Question about BuildMI()

Let’s assume I have an instruction INSTR that takes 3 operands

def INSTR : F_R<0b001010,(outs Regs:$rd) , (ins Regs:$rb, Regs:$ra), … >

and build this instruction in my code

BuildMI(MB,II,dl, TII.get(INSTR)).add(Ops[0]).add(Ops[1]).add(Ops[2]);

Which Ops element corresponds to which operand?

Is it Ops[0] → rd, Ops[1] → rb, Ops[2] → ra ?

From MachineInstrBuilder::add() implementation in MachineInstrBuilder.h, I can’t tell for sure where the MO argument goes.


That's right. It's left to right, starting with (outs), then (ins).
After that are any implicit operands not declared in the instruction.