From 9a131c544cc06c46a3c39ed0c3e6d4311998b5f1 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 27 Jan 2013 01:22:51 +0000 Subject: Convert the CPP backend to use the AttributeSet instead of AttributeWithIndex. Further removal of the introspective AttributeWithIndex thing. Also fix the #includes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173599 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CppBackend/CPPBackend.cpp | 63 +++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 26 deletions(-) (limited to 'lib/Target/CppBackend') diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 1f4bdf8d89..604abf93cc 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -470,18 +470,19 @@ void CppWriter::printAttributes(const AttributeSet &PAL, nl(Out); if (!PAL.isEmpty()) { Out << '{'; in(); nl(Out); - Out << "SmallVector Attrs;"; nl(Out); - Out << "AttributeWithIndex PAWI;"; nl(Out); + Out << "SmallVector Attrs;"; nl(Out); + Out << "AttributeSet PAS;"; in(); nl(Out); for (unsigned i = 0; i < PAL.getNumSlots(); ++i) { unsigned index = PAL.getSlotIndex(i); AttrBuilder attrs(PAL.getSlotAttributes(i), index); - Out << "PAWI.Index = " << index << "U;\n"; - Out << " {\n AttrBuilder B;\n"; + Out << "{"; in(); nl(Out); + Out << "AttrBuilder B;"; nl(Out); -#define HANDLE_ATTR(X) \ - if (attrs.contains(Attribute::X)) \ - Out << " B.addAttribute(Attribute::" #X ");\n"; \ - attrs.removeAttribute(Attribute::X); +#define HANDLE_ATTR(X) \ + if (attrs.contains(Attribute::X)) { \ + Out << "B.addAttribute(Attribute::" #X ");"; nl(Out); \ + attrs.removeAttribute(Attribute::X); \ + } HANDLE_ATTR(SExt); HANDLE_ATTR(ZExt); @@ -510,14 +511,23 @@ void CppWriter::printAttributes(const AttributeSet &PAL, HANDLE_ATTR(NonLazyBind); HANDLE_ATTR(MinSize); #undef HANDLE_ATTR - if (attrs.contains(Attribute::StackAlignment)) - Out << " B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n"; - attrs.removeAttribute(Attribute::StackAlignment); + + if (attrs.contains(Attribute::StackAlignment)) { + Out << "B.addStackAlignmentAttr(" << attrs.getStackAlignment()<<')'; + nl(Out); + 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);"; + Out << "PAS = AttributeSet::get(mod->getContext(), "; + if (index == ~0U) + Out << "~0U,"; + else + Out << index << "U,"; + Out << " B);"; out(); nl(Out); + Out << "}"; out(); nl(Out); nl(Out); + Out << "Attrs.push_back(PAS);"; nl(Out); } Out << name << "_PAL = AttributeSet::get(mod->getContext(), Attrs);"; nl(Out); @@ -1889,23 +1899,24 @@ void CppWriter::printModuleBody() { void CppWriter::printProgram(const std::string& fname, const std::string& mName) { - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; Out << "#include \n"; Out << "#include \n"; + Out << "#include \n"; Out << "#include \n"; Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "#include \n"; Out << "#include \n"; Out << "using namespace llvm;\n\n"; Out << "Module* " << fname << "();\n\n"; -- cgit v1.2.3