diff options
author | Chris Lattner <sabre@nondot.org> | 2010-10-06 00:19:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-10-06 00:19:21 +0000 |
commit | c7252ce74324e44efa7ec2506035a8e2d2e93d2f (patch) | |
tree | f1e875d854c9cb7863cfa3d3269b9f3665129d9e /utils | |
parent | 78caacc2266e504eca315844203b3f727c27fbd0 (diff) |
remove the !nameconcat tblgen feature. It "shorthand" and only used in 4 places
where !cast is just as short.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/Record.cpp | 88 | ||||
-rw-r--r-- | utils/TableGen/Record.h | 2 | ||||
-rw-r--r-- | utils/TableGen/TGLexer.cpp | 1 | ||||
-rw-r--r-- | utils/TableGen/TGLexer.h | 2 | ||||
-rw-r--r-- | utils/TableGen/TGParser.cpp | 44 |
5 files changed, 17 insertions, 120 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index dc793586fbe..3d4e1387601 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -152,16 +152,6 @@ Init *StringRecTy::convertValue(BinOpInit *BO) { return new BinOpInit(BinOpInit::STRCONCAT, L, R, new StringRecTy); return BO; } - if (BO->getOpcode() == BinOpInit::NAMECONCAT) { - if (BO->getType()->getAsString() == getAsString()) { - Init *L = BO->getLHS()->convertInitializerTo(this); - Init *R = BO->getRHS()->convertInitializerTo(this); - if (L == 0 || R == 0) return 0; - if (L != BO->getLHS() || R != BO->getRHS()) - return new BinOpInit(BinOpInit::NAMECONCAT, L, R, new StringRecTy); - return BO; - } - } return convertValue((TypedInit*)BO); } @@ -236,16 +226,6 @@ Init *DagRecTy::convertValue(BinOpInit *BO) { return new BinOpInit(BinOpInit::CONCAT, L, R, new DagRecTy); return BO; } - if (BO->getOpcode() == BinOpInit::NAMECONCAT) { - if (BO->getType()->getAsString() == getAsString()) { - Init *L = BO->getLHS()->convertInitializerTo(this); - Init *R = BO->getRHS()->convertInitializerTo(this); - if (L == 0 || R == 0) return 0; - if (L != BO->getLHS() || R != BO->getRHS()) - return new BinOpInit(BinOpInit::CONCAT, L, R, new DagRecTy); - return BO; - } - } return 0; } @@ -518,9 +498,8 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { // From TGParser::ParseIDValue if (CurRec) { if (const RecordVal *RV = CurRec->getValue(Name)) { - if (RV->getType() != getType()) { - throw "type mismatch in nameconcat"; - } + if (RV->getType() != getType()) + throw "type mismatch in cast"; return new VarInit(Name, RV->getType()); } @@ -529,9 +508,8 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { const RecordVal *RV = CurRec->getValue(TemplateArgName); assert(RV && "Template arg doesn't exist??"); - if (RV->getType() != getType()) { - throw "type mismatch in nameconcat"; - } + if (RV->getType() != getType()) + throw "type mismatch in cast"; return new VarInit(TemplateArgName, RV->getType()); } @@ -543,9 +521,8 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { const RecordVal *RV = CurMultiClass->Rec.getValue(MCName); assert(RV && "Template arg doesn't exist??"); - if (RV->getType() != getType()) { - throw "type mismatch in nameconcat"; - } + if (RV->getType() != getType()) + throw "type mismatch in cast"; return new VarInit(MCName, RV->getType()); } @@ -660,57 +637,6 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { return new StringInit(LHSs->getValue() + RHSs->getValue()); break; } - case NAMECONCAT: { - StringInit *LHSs = dynamic_cast<StringInit*>(LHS); - StringInit *RHSs = dynamic_cast<StringInit*>(RHS); - if (LHSs && RHSs) { - std::string Name(LHSs->getValue() + RHSs->getValue()); - - // From TGParser::ParseIDValue - if (CurRec) { - if (const RecordVal *RV = CurRec->getValue(Name)) { - if (RV->getType() != getType()) { - throw "type mismatch in nameconcat"; - } - return new VarInit(Name, RV->getType()); - } - - std::string TemplateArgName = CurRec->getName()+":"+Name; - if (CurRec->isTemplateArg(TemplateArgName)) { - const RecordVal *RV = CurRec->getValue(TemplateArgName); - assert(RV && "Template arg doesn't exist??"); - - if (RV->getType() != getType()) { - throw "type mismatch in nameconcat"; - } - - return new VarInit(TemplateArgName, RV->getType()); - } - } - - if (CurMultiClass) { - std::string MCName = CurMultiClass->Rec.getName()+"::"+Name; - if (CurMultiClass->Rec.isTemplateArg(MCName)) { - const RecordVal *RV = CurMultiClass->Rec.getValue(MCName); - assert(RV && "Template arg doesn't exist??"); - - if (RV->getType() != getType()) { - throw "type mismatch in nameconcat"; - } - - return new VarInit(MCName, RV->getType()); - } - } - - if (Record *D = Records.getDef(Name)) - return new DefInit(D); - - errs() << "Variable not defined in !nameconcat: '" + Name + "'\n"; - assert(0 && "Variable not found in !nameconcat"); - return 0; - } - break; - } case EQ: { // try to fold eq comparison for 'bit' and 'int', otherwise fallback // to string objects. @@ -771,8 +697,6 @@ std::string BinOpInit::getAsString() const { case SRL: Result = "!srl"; break; case EQ: Result = "!eq"; break; case STRCONCAT: Result = "!strconcat"; break; - case NAMECONCAT: - Result = "!nameconcat<" + getType()->getAsString() + ">"; break; } return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")"; } diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index 85edbf5e979..44d64abd409 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -848,7 +848,7 @@ public: /// class BinOpInit : public OpInit { public: - enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, NAMECONCAT, EQ }; + enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, EQ }; private: BinaryOp Opc; Init *LHS, *RHS; diff --git a/utils/TableGen/TGLexer.cpp b/utils/TableGen/TGLexer.cpp index 4ea2e9118ef..12fa39f0092 100644 --- a/utils/TableGen/TGLexer.cpp +++ b/utils/TableGen/TGLexer.cpp @@ -427,7 +427,6 @@ tgtok::TokKind TGLexer::LexExclaim() { if (Len == 3 && !memcmp(Start, "shl", 3)) return tgtok::XSHL; if (Len == 2 && !memcmp(Start, "eq", 2)) return tgtok::XEq; if (Len == 9 && !memcmp(Start, "strconcat", 9)) return tgtok::XStrConcat; - if (Len == 10 && !memcmp(Start, "nameconcat", 10)) return tgtok::XNameConcat; if (Len == 5 && !memcmp(Start, "subst", 5)) return tgtok::XSubst; if (Len == 7 && !memcmp(Start, "foreach", 7)) return tgtok::XForEach; if (Len == 4 && !memcmp(Start, "cast", 4)) return tgtok::XCast; diff --git a/utils/TableGen/TGLexer.h b/utils/TableGen/TGLexer.h index 91392fed452..f5753a404eb 100644 --- a/utils/TableGen/TGLexer.h +++ b/utils/TableGen/TGLexer.h @@ -45,7 +45,7 @@ namespace tgtok { MultiClass, String, // !keywords. - XConcat, XSRA, XSRL, XSHL, XStrConcat, XNameConcat, XCast, XSubst, + XConcat, XSRA, XSRL, XSHL, XStrConcat, XCast, XSubst, XForEach, XCar, XCdr, XNull, XIf, XEq, // Integer value. diff --git a/utils/TableGen/TGParser.cpp b/utils/TableGen/TGParser.cpp index 0c46a814c25..d4095392809 100644 --- a/utils/TableGen/TGParser.cpp +++ b/utils/TableGen/TGParser.cpp @@ -797,8 +797,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { case tgtok::XSRL: case tgtok::XSHL: case tgtok::XEq: - case tgtok::XStrConcat: - case tgtok::XNameConcat: { // Value ::= !binop '(' Value ',' Value ')' + case tgtok::XStrConcat: { // Value ::= !binop '(' Value ',' Value ')' tgtok::TokKind OpTok = Lex.getCode(); SMLoc OpLoc = Lex.getLoc(); Lex.Lex(); // eat the operation @@ -808,39 +807,17 @@ Init *TGParser::ParseOperation(Record *CurRec) { switch (OpTok) { default: assert(0 && "Unhandled code!"); - case tgtok::XConcat: - Code = BinOpInit::CONCAT; - Type = new DagRecTy(); - break; - case tgtok::XSRA: - Code = BinOpInit::SRA; - Type = new IntRecTy(); - break; - case tgtok::XSRL: - Code = BinOpInit::SRL; - Type = new IntRecTy(); - break; - case tgtok::XSHL: - Code = BinOpInit::SHL; - Type = new IntRecTy(); - break; - case tgtok::XEq: - Code = BinOpInit::EQ; - Type = new IntRecTy(); - break; + case tgtok::XConcat: Code = BinOpInit::CONCAT; Type = new DagRecTy(); break; + case tgtok::XSRA: Code = BinOpInit::SRA; Type = new IntRecTy(); break; + case tgtok::XSRL: Code = BinOpInit::SRL; Type = new IntRecTy(); break; + case tgtok::XSHL: Code = BinOpInit::SHL; Type = new IntRecTy(); break; + case tgtok::XEq: Code = BinOpInit::EQ; Type = new IntRecTy(); break; case tgtok::XStrConcat: Code = BinOpInit::STRCONCAT; Type = new StringRecTy(); break; - case tgtok::XNameConcat: - Code = BinOpInit::NAMECONCAT; - Type = ParseOperatorType(); - if (Type == 0) { - TokError("did not get type for binary operator"); - return 0; - } - break; } + if (Lex.getCode() != tgtok::l_paren) { TokError("expected '(' after binary operator"); return 0; @@ -1226,9 +1203,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) { } case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')' Lex.Lex(); // eat the '(' - if (Lex.getCode() != tgtok::Id - && Lex.getCode() != tgtok::XCast - && Lex.getCode() != tgtok::XNameConcat) { + if (Lex.getCode() != tgtok::Id && Lex.getCode() != tgtok::XCast) { TokError("expected identifier in dag init"); return 0; } @@ -1278,8 +1253,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) { case tgtok::XSRL: case tgtok::XSHL: case tgtok::XEq: - case tgtok::XStrConcat: - case tgtok::XNameConcat: // Value ::= !binop '(' Value ',' Value ')' + case tgtok::XStrConcat: // Value ::= !binop '(' Value ',' Value ')' case tgtok::XIf: case tgtok::XForEach: case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')' |