Hi,
I've been thinking about how to make MachineInstrBuilder scale as pleasantly as possible, and come up with this idea. Basically, instead of
MIRBuilder.buildInstr(Opcode, Ty, Res, Op0, Op1);
you'd have to write
MIRBuilder.buildInstr(Opcode, Ty, MIB::Def(Res), MIB::Use(Op0), MIB::Use(Op1));
(and similar). This has a few advantages:
- Removes the implicit specialness of the first register (inherited from BuildMI, where it's caught out at least two people I know of, including me).
- Allows other kinds of operands that we'll want to be handled uniformly (FrameIndex, MBB, Imm, ...).
On the other hand, there are disadvantages:
- The usual opaque template error messages when you get it wrong.
- More verbose in the common case of single-def, multiple-uses, register only (instructions like this will be less common for target opcodes than generic ones though).
- Feels like a minor riff on the old MachineInstrBuilder interface. Perhaps what we'd have used then if we had variadic templates, or perhaps there's a good reason we didn't?
Anyone got any feelings? On the whole I think it has potential.