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()); 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? Artjom -- View this message in context: http://www.nabble.com/Inserting-nodes-into-SelectionDAG-%28X86%29-tp24211066p24256897.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
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
On Jul 1, 2009, at 2:22 PMPDT, Dan Gohman wrote:>> 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.You might want to look at SelectionDAGNodes.h, that has some (informal) description of what operands and results the nodes have.