[LLVMdev] specifying accumulator based load/stores

Sanjiv Gupta llvmdev at gmail.com
Thu Jan 17 04:12:18 PST 2008

I have load / store instructions that require accumulator.
So a store looks like..

   mov 3, acc
   st acc, addr

I have specified "acc" as a separate register class containing only one
register which is the "acc".
The instr patterns are then splitted into:

   set imm:$src, ACCClass:$dst  (generating the "mov" above)
   set ACCClass:$src, mem:$dst  (generating the "st" above)

The problem with the generated code is incorrectly assuming that value in
"acc" is still live.
for example, for code like below

   a = 3;
   b = 4;
   c = 3;

it generates:

  mov 3, acc
  st  acc, @a
  mov 4, acc
  st acc, @b
  st acc, @c    (Wrong)

When I use the GPRRegs, which has more regs, the code is ok.
is it because I still haven't implemented the stack/frame related routines
and the value in acc is getting spilled to stack and reloaded?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080117/6285d8b0/attachment.html>

More information about the llvm-dev mailing list