mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
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:
@@ -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";
|
||||
|
Reference in New Issue
Block a user