[llvm-commits] PR400 align attribute

Chris Lattner clattner at apple.com
Thu Apr 19 22:35:40 PDT 2007


>>
>> This adds an extra word to LoadInst and StoreInst.  Since  
>> alignments must be a power of two, I suggest representing them as  
>> a shift amount (e.g, an alignment of 16 is stored as 4, 1<<4 ==  
>> 16).  Given this, we don't need a large number of bits to support  
>> very large shift amounts.  Given this, you can store it in the  
>> "SubClassData" member of Value (which is 16 bits wide), to avoid  
>> using the word.  Load and StoreInst currently store a bit in that  
>> word.  The only trick here is that we want power-of-two-plus one,  
>> so that "0" represents an alignment of zero, not an alignment of 1.
>
> Yeah, I thought about that. It's not a bit problem, I'll encode the  
> alignment the same way it's encoded in the BC which has this same  
> issue.

sounds good.

>> Please don't #include MathExtras.h in Instructions.h
>
> No prob. I'll have to move the accessor methods to the .cpp file  
> and include MathExtras there to use the Log2_32 function, though.

Ok.  The "getter" should be inlined (it just uses <<, nothing exotic  
like log :).

>> +  LoadInst(Value *Ptr, const std::string &Name, bool isVolatile =  
>> false,
>> +           Instruction *InsertBefore = 0, unsigned Align = 0);
>>
>> The instruction* to insert before should be the last member.  In  
>> the case of alignment, I don't think we need a helper constructor  
>> for this (in fact, we probably don't need one for volatile  
>> either).  Any clients that want to create a load instruction with  
>> a specific alignment can create it, then use setAlignment() :)
>
> These helper constructors were used quite prolifically in the  
> lowering passes, like the hunk below. Do you prefer them to be  
> changed to set the attribute directly?

All of the codegen stuff looks good and should stay as you wrote it,  
I'm just talking about the LLVM level stuff.  If you think that  
having an alignment-taking-ctor is useful, feel free to keep it, but  
move the instruction-to-insert-before to the end of the operand list.

-Chris


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20070419/7058e8de/attachment.html>


More information about the llvm-commits mailing list