aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-07-22 17:43:22 +0000
committerDevang Patel <dpatel@apple.com>2009-07-22 17:43:22 +0000
commit0c0a6cad49b088d937ea0043030deda499145b30 (patch)
treec76031cf9bdfac5f7ac7f46d5360b7d8675c12c0 /lib/VMCore
parent3fb536bde6f584edf5202eb96ccdd69442882b95 (diff)
downloadexternal_llvm-0c0a6cad49b088d937ea0043030deda499145b30.zip
external_llvm-0c0a6cad49b088d937ea0043030deda499145b30.tar.gz
external_llvm-0c0a6cad49b088d937ea0043030deda499145b30.tar.bz2
Introduce MetadataBase, a base class for MDString and MDNode.
Derive MDString directly from MetadataBase. Introduce new bitcode block to hold metadata. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76759 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/AsmWriter.cpp25
-rw-r--r--lib/VMCore/Constants.cpp12
-rw-r--r--lib/VMCore/Value.cpp5
3 files changed, 21 insertions, 21 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index a091a93..17d0478 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1063,13 +1063,6 @@ static void WriteConstantInt(raw_ostream &Out, const Constant *CV,
return;
}
- if (const MDString *S = dyn_cast<MDString>(CV)) {
- Out << "!\"";
- PrintEscapedString(S->begin(), S->size(), Out);
- Out << '"';
- return;
- }
-
if (const MDNode *Node = dyn_cast<MDNode>(CV)) {
Out << "!" << Machine->getMetadataSlot(Node);
return;
@@ -1138,7 +1131,16 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
Out << '"';
return;
}
-
+
+ if (const MDString *MDS = dyn_cast<MDString>(V)) {
+ TypePrinter.print(MDS->getType(), Out);
+ Out << ' ';
+ Out << "!\"";
+ PrintEscapedString(MDS->begin(), MDS->size(), Out);
+ Out << '"';
+ return;
+ }
+
char Prefix = '%';
int Slot;
if (Machine) {
@@ -1973,6 +1975,13 @@ void Value::print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const {
SlotTracker SlotTable(GV->getParent());
AssemblyWriter W(OS, SlotTable, GV->getParent(), AAW);
W.write(GV);
+ } else if (const MDString *MDS = dyn_cast<MDString>(this)) {
+ TypePrinting TypePrinter;
+ TypePrinter.print(MDS->getType(), OS);
+ OS << ' ';
+ OS << "!\"";
+ PrintEscapedString(MDS->begin(), MDS->size(), OS);
+ OS << '"';
} else if (const MDNode *N = dyn_cast<MDNode>(this)) {
SlotTracker SlotTable(N);
TypePrinting TypePrinter;
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 2eb7339..db40592 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -1323,18 +1323,6 @@ void UndefValue::destroyConstant() {
destroyConstantImpl();
}
-//---- MDString::get() implementation
-//
-
-MDString::MDString(const char *begin, const char *end)
- : Constant(Type::MetadataTy, MDStringVal, 0, 0),
- StrBegin(begin), StrEnd(end) {}
-
-void MDString::destroyConstant() {
- getType()->getContext().erase(this);
- destroyConstantImpl();
-}
-
//---- MDNode::get() implementation
//
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp
index 07fbfc6..b3c0692 100644
--- a/lib/VMCore/Value.cpp
+++ b/lib/VMCore/Value.cpp
@@ -18,6 +18,7 @@
#include "llvm/Instructions.h"
#include "llvm/Operator.h"
#include "llvm/Module.h"
+#include "llvm/MDNode.h"
#include "llvm/ValueSymbolTable.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -140,7 +141,9 @@ static bool getSymTab(Value *V, ValueSymbolTable *&ST) {
} else if (Argument *A = dyn_cast<Argument>(V)) {
if (Function *P = A->getParent())
ST = &P->getValueSymbolTable();
- } else {
+ } else if (isa<MDString>(V))
+ return true;
+ else {
assert(isa<Constant>(V) && "Unknown value type!");
return true; // no name is setable for this.
}