diff options
| author | David Greene <greened@obbligato.org> | 2011-09-02 20:12:07 +0000 |
|---|---|---|
| committer | David Greene <greened@obbligato.org> | 2011-09-02 20:12:07 +0000 |
| commit | 09d153eb12e907572772a0533ccc7bf3aebef1bf (patch) | |
| tree | a1f2525eaeffd4a088502909af274b46f23cdbf7 | |
| parent | b74711df529a4510abed7dddbdd53d71741ccad7 (diff) | |
| download | bcm5719-llvm-09d153eb12e907572772a0533ccc7bf3aebef1bf.tar.gz bcm5719-llvm-09d153eb12e907572772a0533ccc7bf3aebef1bf.zip | |
Make RecordVal Name an Init
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.
llvm-svn: 139031
| -rw-r--r-- | llvm/utils/TableGen/Record.cpp | 14 | ||||
| -rw-r--r-- | llvm/utils/TableGen/Record.h | 5 |
2 files changed, 16 insertions, 3 deletions
diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp index aabe0254ecf..8c47888dbed 100644 --- a/llvm/utils/TableGen/Record.cpp +++ b/llvm/utils/TableGen/Record.cpp @@ -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 { diff --git a/llvm/utils/TableGen/Record.h b/llvm/utils/TableGen/Record.h index 8e975306378..84313e66d58 100644 --- a/llvm/utils/TableGen/Record.h +++ b/llvm/utils/TableGen/Record.h @@ -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; } |

