Tom Stellard
2012-Jan-20 02:07 UTC
[LLVMdev] Tablegen: How to define an instruction that reads and writes the same register
Hi, Is it possible to define an Instruction with tablegen that reads and writes the same register? For example, an increment instruction that reads a value from a register, adds one to it and then writes the result back to the same register. Thanks, Tom
Eli Friedman
2012-Jan-20 02:25 UTC
[LLVMdev] Tablegen: How to define an instruction that reads and writes the same register
On Thu, Jan 19, 2012 at 6:07 PM, Tom Stellard <thomas.stellard at amd.com> wrote:> Hi, > > Is it possible to define an Instruction with tablegen that reads and > writes the same register? For example, an increment instruction that > reads a value from a register, adds one to it and then writes the result > back to the same register.Yes; you just write the instruction as if the dest and src are distinct, then specify 'let Constraints = "$src1 = $dst"'. See for example INC32r in the x86 backend. -Eli
Peter Cooper
2012-Jan-20 02:28 UTC
[LLVMdev] Tablegen: How to define an instruction that reads and writes the same register
Hi Tom This is frequently done in the x86 target using a tablegen constraint. For example, from X86InstrArithmetic.td we have let Constraints = "$src1 = $dst" in { def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1), "inc{b}\t$dst", [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>; } Thanks, Pete On Jan 19, 2012, at 6:07 PM, Tom Stellard wrote:> Hi, > > Is it possible to define an Instruction with tablegen that reads and > writes the same register? For example, an increment instruction that > reads a value from a register, adds one to it and then writes the result > back to the same register. > > Thanks, > Tom > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Maybe Matching Threads
- [LLVMdev] A question about instruction operands.
- [LLVMdev] A question about instruction operands.
- [LLVMdev] ISel using an operand as both source and destination
- [LLVMdev] ISel using an operand as both source and destination
- [LLVMdev] ISel using an operand as both source and destination