Further progration of metadata operands. The
authorDale Johannesen <dalej@apple.com>
Wed, 13 Jan 2010 00:00:24 +0000 (00:00 +0000)
committerDale Johannesen <dalej@apple.com>
Wed, 13 Jan 2010 00:00:24 +0000 (00:00 +0000)
dumper doesn't really do what I want yet, but
at least it doesn't crash now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93272 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstrBuilder.h
include/llvm/CodeGen/MachineOperand.h
lib/CodeGen/MachineInstr.cpp
lib/VMCore/AsmWriter.cpp

index 6ca63f01109eef2f7b467e344d90a1e6f402cf92..8eb0add019203f72466357fb9cda41b9c5308f9a 100644 (file)
@@ -22,6 +22,7 @@
 namespace llvm {
 
 class TargetInstrDesc;
+class MDNode;
 
 namespace RegState {
   enum {
@@ -123,6 +124,11 @@ public:
     MI->addOperand(MO);
     return *this;
   }
+
+  const MachineInstrBuilder &addMetadata(MDNode *MD) const {
+    MI->addOperand(MachineOperand::CreateMetadata(MD));
+    return *this;
+  }
 };
 
 /// BuildMI - Builder interface.  Specify how to create the initial instruction
index 452c384b6a5e7805c729e8b9600f03317ed9ef89..907c25af7d474848d8b17fa8c51ad74612aa05f2 100644 (file)
@@ -317,7 +317,7 @@ public:
     return Contents.OffsetedInfo.Val.SymbolName;
   }
 
-  MDNode *getMetadata() const {
+  const MDNode *getMetadata() const {
     assert(isMetadata() && "Wrong MachineOperand accessor");
     return Contents.MD;
   }
index f9c20e647307ab7f192be3e1502534292ce44c82..cf3e3e16014aed2a92798617516fc41dd26c87ae 100644 (file)
@@ -34,6 +34,7 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/FoldingSet.h"
+#include "llvm/Metadata.h"
 using namespace llvm;
 
 //===----------------------------------------------------------------------===//
@@ -278,10 +279,15 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
     OS << '>';
     break;
   case MachineOperand::MO_BlockAddress:
-    OS << "<";
+    OS << '<';
     WriteAsOperand(OS, getBlockAddress(), /*PrintType=*/false);
     OS << '>';
     break;
+  case MachineOperand::MO_Metadata:
+    OS << '<';
+    WriteAsOperand(OS, getMetadata(), /*PrintType=*/false);
+    OS << '>';
+    break;
   default:
     llvm_unreachable("Unrecognized operand type");
   }
index 7cb5a7c7598818df8f6d3bd864e0d26578deeb16..92dbd93d353c766c4ea1f1814425b79f1e89d189 100644 (file)
@@ -564,6 +564,9 @@ static SlotTracker *createSlotTracker(const Value *V) {
   if (const Function *Func = dyn_cast<Function>(V))
     return new SlotTracker(Func);
 
+  if (isa<MDNode>(V))
+    return new SlotTracker((Function *)0);
+
   return 0;
 }
 
@@ -1136,6 +1139,8 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
       return;
     }
   
+    if (!Machine)
+      Machine = createSlotTracker(V);
     Out << '!' << Machine->getMetadataSlot(N);
     return;
   }