From 70feca409e3a79c3d9295cbc81c257de6be8ef3e Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Thu, 25 Mar 2010 18:52:01 +0000 Subject: Teach TableGen to understand X.Y notation in the TSFlagsFields strings. Remove much horribleness from X86InstrFormats as a result. Similar simplifications are probably possible for other targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99539 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/InstrInfoEmitter.cpp | 2 +- utils/TableGen/Record.cpp | 10 ++++++++++ utils/TableGen/Record.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 8f7550b848..9bc545928d 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -337,7 +337,7 @@ void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val, IntInit *ShiftInt, raw_ostream &OS) { if (Val == 0 || ShiftInt == 0) throw std::string("Illegal value or shift amount in TargetInfo*!"); - RecordVal *RV = R->getValue(Val->getValue()); + RecordVal *RV = R->getDottedValue(Val->getValue()); int Shift = ShiftInt->getValue(); if (RV == 0 || RV->getValue() == 0) { diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 0e3593b6a1..55c998926c 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -1307,6 +1307,16 @@ void Record::resolveReferencesTo(const RecordVal *RV) { } } +RecordVal *Record::getDottedValue(StringRef Name) { + size_t pos = Name.find('.'); + if (pos == StringRef::npos) + return getValue(Name); + RecordVal *RV = getValue(Name.substr(0, pos)); + if (!RV) return 0; + DefInit *DI = dynamic_cast(RV->getValue()); + if (!DI) return 0; + return DI->getDef()->getDottedValue(Name.substr(pos+1)); +} void Record::dump() const { errs() << *this; } diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index 55c1a80f9b..41373c799a 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -1262,6 +1262,9 @@ public: return 0; } + // Like getValue, but allow dotting into members: X.Y + RecordVal *getDottedValue(StringRef Name); + void addTemplateArg(StringRef Name) { assert(!isTemplateArg(Name) && "Template arg already defined!"); TemplateArgs.push_back(Name); -- cgit v1.2.3