[llvm-commits] [llvm] r171221 - in /llvm/trunk/lib/VMCore: AttributeImpl.h Attributes.cpp

Bill Wendling isanbard at gmail.com
Sat Dec 29 16:06:18 PST 2012


Hi Nakamura,

The Constant kafir future use where we will be storing not only integers but strings as well. I should have mentioned that in the commit message. 

-bw

On Dec 29, 2012, at 6:27 AM, NAKAMURA Takumi <geek4civic at gmail.com> wrote:

> Bill, I don't understand why you introduced llvm::Constant here.
> Would it be enough with APInt, or SmallBitVector?
> 
> 2012/12/29 Bill Wendling <isanbard at gmail.com>:
>> Author: void
>> Date: Sat Dec 29 06:29:38 2012
>> New Revision: 171221
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=171221&view=rev
>> Log:
>> Use a 'Constant' object instead of a bit field to store the attribute data.
>> 
>> Modified:
>>    llvm/trunk/lib/VMCore/AttributeImpl.h
>>    llvm/trunk/lib/VMCore/Attributes.cpp
>> 
>> Modified: llvm/trunk/lib/VMCore/AttributeImpl.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AttributeImpl.h?rev=171221&r1=171220&r2=171221&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/VMCore/AttributeImpl.h (original)
>> +++ llvm/trunk/lib/VMCore/AttributeImpl.h Sat Dec 29 06:29:38 2012
>> @@ -21,6 +21,7 @@
>> 
>> namespace llvm {
>> 
>> +class Constant;
>> class LLVMContext;
>> 
>> //===----------------------------------------------------------------------===//
>> @@ -29,9 +30,9 @@
>> /// could be a single enum, a tuple, or a string. It uses a discriminated union
>> /// to distinguish them.
>> class AttributeImpl : public FoldingSetNode {
>> -  uint64_t Bits;                // FIXME: We will be expanding this.
>> +  Constant *Data;
>> public:
>> -  AttributeImpl(uint64_t bits) : Bits(bits) {}
>> +  AttributeImpl(LLVMContext &C, uint64_t data);
>> 
>>   bool hasAttribute(uint64_t A) const;
>> 
>> @@ -41,16 +42,14 @@
>>   uint64_t getAlignment() const;
>>   uint64_t getStackAlignment() const;
>> 
>> -  uint64_t Raw() const { return Bits; } // FIXME: Remove.
>> +  uint64_t Raw() const;         // FIXME: Remove.
>> 
>>   static uint64_t getAttrMask(uint64_t Val);
>> 
>>   void Profile(FoldingSetNodeID &ID) const {
>> -    Profile(ID, Bits);
>> -  }
>> -  static void Profile(FoldingSetNodeID &ID, uint64_t Bits) {
>> -    ID.AddInteger(Bits);
>> +    Profile(ID, Data);
>>   }
>> +  static void Profile(FoldingSetNodeID &ID, Constant *Data);
>> };
>> 
>> //===----------------------------------------------------------------------===//
>> 
>> Modified: llvm/trunk/lib/VMCore/Attributes.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=171221&r1=171220&r2=171221&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/VMCore/Attributes.cpp (original)
>> +++ llvm/trunk/lib/VMCore/Attributes.cpp Sat Dec 29 06:29:38 2012
>> @@ -53,7 +53,7 @@
>>   if (!PA) {
>>     // If we didn't find any existing attributes of the same shape then create a
>>     // new one and insert it.
>> -    PA = new AttributeImpl(B.Raw());
>> +    PA = new AttributeImpl(Context, B.Raw());
>>     pImpl->AttrsSet.InsertNode(PA, InsertPoint);
>>   }
>> 
>> @@ -298,6 +298,14 @@
>> // AttributeImpl Definition
>> //===----------------------------------------------------------------------===//
>> 
>> +AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) {
>> +  Data = ConstantInt::get(Type::getInt64Ty(C), data);
>> +}
>> +
>> +uint64_t AttributeImpl::Raw() const {
>> +  return cast<ConstantInt>(Data)->getZExtValue();
>> +}
>> +
>> uint64_t AttributeImpl::getAttrMask(uint64_t Val) {
>>   switch (Val) {
>>   case Attribute::None:            return 0;
>> @@ -354,6 +362,10 @@
>>   return Raw() & getAttrMask(Attribute::StackAlignment);
>> }
>> 
>> +void AttributeImpl::Profile(FoldingSetNodeID &ID, Constant *Data) {
>> +  ID.AddInteger(cast<ConstantInt>(Data)->getZExtValue());
>> +}
>> +
>> //===----------------------------------------------------------------------===//
>> // AttributeSetImpl Definition
>> //===----------------------------------------------------------------------===//
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list