wrong imm value for branch conditions..


I have added Branch condition BGEID like below…

def : Pat<(brcond (setcc (i32 GR32:$L), (i32 GR32:$R), SETGE), bb:$T),

(BGEID (CMP GR32:$L, GR32:$R), bb:$T)>;

def BGEID : TBT<0b101110, (outs), (ins GR32:$ra, brtarget:$offset), “bgeid\t$ra,$offset”, [], IIC_BRc> {

let rd = 0b10101;


def brtarget : Operand


let PrintMethod = “printPCRelImmOperand”;

let EncoderMethod = “getBranchTargetOpValue”;

let OperandType = “OPERAND_PCREL”;

let DecoderMethod = “DecodeBranchTarget”;


getBranchTargetOpValue**(const MCInst &MI, unsigned OpNo,**

SmallVectorImpl &Fixups,

const MCSubtargetInfo &STI) const {

const MCOperand &MO = MI.getOperand(OpNo);

printf(“in getBranchTargetOpValue\n”);




return 0;


I have added code like above for bgeid instruction.I am able to genereate bgeid instruction but the offset value is not proper.

9c: 14a53001 cmp r5, r5, r6

a0: bea50005 bgeid r5, 5 // a5

a4: b8100034 brid 52 // d8

I am getting 5 as offset and it is pointing to invalid address. I tried to fix it in getBranchTargetOpValue function but the control is not even coming to getBranchTargetOpValue.

am I doing anything wrong here.

Thanking you in advance…


Mahesh B