Make RecordVal Name an Init
authorDavid Greene <greened@obbligato.org>
Fri, 2 Sep 2011 20:12:07 +0000 (20:12 +0000)
committerDavid Greene <greened@obbligato.org>
Fri, 2 Sep 2011 20:12:07 +0000 (20:12 +0000)
Store a RecordVal's name as an Init to allow class-qualified Record
members to reference Records that have Init names.  We'll use this to
provide more programmability in how we name defs and their associated
members.

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

utils/TableGen/Record.cpp
utils/TableGen/Record.h

index aabe0254ecf1682deb4705da5bb54a3f1d8ea028..8c47888dbed48f7a626dbd8d2120f36d2aef89c3 100644 (file)
@@ -1619,12 +1619,24 @@ std::string DagInit::getAsString() const {
 //    Other implementations
 //===----------------------------------------------------------------------===//
 
-RecordVal::RecordVal(const std::string &N, RecTy *T, unsigned P)
+RecordVal::RecordVal(Init *N, RecTy *T, unsigned P)
   : Name(N), Ty(T), Prefix(P) {
   Value = Ty->convertValue(UnsetInit::get());
   assert(Value && "Cannot create unset value for current type!");
 }
 
+RecordVal::RecordVal(const std::string &N, RecTy *T, unsigned P)
+  : Name(StringInit::get(N)), Ty(T), Prefix(P) {
+  Value = Ty->convertValue(UnsetInit::get());
+  assert(Value && "Cannot create unset value for current type!");
+}
+
+const std::string &RecordVal::getName() const {
+  StringInit *NameString = dynamic_cast<StringInit *>(Name);
+  assert(NameString && "RecordVal name is not a string!");
+  return NameString->getValue();
+}
+
 void RecordVal::dump() const { errs() << *this; }
 
 void RecordVal::print(raw_ostream &OS, bool PrintSem) const {
index 8e975306378caaba73308be62abbb269df2cba3e..84313e66d58fea92e50f25995ee459c2954f307e 100644 (file)
@@ -1337,14 +1337,15 @@ public:
 //===----------------------------------------------------------------------===//
 
 class RecordVal {
-  std::string Name;
+  Init *Name;
   RecTy *Ty;
   unsigned Prefix;
   Init *Value;
 public:
+  RecordVal(Init *N, RecTy *T, unsigned P);
   RecordVal(const std::string &N, RecTy *T, unsigned P);
 
-  const std::string &getName() const { return Name; }
+  const std::string &getName() const;
 
   unsigned getPrefix() const { return Prefix; }
   RecTy *getType() const { return Ty; }