[llvm-dev] How to avoid multiple registers definitions in customInserter.

Krzysztof Parzyszek via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 10 13:41:42 PDT 2018


On 9/10/2018 3:43 AM, Dominique Torette via llvm-dev wrote:
> Hi,
> I’m lowering some of the logical operators (by example the | operator)  
> on integer32.
> Sadly my target only provide native instruction on high and low parts of 
> 32 bits registers.
> So, I have to generate a sequence of two native instructions (LOR 
> followed by HOR).

For instructions that modify a register, but preserve some part of it, 
the typical approach is to add an extra operand that provides the 
pre-existing value of the register. For example

def LOR: Instruction {
   let OutOperandList = (outs RC:$Rd)
   // Rx will hold the incoming value, the high half of it will be 
preserved.
   let InOperandList = (ins RC:$Rx, RC:$Ra, RC:$Rb);
   let Constraints = "$Rd == $Rx";
}

Similarly for HOR. Then have an instruction sequence like

   %10 = IMPLICIT_DEF         ; if there is no preexisting value
   %11 = LOR %10, %..., %...
   %12 = HOR %11, %..., %...

-Krzysztof

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation


More information about the llvm-dev mailing list