[LLVMdev] ADDE to use branch registers

Maurice Daverveldt maurice.daverveldt at gmail.com
Fri Oct 4 02:42:54 PDT 2013


Hi,

I am working on a LLVM backend that has eight different branch registers. I am having a lot of trouble with implementing the following instructions:

addcg $r0.1, $b0.0 = $r0.1, $r0.1, $b0.0

(r is a general purpose register and b is a 1 bit branch register) The branch register is used for carry in and carry out. 

I have noticed that this instruction is very closely related to the ADDE instruction so this seemed like a logical place to start. I have seen that ADDC instructions and ADDE instructions are linked together using "glue". Is there a way to "save" the glue to one of the branch registers?

I have played around with some custom lowering of ADDC and ADDE instructions by trying to add an extra register to the instruction pattern. The following code snippet is not really working for me:

SDValue rvexTargetLowering::
LowerAddCG(SDValue Op, SelectionDAG &DAG) const
{
  unsigned Opc = Op.getOpcode();
  SDNode* N = Op.getNode();
  EVT VT = Op.getValueType();
  DebugLoc dl = N->getDebugLoc();

  SDValue BReg = DAG.getTargetConstant(rvex::B0, VT); // Add extra register to output

  return DAG.getNode(rvexISD::Addc, dl, VT, N->getOperand(0), N->getOperand(1), BReg);
}  

Could anybody advice me on a way to make the backend know that the ADDE instruction will cause a branch register to be used?

Thanks in advance!

Maurice Daverveldt
TUDelft





More information about the llvm-dev mailing list