Make LABEL a builtin opcode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33537 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index 12a824c..e293580 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -1029,6 +1029,16 @@
   O << "\n\t" << TAI->getInlineAsmEnd() << "\n";
 }
 
+/// printLabel - This method prints a local label used by debug and
+/// exception handling tables.
+void AsmPrinter::printLabel(const MachineInstr *MI) const {
+  if (AsmVerbose) O << "\n";
+  O << TAI->getPrivateGlobalPrefix()
+    << "debug_loc"
+    << MI->getOperand(0).getImmedValue()
+    << ":\n";
+}
+
 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
 /// instruction, using the specified assembler variant.  Targets should
 /// overried this to format as appropriate.
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp
index 69c6f4e..efc382b 100644
--- a/lib/CodeGen/BranchFolding.cpp
+++ b/lib/CodeGen/BranchFolding.cpp
@@ -74,16 +74,12 @@
   while (!MBB->succ_empty())
     MBB->removeSuccessor(MBB->succ_end()-1);
   
-  // If there is DWARF info to active, check to see if there are any DWARF_LABEL
+  // If there is DWARF info to active, check to see if there are any LABEL
   // records in the basic block.  If so, unregister them from MachineDebugInfo.
   if (MDI && !MBB->empty()) {
-    unsigned DWARF_LABELOpc = TII->getDWARF_LABELOpcode();
-    assert(DWARF_LABELOpc &&
-           "Target supports dwarf but didn't implement getDWARF_LABELOpcode!");
-    
     for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
          I != E; ++I) {
-      if ((unsigned)I->getOpcode() == DWARF_LABELOpc) {
+      if ((unsigned)I->getOpcode() == TargetInstrInfo::LABEL) {
         // The label ID # is always operand #0, an immediate.
         MDI->InvalidateLabel(I->getOperand(0).getImm());
       }
diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp
index 2ad1ba0..45e7fa2 100644
--- a/lib/CodeGen/MachineDebugInfo.cpp
+++ b/lib/CodeGen/MachineDebugInfo.cpp
@@ -1649,9 +1649,6 @@
   // Get target instruction info.
   const TargetInstrInfo *TII = MF.getTarget().getInstrInfo();
   if (!TII) return false;
-  // Get target version of the debug label opcode.
-  unsigned DWARF_LABELOpc = TII->getDWARF_LABELOpcode();
-  if (!DWARF_LABELOpc) return false;
   
   // Track if change is made.
   bool MadeChange = false;
@@ -1664,7 +1661,7 @@
     // Iterate through instructions.
     for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
       // Is it a debug label.
-      if ((unsigned)I->getOpcode() == DWARF_LABELOpc) {
+      if ((unsigned)I->getOpcode() == TargetInstrInfo::LABEL) {
         // The label ID # is always operand #0, an immediate.
         unsigned NextLabel = I->getOperand(0).getImm();
         
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index c8804e9..3a8fe7a 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -737,9 +737,9 @@
     case TargetLowering::Expand: {
       MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
       bool useDEBUG_LOC = TLI.isOperationLegal(ISD::DEBUG_LOC, MVT::Other);
-      bool useDEBUG_LABEL = TLI.isOperationLegal(ISD::DEBUG_LABEL, MVT::Other);
+      bool useLABEL = TLI.isOperationLegal(ISD::LABEL, MVT::Other);
       
-      if (DebugInfo && (useDEBUG_LOC || useDEBUG_LABEL)) {
+      if (DebugInfo && (useDEBUG_LOC || useLABEL)) {
         const std::string &FName =
           cast<StringSDNode>(Node->getOperand(3))->getValue();
         const std::string &DirName = 
@@ -761,7 +761,7 @@
           unsigned Col = 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[0],Ops.size());
+          Result = DAG.getNode(ISD::LABEL, MVT::Other,&Ops[0],Ops.size());
         }
       } else {
         Result = Tmp1;  // chain
@@ -803,9 +803,9 @@
     }
     break;    
 
-  case ISD::DEBUG_LABEL:
-    assert(Node->getNumOperands() == 2 && "Invalid DEBUG_LABEL node!");
-    switch (TLI.getOperationAction(ISD::DEBUG_LABEL, MVT::Other)) {
+  case ISD::LABEL:
+    assert(Node->getNumOperands() == 2 && "Invalid LABEL node!");
+    switch (TLI.getOperationAction(ISD::LABEL, MVT::Other)) {
     default: assert(0 && "This action is not supported yet!");
     case TargetLowering::Legal:
       Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index eeea70d..33227ad 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -452,6 +452,7 @@
       assert(0 && "This target-independent node should have been selected!");
     case ISD::EntryToken: // fall thru
     case ISD::TokenFactor:
+    case ISD::LABEL:
       break;
     case ISD::CopyToReg: {
       unsigned InReg;
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 5f92df3..97fb8c5 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2691,6 +2691,7 @@
   case ISD::UNDEF:         return "undef";
   case ISD::MERGE_VALUES:  return "mergevalues";
   case ISD::INLINEASM:     return "inlineasm";
+  case ISD::LABEL:         return "label";
   case ISD::HANDLENODE:    return "handlenode";
   case ISD::FORMAL_ARGUMENTS: return "formal_arguments";
   case ISD::CALL:          return "call";
@@ -2811,7 +2812,6 @@
   // 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()) {
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index bf16327..748dae8 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1980,7 +1980,7 @@
     DbgRegionStartInst &RSI = cast<DbgRegionStartInst>(I);
     if (DebugInfo && RSI.getContext() && DebugInfo->Verify(RSI.getContext())) {
       unsigned LabelID = DebugInfo->RecordRegionStart(RSI.getContext());
-      DAG.setRoot(DAG.getNode(ISD::DEBUG_LABEL, MVT::Other, getRoot(),
+      DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
                               DAG.getConstant(LabelID, MVT::i32)));
     }
 
@@ -1991,7 +1991,7 @@
     DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I);
     if (DebugInfo && REI.getContext() && DebugInfo->Verify(REI.getContext())) {
       unsigned LabelID = DebugInfo->RecordRegionEnd(REI.getContext());
-      DAG.setRoot(DAG.getNode(ISD::DEBUG_LABEL, MVT::Other,
+      DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other,
                               getRoot(), DAG.getConstant(LabelID, MVT::i32)));
     }
 
@@ -2003,7 +2003,7 @@
     if (DebugInfo && FSI.getSubprogram() &&
         DebugInfo->Verify(FSI.getSubprogram())) {
       unsigned LabelID = DebugInfo->RecordRegionStart(FSI.getSubprogram());
-      DAG.setRoot(DAG.getNode(ISD::DEBUG_LABEL, MVT::Other,
+      DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other,
                   getRoot(), DAG.getConstant(LabelID, MVT::i32)));
     }