llvm.org GIT mirror llvm / 9a131c5
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 Bill Wendling 7 years ago
1 changed file(s) with 39 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
469469 nl(Out);
470470 if (!PAL.isEmpty()) {
471471 Out << '{'; in(); nl(Out);
472 Out << "SmallVector Attrs;"; nl(Out);
473 Out << "AttributeWithIndex PAWI;"; nl(Out);
472 Out << "SmallVector Attrs;"; nl(Out);
473 Out << "AttributeSet PAS;"; in(); nl(Out);
474474 for (unsigned i = 0; i < PAL.getNumSlots(); ++i) {
475475 unsigned index = PAL.getSlotIndex(i);
476476 AttrBuilder attrs(PAL.getSlotAttributes(i), index);
477 Out << "PAWI.Index = " << index << "U;\n";
478 Out << " {\n AttrBuilder B;\n";
479
480 #define HANDLE_ATTR(X) \
481 if (attrs.contains(Attribute::X)) \
482 Out << " B.addAttribute(Attribute::" #X ");\n"; \
483 attrs.removeAttribute(Attribute::X);
477 Out << "{"; in(); nl(Out);
478 Out << "AttrBuilder B;"; nl(Out);
479
480 #define HANDLE_ATTR(X) \
481 if (attrs.contains(Attribute::X)) { \
482 Out << "B.addAttribute(Attribute::" #X ");"; nl(Out); \
483 attrs.removeAttribute(Attribute::X); \
484 }
484485
485486 HANDLE_ATTR(SExt);
486487 HANDLE_ATTR(ZExt);
509510 HANDLE_ATTR(NonLazyBind);
510511 HANDLE_ATTR(MinSize);
511512 #undef HANDLE_ATTR
512 if (attrs.contains(Attribute::StackAlignment))
513 Out << " B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n";
514 attrs.removeAttribute(Attribute::StackAlignment);
513
514 if (attrs.contains(Attribute::StackAlignment)) {
515 Out << "B.addStackAlignmentAttr(" << attrs.getStackAlignment()<<')';
516 nl(Out);
517 attrs.removeAttribute(Attribute::StackAlignment);
518 }
519
515520 assert(!attrs.hasAttributes() && "Unhandled attribute!");
516 Out << " PAWI.Attrs = Attribute::get(mod->getContext(), B);\n }";
517 nl(Out);
518 Out << "Attrs.push_back(PAWI);";
519 nl(Out);
521 Out << "PAS = AttributeSet::get(mod->getContext(), ";
522 if (index == ~0U)
523 Out << "~0U,";
524 else
525 Out << index << "U,";
526 Out << " B);"; out(); nl(Out);
527 Out << "}"; out(); nl(Out);
528 nl(Out);
529 Out << "Attrs.push_back(PAS);"; nl(Out);
520530 }
521531 Out << name << "_PAL = AttributeSet::get(mod->getContext(), Attrs);";
522532 nl(Out);
18881898
18891899 void CppWriter::printProgram(const std::string& fname,
18901900 const std::string& mName) {
1891 Out << "#include \n";
1892 Out << "#include \n";
1893 Out << "#include \n";
1894 Out << "#include \n";
1895 Out << "#include \n";
1896 Out << "#include \n";
1897 Out << "#include \n";
1898 Out << "#include \n";
1899 Out << "#include \n";
1900 Out << "#include \n";
1901 Out << "#include \n";
1902 Out << "#include \n";
19031901 Out << "#include \n";
19041902 Out << "#include \n";
1903
19051904 Out << "#include \n";
19061905 Out << "#include \n";
19071906 Out << "#include \n";
1907 Out << "#include \n";
1908 Out << "#include \n";
1909 Out << "#include \n";
1910 Out << "#include \n";
1911 Out << "#include \n";
1912 Out << "#include \n";
1913 Out << "#include \n";
1914 Out << "#include \n";
1915 Out << "#include \n";
1916 Out << "#include \n";
1917 Out << "#include \n";
1918 Out << "#include \n";
19081919 Out << "#include \n";
19091920 Out << "using namespace llvm;\n\n";
19101921 Out << "Module* " << fname << "();\n\n";