revert r179735, it has no testcases, and doesn't really make sense.

llvm-svn: 180574
This commit is contained in:
Chris Lattner 2013-04-25 20:34:16 +00:00
parent 0547d81fdb
commit 49248bb367
4 changed files with 29 additions and 34 deletions

View File

@ -307,8 +307,7 @@ public:
unsigned getStackAlignment(unsigned Index) const; unsigned getStackAlignment(unsigned Index) const;
/// \brief Return the attributes at the index as a string. /// \brief Return the attributes at the index as a string.
std::string getAsString(unsigned Index, bool TargetIndependent = true, std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
bool InAttrGrp = false) const;
typedef ArrayRef<Attribute>::iterator iterator; typedef ArrayRef<Attribute>::iterator iterator;

View File

@ -33,7 +33,6 @@
#include "llvm/IR/TypeFinder.h" #include "llvm/IR/TypeFinder.h"
#include "llvm/IR/ValueSymbolTable.h" #include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/CFG.h" #include "llvm/Support/CFG.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/Dwarf.h" #include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
@ -43,12 +42,6 @@
#include <cctype> #include <cctype>
using namespace llvm; 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. // Make virtual table appear in this compilation unit.
AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {} AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {}
@ -1385,7 +1378,7 @@ void AssemblyWriter::printModule(const Module *M) {
printFunction(I); printFunction(I);
// Output all attribute groups. // Output all attribute groups.
if (!OldStyleAttrSyntax && !Machine.as_empty()) { if (!Machine.as_empty()) {
Out << '\n'; Out << '\n';
writeAllAttributeGroups(); writeAllAttributeGroups();
} }
@ -1613,9 +1606,24 @@ void AssemblyWriter::printFunction(const Function *F) {
Out << "; Materializable\n"; Out << "; Materializable\n";
const AttributeSet &Attrs = F->getAttributes(); const AttributeSet &Attrs = F->getAttributes();
if (!OldStyleAttrSyntax && Attrs.hasAttributes(AttributeSet::FunctionIndex)) { if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) {
AttributeSet AS = Attrs.getFnAttributes(); AttributeSet AS = Attrs.getFnAttributes();
std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, false); 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();
}
}
if (!AttrStr.empty()) if (!AttrStr.empty())
Out << "; Function Attrs: " << AttrStr << '\n'; Out << "; Function Attrs: " << AttrStr << '\n';
} }
@ -1677,15 +1685,8 @@ void AssemblyWriter::printFunction(const Function *F) {
Out << ')'; Out << ')';
if (F->hasUnnamedAddr()) if (F->hasUnnamedAddr())
Out << " unnamed_addr"; Out << " unnamed_addr";
if (!OldStyleAttrSyntax) { if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes());
Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes());
} else {
AttributeSet AS = Attrs.getFnAttributes();
std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, false);
if (!AttrStr.empty())
Out << ' ' << AttrStr;
}
if (F->hasSection()) { if (F->hasSection()) {
Out << " section \""; Out << " section \"";
PrintEscapedString(F->getSection(), Out); PrintEscapedString(F->getSection(), Out);
@ -2156,8 +2157,7 @@ void AssemblyWriter::writeAllAttributeGroups() {
for (std::vector<std::pair<AttributeSet, unsigned> >::iterator for (std::vector<std::pair<AttributeSet, unsigned> >::iterator
I = asVec.begin(), E = asVec.end(); I != E; ++I) I = asVec.begin(), E = asVec.end(); I != E; ++I)
Out << "attributes #" << I->second << " = { " Out << "attributes #" << I->second << " = { "
<< I->first.getAsString(AttributeSet::FunctionIndex, true, true) << I->first.getAsString(AttributeSet::FunctionIndex, true) << " }\n";
<< " }\n";
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -178,7 +178,7 @@ public:
unsigned getAlignment() const; unsigned getAlignment() const;
unsigned getStackAlignment() const; unsigned getStackAlignment() const;
std::string getAsString(bool TargetIndependent, bool InAttrGrp) const; std::string getAsString(bool InAttrGrp) const;
typedef SmallVectorImpl<Attribute>::iterator iterator; typedef SmallVectorImpl<Attribute>::iterator iterator;
typedef SmallVectorImpl<Attribute>::const_iterator const_iterator; typedef SmallVectorImpl<Attribute>::const_iterator const_iterator;

View File

@ -483,16 +483,13 @@ unsigned AttributeSetNode::getStackAlignment() const {
return 0; return 0;
} }
std::string AttributeSetNode::getAsString(bool TargetIndependent, std::string AttributeSetNode::getAsString(bool InAttrGrp) const {
bool InAttrGrp) const {
std::string Str; std::string Str;
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(), for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I) { E = AttrList.end(); I != E; ++I) {
if (TargetIndependent || !I->isStringAttribute()) { if (I != AttrList.begin())
if (I != AttrList.begin()) Str += ' ';
Str += ' '; Str += I->getAsString(InAttrGrp);
Str += I->getAsString(InAttrGrp);
}
} }
return Str; return Str;
} }
@ -848,11 +845,10 @@ unsigned AttributeSet::getStackAlignment(unsigned Index) const {
return ASN ? ASN->getStackAlignment() : 0; return ASN ? ASN->getStackAlignment() : 0;
} }
std::string AttributeSet::getAsString(unsigned Index, bool TargetIndependent, std::string AttributeSet::getAsString(unsigned Index,
bool InAttrGrp) const { bool InAttrGrp) const {
AttributeSetNode *ASN = getAttributes(Index); AttributeSetNode *ASN = getAttributes(Index);
return ASN ? ASN->getAsString(TargetIndependent, InAttrGrp) : return ASN ? ASN->getAsString(InAttrGrp) : std::string("");
std::string("");
} }
/// \brief The attributes for the specified index are returned. /// \brief The attributes for the specified index are returned.