#include "llvm/IR/TypeFinder.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/CFG.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
#include <cctype>
using namespace llvm;
+static cl::opt<bool>
+OldStyleAttrSyntax("enable-old-style-attr-syntax",
+ cl::desc("Output attributes on functions rather than in attribute groups"),
+ cl::Hidden,
+ cl::init(false));
+
// Make virtual table appear in this compilation unit.
AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {}
printFunction(I);
// Output all attribute groups.
- if (!Machine.as_empty()) {
+ if (!OldStyleAttrSyntax && !Machine.as_empty()) {
Out << '\n';
writeAllAttributeGroups();
}
Out << "; Materializable\n";
const AttributeSet &Attrs = F->getAttributes();
- if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) {
+ if (!OldStyleAttrSyntax && Attrs.hasAttributes(AttributeSet::FunctionIndex)) {
AttributeSet AS = Attrs.getFnAttributes();
- std::string AttrStr;
-
- unsigned Idx = 0;
- for (unsigned E = AS.getNumSlots(); Idx != E; ++Idx)
- if (AS.getSlotIndex(Idx) == AttributeSet::FunctionIndex)
- break;
-
- for (AttributeSet::iterator I = AS.begin(Idx), E = AS.end(Idx);
- I != E; ++I) {
- Attribute Attr = *I;
- if (!Attr.isStringAttribute()) {
- if (!AttrStr.empty()) AttrStr += ' ';
- AttrStr += Attr.getAsString();
- }
- }
-
+ std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, true);
if (!AttrStr.empty())
Out << "; Function Attrs: " << AttrStr << '\n';
}
Out << ')';
if (F->hasUnnamedAddr())
Out << " unnamed_addr";
- if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
- Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes());
+ if (!OldStyleAttrSyntax) {
+ if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
+ Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes());
+ } else {
+ AttributeSet AS = Attrs.getFnAttributes();
+ std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, true);
+ if (!AttrStr.empty())
+ Out << ' ' << AttrStr;
+ }
if (F->hasSection()) {
Out << " section \"";
PrintEscapedString(F->getSection(), Out);
for (std::vector<std::pair<AttributeSet, unsigned> >::iterator
I = asVec.begin(), E = asVec.end(); I != E; ++I)
Out << "attributes #" << I->second << " = { "
- << I->first.getAsString(AttributeSet::FunctionIndex, true) << " }\n";
+ << I->first.getAsString(AttributeSet::FunctionIndex, false, true)
+ << " }\n";
}
//===----------------------------------------------------------------------===//
return 0;
}
-std::string AttributeSetNode::getAsString(bool InAttrGrp) const {
+std::string AttributeSetNode::getAsString(bool TargetIndependent,
+ bool InAttrGrp) const {
std::string Str = "";
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ) {
- Str += I->getAsString(InAttrGrp);
- if (++I != E) Str += " ";
+ if (!TargetIndependent || !I->isStringAttribute()) {
+ Str += I->getAsString(InAttrGrp);
+ if (++I != E) Str += " ";
+ } else {
+ ++I;
+ }
}
return Str;
}
return ASN ? ASN->getStackAlignment() : 0;
}
-std::string AttributeSet::getAsString(unsigned Index,
+std::string AttributeSet::getAsString(unsigned Index, bool TargetIndependent,
bool InAttrGrp) const {
AttributeSetNode *ASN = getAttributes(Index);
- return ASN ? ASN->getAsString(InAttrGrp) : std::string("");
+ return ASN ? ASN->getAsString(TargetIndependent, InAttrGrp) :
+ std::string("");
}
/// \brief The attributes for the specified index are returned.