- // Emit boilerplate.
- OS << "SDNode *Select_INLINEASM(SDOperand N) {\n"
- << " std::vector<SDOperand> Ops(N.Val->op_begin(), N.Val->op_end());\n"
- << " SelectInlineAsmMemoryOperands(Ops, *CurDAG);\n\n"
-
- << " // Ensure that the asm operands are themselves selected.\n"
- << " for (unsigned j = 0, e = Ops.size(); j != e; ++j)\n"
- << " AddToISelQueue(Ops[j]);\n\n"
-
- << " std::vector<MVT::ValueType> VTs;\n"
- << " VTs.push_back(MVT::Other);\n"
- << " VTs.push_back(MVT::Flag);\n"
- << " SDOperand New = CurDAG->getNode(ISD::INLINEASM, VTs, &Ops[0], "
- "Ops.size());\n"
- << " return New.Val;\n"
- << "}\n\n";
-
- OS << "SDNode *Select_LABEL(const SDOperand &N) {\n"
- << " SDOperand Chain = N.getOperand(0);\n"
- << " SDOperand N1 = N.getOperand(1);\n"
- << " SDOperand N2 = N.getOperand(2);\n"
- << " unsigned C1 = cast<ConstantSDNode>(N1)->getValue();\n"
- << " unsigned C2 = cast<ConstantSDNode>(N2)->getValue();\n"
- << " SDOperand Tmp1 = CurDAG->getTargetConstant(C1, MVT::i32);\n"
- << " SDOperand Tmp2 = CurDAG->getTargetConstant(C2, MVT::i32);\n"
- << " AddToISelQueue(Chain);\n"
- << " SDOperand Ops[] = { Tmp1, Tmp2, Chain };\n"
- << " return CurDAG->getTargetNode(TargetInstrInfo::LABEL,\n"
- << " MVT::Other, Ops, 3);\n"
- << "}\n\n";
-
- OS << "SDNode *Select_DECLARE(const SDOperand &N) {\n"
- << " SDOperand Chain = N.getOperand(0);\n"
- << " SDOperand N1 = N.getOperand(1);\n"
- << " SDOperand N2 = N.getOperand(2);\n"
- << " if (!isa<FrameIndexSDNode>(N1) || !isa<GlobalAddressSDNode>(N2)) {\n"
- << " cerr << \"Cannot yet select llvm.dbg.declare: \";\n"
- << " N.Val->dump(CurDAG);\n"
- << " abort();\n"
- << " }\n"
- << " int FI = cast<FrameIndexSDNode>(N1)->getIndex();\n"
- << " GlobalValue *GV = cast<GlobalAddressSDNode>(N2)->getGlobal();\n"
- << " SDOperand Tmp1 = "
- << "CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());\n"
- << " SDOperand Tmp2 = "
- << "CurDAG->getTargetGlobalAddress(GV, TLI.getPointerTy());\n"
- << " AddToISelQueue(Chain);\n"
- << " SDOperand Ops[] = { Tmp1, Tmp2, Chain };\n"
- << " return CurDAG->getTargetNode(TargetInstrInfo::DECLARE,\n"
- << " MVT::Other, Ops, 3);\n"
- << "}\n\n";
-
- OS << "SDNode *Select_EXTRACT_SUBREG(const SDOperand &N) {\n"
- << " SDOperand N0 = N.getOperand(0);\n"
- << " SDOperand N1 = N.getOperand(1);\n"
- << " unsigned C = cast<ConstantSDNode>(N1)->getValue();\n"
- << " SDOperand Tmp = CurDAG->getTargetConstant(C, MVT::i32);\n"
- << " AddToISelQueue(N0);\n"
- << " SDOperand Ops[] = { N0, Tmp };\n"
- << " return CurDAG->getTargetNode(TargetInstrInfo::EXTRACT_SUBREG,\n"
- << " N.getValueType(), Ops, 2);\n"
- << "}\n\n";
-
- OS << "SDNode *Select_INSERT_SUBREG(const SDOperand &N) {\n"
- << " SDOperand N0 = N.getOperand(0);\n"
- << " SDOperand N1 = N.getOperand(1);\n"
- << " SDOperand N2 = N.getOperand(2);\n"
- << " unsigned C = cast<ConstantSDNode>(N2)->getValue();\n"
- << " SDOperand Tmp = CurDAG->getTargetConstant(C, MVT::i32);\n"
- << " AddToISelQueue(N1);\n"
- << " SDOperand Ops[] = { N0, N1, Tmp };\n"
- << " if (N0.getOpcode() == ISD::UNDEF) {\n"
- << " return CurDAG->getTargetNode(TargetInstrInfo::INSERT_SUBREG,\n"
- << " N.getValueType(), Ops+1, 2);\n"
- << " } else {\n"
- << " AddToISelQueue(N0);\n"
- << " return CurDAG->getTargetNode(TargetInstrInfo::INSERT_SUBREG,\n"
- << " N.getValueType(), Ops, 3);\n"
- << " }\n"
- << "}\n\n";
-