diff options
author | Jim Laskey <jlaskey@mac.com> | 2006-01-05 01:25:28 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2006-01-05 01:25:28 +0000 |
commit | abf6d1784b2d4bbcb7d20ab64881f77d755059f6 (patch) | |
tree | 922ed43eb59093df7e5fa40d3b814177ed364d86 /lib/CodeGen | |
parent | d90eb7fb2435e2abedb4694edc44fa45642edbe9 (diff) |
Added initial support for DEBUG_LABEL allowing debug specific labels to be
inserted in the code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25104 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 84 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 1 |
3 files changed, 57 insertions, 31 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 1cfa305d85..30a4c9f637 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2117,8 +2117,7 @@ SDOperand DAGCombiner::visitDEBUGLOC(SDNode *N) { return DAG.getNode(ISD::DEBUG_LOC, MVT::Other, Chain.getOperand(0), N->getOperand(1), N->getOperand(2), - N->getOperand(3), - N->getOperand(4)); + N->getOperand(3)); } return SDOperand(); diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index dec782a070..3e470f25b6 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -619,20 +619,33 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { default: assert(0 && "This action is not supported yet!"); case TargetLowering::Expand: { MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo(); - if (TLI.isOperationLegal(ISD::DEBUG_LOC, MVT::Other) && DebugInfo) { - std::vector<SDOperand> Ops; - Ops.push_back(Tmp1); // chain - Ops.push_back(Node->getOperand(1)); // line # - Ops.push_back(Node->getOperand(2)); // col # - const std::string &fname = + bool useDEBUG_LOC = TLI.isOperationLegal(ISD::DEBUG_LOC, MVT::Other); + bool useDEBUG_LABEL = TLI.isOperationLegal(ISD::DEBUG_LABEL, MVT::Other); + + if (DebugInfo && (useDEBUG_LOC || useDEBUG_LABEL)) { + const std::string &FName = cast<StringSDNode>(Node->getOperand(3))->getValue(); - const std::string &dirname = + const std::string &DirName = cast<StringSDNode>(Node->getOperand(4))->getValue(); - unsigned srcfile = DebugInfo->getUniqueSourceID(fname, dirname); - Ops.push_back(DAG.getConstant(srcfile, MVT::i32)); // source file id - unsigned id = DebugInfo->getNextUniqueID(); - Ops.push_back(DAG.getConstant(id, MVT::i32)); // label id - Result = DAG.getNode(ISD::DEBUG_LOC, MVT::Other, Ops); + unsigned SrcFile = DebugInfo->getUniqueSourceID(FName, DirName); + + std::vector<SDOperand> Ops; + Ops.push_back(Tmp1); // chain + SDOperand LineOp = Node->getOperand(1); + SDOperand ColOp = Node->getOperand(2); + + if (useDEBUG_LOC) { + Ops.push_back(LineOp); // line # + Ops.push_back(ColOp); // col # + Ops.push_back(DAG.getConstant(SrcFile, MVT::i32)); // source file id + Result = DAG.getNode(ISD::DEBUG_LOC, MVT::Other, Ops); + } else { + unsigned Line = dyn_cast<ConstantSDNode>(LineOp)->getValue(); + unsigned Col = dyn_cast<ConstantSDNode>(ColOp)->getValue(); + unsigned ID = DebugInfo->RecordLabel(Line, Col, SrcFile); + Ops.push_back(DAG.getConstant(ID, MVT::i32)); + Result = DAG.getNode(ISD::DEBUG_LABEL, MVT::Other, Ops); + } } else { Result = Tmp1; // chain } @@ -661,27 +674,40 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { break; case ISD::DEBUG_LOC: - assert(Node->getNumOperands() == 5 && "Invalid DEBUG_LOC node!"); + assert(Node->getNumOperands() == 4 && "Invalid DEBUG_LOC node!"); switch (TLI.getOperationAction(ISD::DEBUG_LOC, MVT::Other)) { case TargetLowering::Promote: case TargetLowering::Expand: default: assert(0 && "This action is not supported yet!"); - case TargetLowering::Legal: { - SDOperand Tmp5; - Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. - Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the line #. - Tmp3 = LegalizeOp(Node->getOperand(2)); // Legalize the col #. - Tmp4 = LegalizeOp(Node->getOperand(3)); // Legalize the source file id. - Tmp5 = LegalizeOp(Node->getOperand(4)); // Legalize the label id. - - if (Tmp1 != Node->getOperand(0) || - Tmp2 != Node->getOperand(1) || - Tmp3 != Node->getOperand(2) || - Tmp4 != Node->getOperand(3) || - Tmp5 != Node->getOperand(4)) { - Result = - DAG.getNode(ISD::DEBUG_LOC,MVT::Other, Tmp1, Tmp2, Tmp3, Tmp4, Tmp5); - } + case TargetLowering::Legal: + Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. + Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the line #. + Tmp3 = LegalizeOp(Node->getOperand(2)); // Legalize the col #. + Tmp4 = LegalizeOp(Node->getOperand(3)); // Legalize the source file id. + + if (Tmp1 != Node->getOperand(0) || + Tmp2 != Node->getOperand(1) || + Tmp3 != Node->getOperand(2) || + Tmp4 != Node->getOperand(3)) { + Result = DAG.getNode(ISD::DEBUG_LOC,MVT::Other, Tmp1, Tmp2, Tmp3, Tmp4); + } + break; + } + break; + + case ISD::DEBUG_LABEL: + assert(Node->getNumOperands() == 2 && "Invalid DEBUG_LABEL node!"); + switch (TLI.getOperationAction(ISD::DEBUG_LABEL, MVT::Other)) { + case TargetLowering::Promote: + case TargetLowering::Expand: + default: assert(0 && "This action is not supported yet!"); + case TargetLowering::Legal: + Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. + Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the label id. + + if (Tmp1 != Node->getOperand(0) || + Tmp2 != Node->getOperand(1)) { + Result = DAG.getNode(ISD::DEBUG_LABEL, MVT::Other, Tmp1, Tmp2); } break; } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 853b48c9c8..b067c122ac 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2005,6 +2005,7 @@ const char *SDNode::getOperationName(const SelectionDAG *G) const { // Debug info case ISD::LOCATION: return "location"; case ISD::DEBUG_LOC: return "debug_loc"; + case ISD::DEBUG_LABEL: return "debug_label"; case ISD::CONDCODE: switch (cast<CondCodeSDNode>(this)->get()) { |