From dd8fbf572ee98ef793b691dda2dc89eaf38cba2f Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 13 Jan 2012 03:38:34 +0000 Subject: Delete CodeInit and CodeRecTy from TableGen. The code type was always identical to a string anyway. Now it is simply a synonym. The code literal syntax [{...}] is still valid. llvm-svn: 148092 --- llvm/lib/TableGen/Record.cpp | 30 ------------------------------ llvm/lib/TableGen/TGParser.cpp | 6 +++--- 2 files changed, 3 insertions(+), 33 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index d328d893fd0..25ff0629072 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -78,7 +78,6 @@ template<> struct DenseMapInfo { BitRecTy BitRecTy::Shared; IntRecTy IntRecTy::Shared; StringRecTy StringRecTy::Shared; -CodeRecTy CodeRecTy::Shared; DagRecTy DagRecTy::Shared; void RecTy::anchor() { } @@ -316,12 +315,6 @@ Init *ListRecTy::convertValue(TypedInit *TI) { return 0; } -Init *CodeRecTy::convertValue(TypedInit *TI) { - if (TI->getType()->typeIsConvertibleTo(this)) - return TI; - return 0; -} - Init *DagRecTy::convertValue(TypedInit *TI) { if (TI->getType()->typeIsConvertibleTo(this)) return TI; @@ -582,17 +575,6 @@ StringInit *StringInit::get(StringRef V) { return I; } -void CodeInit::anchor() { } - -CodeInit *CodeInit::get(StringRef V) { - typedef StringMap Pool; - static Pool ThePool; - - CodeInit *&I = ThePool[V]; - if (!I) I = new CodeInit(V); - return I; -} - static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef Range, RecTy *EltTy) { @@ -1993,18 +1975,6 @@ DagInit *Record::getValueAsDag(StringRef FieldName) const { "' does not have a dag initializer!"; } -std::string Record::getValueAsCode(StringRef FieldName) const { - const RecordVal *R = getValue(FieldName); - if (R == 0 || R->getValue() == 0) - throw "Record `" + getName() + "' does not have a field named `" + - FieldName.str() + "'!\n"; - - if (CodeInit *CI = dynamic_cast(R->getValue())) - return CI->getValue(); - throw "Record `" + getName() + "', field `" + FieldName.str() + - "' does not have a code initializer!"; -} - void MultiClass::dump() const { errs() << "Record:\n"; diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 5c13af18c6f..81c68292f1b 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -595,11 +595,11 @@ bool TGParser::ParseOptionalBitList(std::vector &Ranges) { /// ParseType - Parse and return a tblgen type. This returns null on error. /// /// Type ::= STRING // string type +/// Type ::= CODE // code type /// Type ::= BIT // bit type /// Type ::= BITS '<' INTVAL '>' // bits type /// Type ::= INT // int type /// Type ::= LIST '<' Type '>' // list type -/// Type ::= CODE // code type /// Type ::= DAG // dag type /// Type ::= ClassID // Record Type /// @@ -607,9 +607,9 @@ RecTy *TGParser::ParseType() { switch (Lex.getCode()) { default: TokError("Unknown token when expecting a type"); return 0; case tgtok::String: Lex.Lex(); return StringRecTy::get(); + case tgtok::Code: Lex.Lex(); return StringRecTy::get(); case tgtok::Bit: Lex.Lex(); return BitRecTy::get(); case tgtok::Int: Lex.Lex(); return IntRecTy::get(); - case tgtok::Code: Lex.Lex(); return CodeRecTy::get(); case tgtok::Dag: Lex.Lex(); return DagRecTy::get(); case tgtok::Id: if (Record *R = ParseClassID()) return RecordRecTy::get(R); @@ -1104,7 +1104,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, break; } case tgtok::CodeFragment: - R = CodeInit::get(Lex.getCurStrVal()); + R = StringInit::get(Lex.getCurStrVal()); Lex.Lex(); break; case tgtok::question: -- cgit v1.2.3