diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-12 17:45:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-12 17:45:29 +0000 |
commit | 58d74910c6b82e622ecbb57d6644d48fec5a5c0f (patch) | |
tree | f04d1ab294b3379bf97d9f727d4ade9e7079ca48 /tools/llvm2cpp | |
parent | 37f603f5d78f735e8de92113429b67c77aa58086 (diff) |
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
Diffstat (limited to 'tools/llvm2cpp')
-rw-r--r-- | tools/llvm2cpp/CppWriter.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp index 45810c36d0..a10fec00fd 100644 --- a/tools/llvm2cpp/CppWriter.cpp +++ b/tools/llvm2cpp/CppWriter.cpp @@ -18,7 +18,6 @@ #include "llvm/InlineAsm.h" #include "llvm/Instruction.h" #include "llvm/Instructions.h" -#include "llvm/ParamAttrsList.h" #include "llvm/Module.h" #include "llvm/TypeSymbolTable.h" #include "llvm/ADT/StringExtras.h" @@ -125,7 +124,7 @@ private: std::string getCppName(const Value* val); inline void printCppName(const Value* val); - void printParamAttrs(const ParamAttrsList* PAL, const std::string &name); + void printParamAttrs(const PAListPtr &PAL, const std::string &name); bool printTypeInternal(const Type* Ty); inline void printType(const Type* Ty); void printTypes(const Module* M); @@ -438,16 +437,16 @@ CppWriter::printCppName(const Value* val) { } void -CppWriter::printParamAttrs(const ParamAttrsList* PAL, const std::string &name) { - Out << "ParamAttrsList *" << name << "_PAL = 0;"; +CppWriter::printParamAttrs(const PAListPtr &PAL, const std::string &name) { + Out << "PAListPtr " << name << "_PAL = 0;"; nl(Out); - if (PAL) { + if (!PAL.isEmpty()) { Out << '{'; in(); nl(Out); - Out << "ParamAttrsVector Attrs;"; nl(Out); + Out << "SmallVector<ParamAttrsWithIndex, 4> Attrs;"; nl(Out); Out << "ParamAttrsWithIndex PAWI;"; nl(Out); - for (unsigned i = 0; i < PAL->size(); ++i) { - uint16_t index = PAL->getParamIndex(i); - ParameterAttributes attrs = PAL->getParamAttrs(index); + for (unsigned i = 0; i < PAL.getNumSlots(); ++i) { + uint16_t index = PAL.getSlot(i).Index; + ParameterAttributes attrs = PAL.getSlot(i).Attrs; Out << "PAWI.index = " << index << "; PAWI.attrs = 0 "; if (attrs & ParamAttr::SExt) Out << " | ParamAttr::SExt"; @@ -466,7 +465,7 @@ CppWriter::printParamAttrs(const ParamAttrsList* PAL, const std::string &name) { Out << "Attrs.push_back(PAWI);"; nl(Out); } - Out << name << "_PAL = ParamAttrsList::get(Attrs);"; + Out << name << "_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());"; nl(Out); out(); nl(Out); Out << '}'; nl(Out); @@ -1748,7 +1747,6 @@ void CppWriter::printProgram( Out << "#include <llvm/BasicBlock.h>\n"; Out << "#include <llvm/Instructions.h>\n"; Out << "#include <llvm/InlineAsm.h>\n"; - Out << "#include <llvm/ParamAttrsList.h>\n"; Out << "#include <llvm/Support/MathExtras.h>\n"; Out << "#include <llvm/Pass.h>\n"; Out << "#include <llvm/PassManager.h>\n"; |