LLVM Backend DAGToDAGISel

I am currently working on DAGToDAGISel class and am trying to figure out a way for storing an immediate in register if it is greater than 31.

I have something like:

unsigned Imm = Node->getConstantOperandVal(2);
if (Imm > 31)
{

//wanted to load into the register and get the register number

Imm = Register number
}

Instead of storing it as immediate:
SDValue immediteVAL = CurDAG->getTargetConstant(Imm, MVT::i32);

Any clues or references which might help me with this?

Thanks,

Ambuj

From: "Ambuj Agrawal" <ambujbwt@gmail.com>
To: llvmdev@cs.uiuc.edu
Sent: Friday, February 20, 2015 10:13:56 AM
Subject: [LLVMdev] LLVM Backend DAGToDAGISel

I am currently working on DAGToDAGISel class and am trying to figure
out a way for storing an immediate in register if it is greater than
31.

I have something like:

unsigned Imm = Node->getConstantOperandVal(2);
if (Imm > 31)
{
//wanted to load into the register and get the register number

Imm = Register number
}

Instead of storing it as immediate:
SDValue immediteVAL = CurDAG->getTargetConstant(Imm, MVT::i32);

Any clues or references which might help me with this?

You can create the machine-instruction nodes used to materialized the integer. You may also be able to let the generic constant integer selection code handle it for you, but that will mean that your instruction patterns need to refuse to match the larger integers as immediates. The PPC backend uses both techniques in places. Regarding the patterns, see maskimm32 and imm32SExt16, for example, in lib/Target/PowerPC/PPCInstrInfo.td.

-Hal