[llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp
Reid Spencer
rspencer at reidspencer.com
Sat Apr 21 09:46:08 PDT 2007
Christopher,
On Sat, 2007-04-21 at 03:17 -0500, Christopher Lamb wrote:
>
> Changes in directory llvm/lib/Bytecode/Writer:
>
> Writer.cpp updated: 1.173 -> 1.174
> ---
> Log message:
>
>
> add support for alignment attributes on load/store instructions
>
>
> ---
> Diffs of the changes: (+27 -5)
>
> Writer.cpp | 32 +++++++++++++++++++++++++++-----
> 1 files changed, 27 insertions(+), 5 deletions(-)
>
>
> Index: llvm/lib/Bytecode/Writer/Writer.cpp
> diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.173 llvm/lib/Bytecode/Writer/Writer.cpp:1.174
> --- llvm/lib/Bytecode/Writer/Writer.cpp:1.173 Mon Apr 16 18:32:28 2007
> +++ llvm/lib/Bytecode/Writer/Writer.cpp Sat Apr 21 03:16:25 2007
> @@ -616,7 +616,7 @@
> unsigned Opcode = I.getOpcode();
> unsigned NumOperands = I.getNumOperands();
>
> - // Encode 'tail call' as 61, 'volatile load' as 62, and 'volatile store' as
> + // Encode 'tail call' as 61
> // 63.
> if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
> if (CI->getCallingConv() == CallingConv::C) {
> @@ -632,10 +632,6 @@
> } else {
> Opcode = 58; // Call escape sequence.
> }
> - } else if (isa<LoadInst>(I) && cast<LoadInst>(I).isVolatile()) {
> - Opcode = 62;
> - } else if (isa<StoreInst>(I) && cast<StoreInst>(I).isVolatile()) {
> - Opcode = 63;
> }
>
> // Figure out which type to encode with the instruction. Typically we want
> @@ -744,6 +740,32 @@
> } else if (isa<InvokeInst>(I)) {
> // Invoke escape seq has at least 4 operands to encode.
> ++NumOperands;
> + } else if (const LoadInst *LI = dyn_cast<LoadInst>(&I)) {
> + // Encode attributed load as opcode 62
> + // We need to encode the attributes of the load instruction as the second
> + // operand. Its not really a slot, but we don't want to break the
> + // instruction format for these instructions.
> + if (LI->getAlignment() || LI->isVolatile()) {
> + NumOperands = 2;
> + Slots[1] = ((Log2_32(LI->getAlignment())+1)<<1) +
> + (LI->isVolatile() ? 1 : 0);
Is this Log2_32 really needed? The alignment should already be a power
of two. If the alignment is something like 7 then you'll get rounding
to 8 but I contend that an alignment of 7 can't happen. This can be
assured in the bcreader and the asmparser.
> + if (Slots[1] > MaxOpSlot)
> + MaxOpSlot = Slots[1];
> + Opcode = 62;
> + }
> + } else if (const StoreInst *SI = dyn_cast<StoreInst>(&I)) {
> + // Encode attributed store as opcode 63
> + // We need to encode the attributes of the store instruction as the third
> + // operand. Its not really a slot, but we don't want to break the
> + // instruction format for these instructions.
> + if (SI->getAlignment() || SI->isVolatile()) {
> + NumOperands = 3;
> + Slots[2] = ((Log2_32(SI->getAlignment())+1)<<1) +
> + (SI->isVolatile() ? 1 : 0);
> + if (Slots[2] > MaxOpSlot)
> + MaxOpSlot = Slots[2];
> + Opcode = 63;
> + }
> }
>
> // Decide which instruction encoding to use. This is determined primarily
>
>
>
> _______________________________________________
> 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