[llvm-commits] [llvm] r142497 - in /llvm/trunk: include/llvm/TableGen/Record.h lib/TableGen/Record.cpp
David Greene
greened at obbligato.org
Wed Oct 19 06:02:33 PDT 2011
Author: greened
Date: Wed Oct 19 08:02:33 2011
New Revision: 142497
URL: http://llvm.org/viewvc/llvm-project?rev=142497&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/TableGen/Record.h
llvm/trunk/lib/TableGen/Record.cpp
Modified: llvm/trunk/include/llvm/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=142497&r1=142496&r2=142497&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Record.h (original)
+++ llvm/trunk/include/llvm/TableGen/Record.h Wed Oct 19 08:02:33 2011
@@ -1058,9 +1058,11 @@
/// VarInit - 'Opcode' - Represent a reference to an entire variable object.
///
class VarInit : public TypedInit {
- std::string VarName;
+ Init *VarName;
explicit VarInit(const std::string &VN, RecTy *T)
+ : TypedInit(T), VarName(StringInit::get(VN)) {}
+ explicit VarInit(Init *VN, RecTy *T)
: TypedInit(T), VarName(VN) {}
VarInit(const VarInit &Other); // Do not define.
@@ -1074,7 +1076,11 @@
return Ty->convertValue(const_cast<VarInit *>(this));
}
- const std::string &getName() const { return VarName; }
+ const std::string &getName() const;
+ Init *getNameInit() const { return VarName; }
+ std::string getNameInitAsString() const {
+ return getNameInit()->getAsUnquotedString();
+ }
virtual Init *resolveBitReference(Record &R, const RecordVal *RV,
unsigned Bit) const;
@@ -1092,7 +1098,7 @@
///
virtual Init *resolveReferences(Record &R, const RecordVal *RV) const;
- virtual std::string getAsString() const { return VarName; }
+ virtual std::string getAsString() const { return getName(); }
};
Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=142497&r1=142496&r2=142497&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Wed Oct 19 08:02:33 2011
@@ -1298,7 +1298,12 @@
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 @@
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;
More information about the llvm-commits
mailing list