[llvm-commits] [llvm] r139031 - in /llvm/trunk/utils/TableGen: Record.cpp Record.h
David Greene
greened at obbligato.org
Fri Sep 2 13:12:07 PDT 2011
Author: greened
Date: Fri Sep 2 15:12:07 2011
New Revision: 139031
URL: http://llvm.org/viewvc/llvm-project?rev=139031&view=rev
Log:
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.
Modified:
llvm/trunk/utils/TableGen/Record.cpp
llvm/trunk/utils/TableGen/Record.h
Modified: llvm/trunk/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=139031&r1=139030&r2=139031&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Fri Sep 2 15:12:07 2011
@@ -1619,12 +1619,24 @@
// 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 {
Modified: llvm/trunk/utils/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=139031&r1=139030&r2=139031&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.h (original)
+++ llvm/trunk/utils/TableGen/Record.h Fri Sep 2 15:12:07 2011
@@ -1337,14 +1337,15 @@
//===----------------------------------------------------------------------===//
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; }
More information about the llvm-commits
mailing list