Reimplement the parameter attributes support, phase #1. hilights:

1. There is now a "PAListPtr" class, which is a smart pointer around
   the underlying uniqued parameter attribute list object, and manages
   its refcount.  It is now impossible to mess up the refcount.
2. PAListPtr is now the main interface to the underlying object, and
   the underlying object is now completely opaque.
3. Implementation details like SmallVector and FoldingSet are now no
   longer part of the interface.
4. You can create a PAListPtr with an arbitrary sequence of
   ParamAttrsWithIndex's, no need to make a SmallVector of a specific 
   size (you can just use an array or scalar or vector if you wish).
5. All the client code that had to check for a null pointer before
   dereferencing the pointer is simplified to just access the 
   PAListPtr directly.
6. The interfaces for adding attrs to a list and removing them is a
   bit simpler.

Phase #2 will rename some stuff (e.g. PAListPtr) and do other less 
invasive changes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48289 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2008-03-12 17:45:29 +00:00
parent 37f603f5d7
commit 58d74910c6
34 changed files with 1320 additions and 1630 deletions

View File

@@ -17,7 +17,6 @@
#include "llvm/InlineAsm.h"
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/ParamAttrsList.h"
#include "llvm/ValueSymbolTable.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/ADT/STLExtras.h"
@@ -2056,13 +2055,11 @@ UpRTypes
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
if (isVarArg) Params.pop_back();
const ParamAttrsList *PAL = 0;
PAListPtr PAL;
if (lastCallingConv == OldCallingConv::CSRet) {
ParamAttrsVector Attrs;
ParamAttrsWithIndex PAWI;
PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
Attrs.push_back(PAWI);
PAL = ParamAttrsList::get(Attrs);
ParamAttrsWithIndex PAWI =
ParamAttrsWithIndex::get(1, ParamAttr::StructRet);
PAL = PAListPtr::get(&PAWI, 1);
}
const FunctionType *FTy =
@@ -2974,11 +2971,9 @@ FunctionHeaderH
// Convert the CSRet calling convention into the corresponding parameter
// attribute.
if ($1 == OldCallingConv::CSRet) {
ParamAttrsVector Attrs;
ParamAttrsWithIndex PAWI;
PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
Attrs.push_back(PAWI);
Fn->setParamAttrs(ParamAttrsList::get(Attrs));
ParamAttrsWithIndex PAWI =
ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
Fn->setParamAttrs(PAListPtr::get(&PAWI, 1));
}
// Add all of the arguments we parsed to the function...
@@ -3296,11 +3291,9 @@ BBTerminatorInst
}
cast<InvokeInst>($$.TI)->setCallingConv(upgradeCallingConv($2));
if ($2 == OldCallingConv::CSRet) {
ParamAttrsVector Attrs;
ParamAttrsWithIndex PAWI;
PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
Attrs.push_back(PAWI);
cast<InvokeInst>($$.TI)->setParamAttrs(ParamAttrsList::get(Attrs));
ParamAttrsWithIndex PAWI =
ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
cast<InvokeInst>($$.TI)->setParamAttrs(PAListPtr::get(&PAWI, 1));
}
delete $3.PAT;
delete $6;
@@ -3715,11 +3708,9 @@ InstVal
}
// Deal with CSRetCC
if ($2 == OldCallingConv::CSRet) {
ParamAttrsVector Attrs;
ParamAttrsWithIndex PAWI;
PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg
Attrs.push_back(PAWI);
cast<CallInst>($$.I)->setParamAttrs(ParamAttrsList::get(Attrs));
ParamAttrsWithIndex PAWI =
ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
cast<CallInst>($$.I)->setParamAttrs(PAListPtr::get(&PAWI, 1));
}
delete $3.PAT;
delete $6;