Tzu-Chien Chiu
2005-May-06 03:52 UTC
[LLVMdev] initialize 'dag' variable and interpret asmstring in tablegen .td file
llvm/lib/Target/X86/X86InstrInfo.td: class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr> : Instruction { .... dag OperandList = ops; string AsmString = AsmStr; } def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src), "mov{l} {$src, $dst|$dst, $src}">; I cannot find any document on initializing the 'dag' type variable, and I cannot understand the syntax of "asmstring" either. how does the x86 asmwrite interpret the "AsmString" ?
Chris Lattner
2005-May-06 05:20 UTC
[LLVMdev] initialize 'dag' variable and interpret asmstring in tablegen .td file
On Fri, 6 May 2005, Tzu-Chien Chiu wrote:> llvm/lib/Target/X86/X86InstrInfo.td: > class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string > AsmStr> : Instruction { > .... > dag OperandList = ops; > string AsmString = AsmStr; > } > > def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src), > "mov{l} {$src, $dst|$dst, $src}">; > > I cannot find any document on initializing the 'dag' type variable, > and I cannot understand the syntax of "asmstring" either.The DAG operator is just a nested set of parens, e.g. (X (Y Z), Q), where X,Y,Z,Q are tblgen defs. This is described here: http://llvm.cs.uiuc.edu/docs/TableGenFundamentals.html#values> how does the x86 asmwrite interpret the "AsmString" ?The X86 has two asm formats: Intel and AT&T. Things in {}'s get split up and treated as one or the other. The 0 part is AT&T, the 1th part is Intel. It might make it more clear to just say that this string: "mov{l} {$src, $dst|$dst, $src}" is fully equivalent to this one: "{movl $src, $dst|mov $dst, $src}" No other targets support multiple output formats, so they don't have to worry about this. -Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
Tzu-Chien Chiu
2005-May-06 06:00 UTC
[LLVMdev] initialize 'dag' variable and interpret asmstring in tablegen .td file
The macro $src, $dest used in Instruction::AsmString must be "declared" in Instruction::OperandList, right? $$ has special meaning? On 5/6/05, Chris Lattner <sabre at nondot.org> wrote:> On Fri, 6 May 2005, Tzu-Chien Chiu wrote: > > llvm/lib/Target/X86/X86InstrInfo.td: > > class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string > > AsmStr> : Instruction { > > .... > > dag OperandList = ops; > > string AsmString = AsmStr; > > } > > > > def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src), > > "mov{l} {$src, $dst|$dst, $src}">; > > > > I cannot find any document on initializing the 'dag' type variable, > > and I cannot understand the syntax of "asmstring" either. > > The DAG operator is just a nested set of parens, e.g. (X (Y Z), Q), where > X,Y,Z,Q are tblgen defs. This is described here: > http://llvm.cs.uiuc.edu/docs/TableGenFundamentals.html#values > > > how does the x86 asmwrite interpret the "AsmString" ? > > The X86 has two asm formats: Intel and AT&T. Things in {}'s get split up > and treated as one or the other. The 0 part is AT&T, the 1th part is > Intel. It might make it more clear to just say that this string: > > "mov{l} {$src, $dst|$dst, $src}" > > is fully equivalent to this one: > > "{movl $src, $dst|mov $dst, $src}" > > No other targets support multiple output formats, so they don't have to > worry about this. > > -Chris > > -- > http://nondot.org/sabre/ > http://llvm.cs.uiuc.edu/ >
Possibly Parallel Threads
- [LLVMdev] initialize 'dag' variable and interpret asmstring in tablegen .td file
- [LLVMdev] initialize 'dag' variable and interpret asmstring in tablegen .td file
- [LLVMdev] problems with tablegen and namespaces
- [LLVMdev] Accessing InstrFormat.td fields
- [LLVMdev] bug in tablegen?