[PATCH] Add support for ARM modified immediate syntax

Tim Northover t.p.northover at gmail.com
Tue Aug 13 06:02:43 PDT 2013


Hi Mihai,

On 13 August 2013 13:40, Mihail Popa <mihail.popa at gmail.com> wrote:
>> Incidentally, adding an "MIOperandInfo = (ops i32imm:$value, i32imm:$rot)"
>> would probably make the internal representation neatest here. by giving your
>> MachineInstr two separate operands for the
>> immediate value.
>
> Not so sure how this can help with anything since the natural representation
> of an integer is ... well, one integer.

But you've got the problem that there are multiple encodings for the
integer 0 (for example). You could squash them into one MCOperand as
(say) "BaseImm | (RotAmt << 8)", but splitting them into two
MCOperands strikes me as more accurate.

> I am not sure I understand how you could have the instruction selector
> produce two operands instead of one.

That's what ComplexPatterns do, provided the extra operands are hidden
in an MIOperandInfo. For example

def so_imm : Operand<i32>, ComplexPattern<i32, 2, "SelectSOImm"> {
  let MIOperandInfo = (ops i32imm:$value, i32imm:$rot);
  [...]
}

lets you write patterns like "(set GPR:$Rd, (add GPR:$Rn,
so_imm:$imm))". The function "SelectSOImm" would get called with two
"SDValue &" operands that it's expected fill up based on its input
node if it succeeds.

> In addition there would still have to be a further lowering pass when the
> MCOperand is generated.

That's all handled automatically, if I understand you correctly. Both
the MachineInstr and the MCInst would have two immediate operands.

> Speaking of which - looking at how MachineOperands are lowered to
> MCOperands: how can I tell that a specific
> MachineOperand::MO_Immediate will actually end up being an ARMSOImm? The
> MCOperandInfo structures don't help.

I don't believe you can. Why do you think you need to?

Cheers.

Tim.



More information about the llvm-commits mailing list