[LLVMdev] Implicit defs
romixlev at yahoo.com
Mon Oct 30 03:42:40 PST 2006
--- Chris Lattner <sabre at nondot.org> wrote:
> On Sat, 14 Oct 2006, Roman Levenstein wrote:
> > OK. I have not explained in my first email about DEFs everything I
> > wanted, the second one was a bit more specific ;) Of course, I
> > that I can add explicit DEFs to the machine instruction. But is it
> > possible to do it at the higher level, e.g. in the ISelLowering
> > where no machine insns are generated yet. Basically, it is
> > possible at this level to do the mapping of virtual registers for
> > parameters to the physical registers, and this can be done without
> > problems. It is usually done in LowerCALL or something like that.
> > like to do the same for return registers at the same place, to keep
> > these related things together and because of certain symmetry of
> > But if I would do it as you propose, I'll need to put somewhere
> > where we can operate at the MI level, right? So the question is
> > actually about possibility of doing it in LowerCALL, where MIs are
> > generated yet.
> This is certainly possible, but requires some C++ code. I assume you
> something like the PPC backend right now. If so, you have this in
> lowering code:
> // Add argument registers to the end of the list so that they are
> known live
> // into the call.
> for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
> if (InFlag.Val)
> Chain = DAG.getNode(CallOpc, NodeTys, &Ops, Ops.size());
> This creates a call node with a list of input registers, these are
> as uses. In the PPC backend, this is matched with this pattern:
> def BLA : IForm<18, 1, 1, (ops aaddr:$func, variable_ops),
> "bla $func", BrB, [(PPCcall (i32
> The "variable_ops" part of the operation list causes all those
> to be added to the node when the isel turns the isel graph into the
> graph. Unfortunately, this will not work with extra definitions
> clobbered regs in your case).
> Perhaps the easiest way to handle this whole thing is to add an
> integer operand to the DAG call node that indicates the calling
> convention used.
> You can then use a 'usesCustomDAGSchedInserter' inserter to create
> the machine instr any way you like based on this information.
> See the PPC backend and how it inserts SELECT_CC_I4, for example.
> In your case, you would result in one machine instr (instead of the
> many SELECT_CC_I4 produces).
Thanks for the hint. I did it as you describe. Well, almost. Instead of
using the calling convention as an additional argument, I directly put
the list of DEF regs into the list of operands.
Taking the code above as an example, I do something like:
// Put a list registers implicitly DEFined by this instruction
// Put a delimiter indicating the end of the list
// Here comes the usual ops.push_back(DAG.getRegister(...)) for USEed
And then when processing the usesCustomDAGSchedInserter-marked CALL
insn, I basically create a CALL instruction by iterating over this list
and adding all of the regs from the DEF list as isDef operands of the
machine instruction. This works without any problems and enforces the
required register constraints.
Having done that, I'll concentrate now on the mapping of 64bit FP regs
2x32bit integer regs and register allocation of them.
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates
More information about the llvm-dev