[llvm-dev] access to MIOperandInfo values in asm string

Nicolas Belleville NB248137 via llvm-dev llvm-dev at lists.llvm.org
Mon May 9 09:14:51 PDT 2016


Hi all,

I am currently doing a work on ARM backend, and I have to modify the way
instructions are printed. I am struggling a little with tablegen files.

For some of the instructions, I'd like to access to the values of fields
of some variables and print it in the asm string.

For example, in ARMInstrThumb.td, for the instruction tLDRspi :
the variable addr is of type t_addrmode_sp.
This type definition is this one :
        def t_addrmode_sp : MemOperand,
                            ComplexPattern<i32, 2,
        "SelectCdgThumbAddrModeSP", []> {
          let EncoderMethod = "getAddrModeCdgThumbSPOpValue";
          let DecoderMethod = "DecodeCdgThumbAddrModeSP";
          let PrintMethod = "printCdgThumbAddrModeSPOperand";
          let ParserMatchClass = t_addrmode_sp_asm_operand;
          let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
        }

I'd like to access to $addr.base or $addr.offsimm (its MIOperandInfo) in
the asm string, to print them separately.
For example, instead of printing "ldr sp, #3" I'd like to be able to
print "ldr sp, sp, #3" or "ldr #3". 

Yet, putting "$addr.base" in the asm string will print the value of
"$addr" and then ".base", and not the value of the base field of addr.
(ie "ldr $addr.base" is printing in "ldr sp, #3.base", and not printing
as "ldr sp")

How can I do to access this field in the asm string ?


Thanks a lot

Nicolas



More information about the llvm-dev mailing list