[LLVMdev] Inserting nodes into SelectionDAG (X86)
Dan Gohman
gohman at apple.com
Wed Jul 1 14:22:42 PDT 2009
On Jun 29, 2009, at 9:00 AM, Artjom Kochtchi wrote:
>
> Sorry to ask again, but I still can't get it right.
>
> The following code compiles and runs, but produces no instructions:
> Ops.push_back(DAG.getRegister(X86::EAX, MVT::i32));
> Ops.push_back(DAG.getConstant(1, MVT::i32));
> DAG.getNode(ISD::ADD, DAG.getVTList(MVT::i32), &Ops[0], Ops.size());
To read the value of a physical register, a CopyFromReg node is
needed.
>
> I reckon that has something to do with the fact that I am not using
> the
> Chain object. But as soon as I try to chain that node, llc tells me
> that I
> have the wrong number of operands:
> Ops.push_back(Chain);
> Ops.push_back(DAG.getRegister(X86::EAX, MVT::i32));
> Ops.push_back(DAG.getConstant(1, MVT::i32));
> Chain = DAG.getNode(ISD::ADD, DAG.getVTList(MVT::Other, MVT::i32),
> &Ops[0], Ops.size());
>
> Isn't that the way how it is supposed to work?
ADD does not use a chain, so there's no chain operand, or
MVT::Other result for it in an ADD node.
Dan
More information about the llvm-dev
mailing list