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 | 011dca7fac07100695dd3685bfaddbea58a468b9 (patch) | |
tree | 558d6a261450aa411c0acfd30422041fa5ce931d /utils/TableGen/Record.cpp | |
parent | d5705fe50d58dd2b686b26d1683315f785246ce0 (diff) | |
download | llvm-011dca7fac07100695dd3685bfaddbea58a468b9.tar.gz llvm-011dca7fac07100695dd3685bfaddbea58a468b9.tar.bz2 llvm-011dca7fac07100695dd3685bfaddbea58a468b9.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r-- | utils/TableGen/Record.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index aabe0254ec..8c47888dbe 100644 --- a/utils/TableGen/Record.cpp +++ b/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 { |