[llvm-commits] [llvm] r173635 - Add special 'get' methods to create an Attribute with an alignment. Also do some random cleanup. No functionality change.
Bill Wendling
isanbard at gmail.com
Sun Jan 27 14:43:04 PST 2013
Author: void
Date: Sun Jan 27 16:43:04 2013
New Revision: 173635
URL: http://llvm.org/viewvc/llvm-project?rev=173635&view=rev
Log:
Add special 'get' methods to create an Attribute with an alignment. Also do some random cleanup. No functionality change.
Modified:
llvm/trunk/include/llvm/IR/Attributes.h
llvm/trunk/lib/IR/Attributes.cpp
Modified: llvm/trunk/include/llvm/IR/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Attributes.h?rev=173635&r1=173634&r2=173635&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Sun Jan 27 16:43:04 2013
@@ -107,11 +107,15 @@ private:
public:
Attribute() : pImpl(0) {}
- /// \brief Return a uniquified Attribute object. This takes the uniquified
- /// value from the Builder and wraps it in the Attribute class.
+ /// \brief Return a uniquified Attribute object.
static Attribute get(LLVMContext &Context, ArrayRef<AttrKind> Kinds);
static Attribute get(LLVMContext &Context, AttrBuilder &B);
+ /// \brief Return a uniquified Attribute object that has the specific
+ /// alignment set.
+ static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align);
+ static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align);
+
/// \brief Return true if the attribute is present.
bool hasAttribute(AttrKind Val) const;
@@ -130,25 +134,18 @@ public:
bool operator==(AttrKind K) const;
bool operator!=(AttrKind K) const;
+ /// \brief Less-than operator. Useful for sorting the attributes list.
bool operator<(Attribute A) const;
+ /// \brief The Attribute is converted to a string of equivalent mnemonic. This
+ /// is, presumably, for writing out the mnemonics for the assembly writer.
+ std::string getAsString() const;
+
void Profile(FoldingSetNodeID &ID) const {
ID.AddPointer(pImpl);
}
- // FIXME: Remove these 'operator' methods.
- bool operator==(const Attribute &A) const {
- return pImpl == A.pImpl;
- }
- bool operator!=(const Attribute &A) const {
- return pImpl != A.pImpl;
- }
-
uint64_t Raw() const;
-
- /// \brief The Attribute is converted to a string of equivalent mnemonic. This
- /// is, presumably, for writing out the mnemonics for the assembly writer.
- std::string getAsString() const;
};
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=173635&r1=173634&r2=173635&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Sun Jan 27 16:43:04 2013
@@ -62,6 +62,17 @@ Attribute Attribute::get(LLVMContext &Co
return Attribute(PA);
}
+Attribute Attribute::getWithAlignment(LLVMContext &Context, uint64_t Align) {
+ AttrBuilder B;
+ return get(Context, B.addAlignmentAttr(Align));
+}
+
+Attribute Attribute::getWithStackAlignment(LLVMContext &Context,
+ uint64_t Align) {
+ AttrBuilder B;
+ return get(Context, B.addStackAlignmentAttr(Align));
+}
+
bool Attribute::hasAttribute(AttrKind Val) const {
return pImpl && pImpl->hasAttribute(Val);
}
More information about the llvm-commits
mailing list