[llvm-dev] Immediate operand for load instruction, in back end

Daniel Sanders via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 22 09:49:44 PDT 2016


Hi Alex,

So far, the code you've mentioned only defines a couple tablegen classes but doesn't define the instruction itself. To define the instruction you will also need a 'def' statement. For MIPS MSA, this statement looks like this:
    def LD_D: LD_D_ENC, LD_D_DESC;
This defines an instruction (LD_D) with the encoding specified by the LD_D_ENC class, and the operation description (including assembly syntax) specified by the LD_D_DESC class. You'll sometimes find 'adjectives' like ISA_MIPS2 which specify the version of the MIPS architecture in which the instruction is available. We don't need one here because all the MSA instructions specify the MSA requirement in one of the base classes of LD_D_ENC.

For CodeGen support, you will also need to make changes to ${TARGET}ISelLowering.cpp (MipsSEISelLowering.cpp for MIPS). The relevant code for MIPS is in addMSAIntType() and addMSAFloatType() and makes the vector types legal by binding them to a register class and specifies how to handle each operation using setOperationAction().

>     I've tried to change mem_msa to hold only let MIOperandInfo = (ops
> simm10) but there

It sounds like you're on the right track but there may be an easier way. Continuing on this track, I believe you will also need to change the addrimm10 mentioned in the argument list for LD_DESC_BASE. The one for MIPS will be matching the DAG using the selectIntAddrMSA() function which will produce the two operands expected by mem_msa.

I haven't tried this but given that you only want an immediate address, it may be easier to use an immediate operand (e.g. uimm4_ptr, you may need to search for 'uimm # I # _ptr' for the definition) and an ImmLeaf subclass (e.g. immZExt4Ptr) instead of the mem_msa and addrimm10.

Hope this helps
 
> -----Original Message-----
> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of RCU
> via llvm-dev
> Sent: 18 March 2016 09:44
> To: llvm-dev
> Subject: [llvm-dev] Immediate operand for load instruction, in back end
> 
>    Hello,
>      I'm trying to define in my new back end, in MyBackendInstrInfo.td file, a
> vector load
> instruction that takes an immediate address operand. (I got inspired from
> Mips' MSA SIMD
> extensions.)
>      Could you please tell me what's the right way to do it?
> 
> 
>      Here, the load class has $addrsrc which is a relative address with base a
> certain
> register and offset:
> class LD_DESC_BASE<string instr_asm, SDPatternOperator OpNode,
>      ValueType TyNode, RegisterOperand ROWD,
>      Operand MemOpnd = mem_msa,
>      ComplexPattern Addr = addrimm10,
>      InstrItinClass itin = NoItinerary> {
>    dag OutOperandList = (outs ROWD:$wd);
>    dag InOperandList = (ins MemOpnd:$addrsrc);
>    string AsmString = !strconcat("mov $wd, ($addrsrc)");
>    list<dag> Pattern = [(set ROWD:$wd, (TyNode (OpNode Addr:$addrsrc)))];
>    InstrItinClass Itinerary = itin;
>    string DecoderMethod = "DecodeMSA128Mem";
> }
> 
> class LD_D_DESC : LD_DESC_BASE<"ldvd", load, v32i16, MSA128DOpnd>;
> 
> 
>     I've tried to change mem_msa to hold only let MIOperandInfo = (ops
> simm10) but there
> are problems it seems:
> 
> // MSA specific address operand
> def mem_msa : mem_generic {
> let MIOperandInfo = (ops ptr_rc, simm10);
> let EncoderMethod = "getMSAMemEncoding";
> }
> 
> 
> 
>     Could you please tell me what is the simplest way to define in
> LD_DESC_BASE a $addrsrc
> that is just an immediate value like i16 or i16imm?
> 
>    Thank you very much,
>      Alex
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list