X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FCppBackend%2FCPPBackend.cpp;h=0f9ba58295babc684b5834e433c16a9ddd823da2;hb=034b94b17006f51722886b0f2283fb6fb19aca1f;hp=4ddcd38aca6e763672499c9a30d8bc3b7959c6ad;hpb=4aa189909a194b4b858aefa0c186fa6504845bfd;p=oota-llvm.git diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 4ddcd38aca6..0f9ba58295b 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -13,25 +13,25 @@ //===----------------------------------------------------------------------===// #include "CPPTargetMachine.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/CallingConv.h" +#include "llvm/Config/config.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/InlineAsm.h" #include "llvm/Instruction.h" #include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" -#include "llvm/PassManager.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCSubtargetInfo.h" -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" +#include "llvm/PassManager.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/TargetRegistry.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/Config/config.h" #include #include #include @@ -141,7 +141,7 @@ namespace { std::string getCppName(const Value* val); inline void printCppName(const Value* val); - void printAttributes(const AttrListPtr &PAL, const std::string &name); + void printAttributes(const AttributeSet &PAL, const std::string &name); void printType(Type* Ty); void printTypes(const Module* M); @@ -464,9 +464,9 @@ void CppWriter::printCppName(const Value* val) { printEscapedString(getCppName(val)); } -void CppWriter::printAttributes(const AttrListPtr &PAL, +void CppWriter::printAttributes(const AttributeSet &PAL, const std::string &name) { - Out << "AttrListPtr " << name << "_PAL;"; + Out << "AttributeSet " << name << "_PAL;"; nl(Out); if (!PAL.isEmpty()) { Out << '{'; in(); nl(Out); @@ -474,13 +474,15 @@ void CppWriter::printAttributes(const AttrListPtr &PAL, Out << "AttributeWithIndex PAWI;"; nl(Out); for (unsigned i = 0; i < PAL.getNumSlots(); ++i) { unsigned index = PAL.getSlot(i).Index; - Attributes attrs = PAL.getSlot(i).Attrs; - Out << "PAWI.Index = " << index << "U; PAWI.Attrs = Attribute::None "; -#define HANDLE_ATTR(X) \ - if (attrs & Attribute::X) \ - Out << " | Attribute::" #X; \ - attrs &= ~Attribute::X; - + AttrBuilder attrs(PAL.getSlot(i).Attrs); + Out << "PAWI.Index = " << index << "U;\n"; + Out << " {\n AttrBuilder B;\n"; + +#define HANDLE_ATTR(X) \ + if (attrs.hasAttribute(Attribute::X)) \ + Out << " B.addAttribute(Attribute::" #X ");\n"; \ + attrs.removeAttribute(Attribute::X); + HANDLE_ATTR(SExt); HANDLE_ATTR(ZExt); HANDLE_ATTR(NoReturn); @@ -505,19 +507,18 @@ void CppWriter::printAttributes(const AttrListPtr &PAL, HANDLE_ATTR(ReturnsTwice); HANDLE_ATTR(UWTable); HANDLE_ATTR(NonLazyBind); + HANDLE_ATTR(MinSize); #undef HANDLE_ATTR - if (attrs & Attribute::StackAlignment) - Out << " | Attribute::constructStackAlignmentFromInt(" - << Attribute::getStackAlignmentFromAttrs(attrs) - << ")"; - attrs &= ~Attribute::StackAlignment; - assert(attrs == 0 && "Unhandled attribute!"); - Out << ";"; + if (attrs.hasAttribute(Attribute::StackAlignment)) + Out << " B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n"; + attrs.removeAttribute(Attribute::StackAlignment); + assert(!attrs.hasAttributes() && "Unhandled attribute!"); + Out << " PAWI.Attrs = Attribute::get(mod->getContext(), B);\n }"; nl(Out); Out << "Attrs.push_back(PAWI);"; nl(Out); } - Out << name << "_PAL = AttrListPtr::get(Attrs);"; + Out << name << "_PAL = AttributeSet::get(mod->getContext(), Attrs);"; nl(Out); out(); nl(Out); Out << '}'; nl(Out); @@ -1940,14 +1941,6 @@ void CppWriter::printModule(const std::string& fname, } nl(Out); - // Loop over the dependent libraries and emit them. - Module::lib_iterator LI = TheModule->lib_begin(); - Module::lib_iterator LE = TheModule->lib_end(); - while (LI != LE) { - Out << "mod->addLibrary(\"" << *LI << "\");"; - nl(Out); - ++LI; - } printModuleBody(); nl(Out) << "return mod;"; nl(Out,-1) << "}";