diff options
author | David Greene <greened@obbligato.org> | 2011-10-19 13:02:33 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-10-19 13:02:33 +0000 |
commit | ee6dca17252de152720655282fb4b74b76fb2fe9 (patch) | |
tree | 7a639e67344437423817df6f855ccaaa157f69e8 /lib/TableGen/Record.cpp | |
parent | 96a9f78c4aa1bc188f3f7ee869bed44cb7a6ff0e (diff) | |
download | llvm-ee6dca17252de152720655282fb4b74b76fb2fe9.tar.gz llvm-ee6dca17252de152720655282fb4b74b76fb2fe9.tar.bz2 llvm-ee6dca17252de152720655282fb4b74b76fb2fe9.tar.xz |
Make VarInit Name an Init
Make the VarInit name an Init itself. We need this to implement paste
functionality so we can reference variables whose names are not yet
completely resolved.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen/Record.cpp')
-rw-r--r-- | lib/TableGen/Record.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 06a41c9eb2..64975e4656 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -1298,7 +1298,12 @@ TypedInit::convertInitListSlice(const std::vector<unsigned> &Elements) const { VarInit *VarInit::get(const std::string &VN, RecTy *T) { - typedef std::pair<RecTy *, TableGenStringKey> Key; + Init *Value = StringInit::get(VN); + return VarInit::get(Value, T); +} + +VarInit *VarInit::get(Init *VN, RecTy *T) { + typedef std::pair<RecTy *, Init *> Key; typedef DenseMap<Key, VarInit *> Pool; static Pool ThePool; @@ -1309,6 +1314,13 @@ VarInit *VarInit::get(const std::string &VN, RecTy *T) { return I; } +const std::string &VarInit::getName() const { + StringInit *NameString = + dynamic_cast<StringInit *>(getNameInit()); + assert(NameString && "VarInit name is not a string!"); + return NameString->getValue(); +} + Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, unsigned Bit) const { if (R.isTemplateArg(getName())) return 0; |