From e917fff30f9bb8c24a656492449d72d8262c7d7f Mon Sep 17 00:00:00 2001 From: David Greene Date: Thu, 14 May 2009 22:23:47 +0000 Subject: Implement a !foreach operator analogous to GNU make's $(foreach). Use it on dags and lists like this: class decls { string name; } def Decls : decls; class B names> : A; llvm-svn: 71803 --- llvm/utils/TableGen/TGParser.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'llvm/utils/TableGen/TGParser.cpp') diff --git a/llvm/utils/TableGen/TGParser.cpp b/llvm/utils/TableGen/TGParser.cpp index 967f5d0d5dd..bc5d65eea59 100644 --- a/llvm/utils/TableGen/TGParser.cpp +++ b/llvm/utils/TableGen/TGParser.cpp @@ -792,7 +792,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { return (new BinOpInit(Code, LHS, RHS, Type))->Fold(CurRec, CurMultiClass); } -// case tgtok::XForEach: + case tgtok::XForEach: case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')' TernOpInit::TernaryOp Code; RecTy *Type = 0; @@ -802,9 +802,9 @@ Init *TGParser::ParseOperation(Record *CurRec) { Lex.Lex(); // eat the operation switch (LexCode) { default: assert(0 && "Unhandled code!"); - //case tgtok::XForEach: - //Code = TernOpInit::FOREACH; - //break; + case tgtok::XForEach: + Code = TernOpInit::FOREACH; + break; case tgtok::XSubst: Code = TernOpInit::SUBST; break; @@ -844,15 +844,15 @@ Init *TGParser::ParseOperation(Record *CurRec) { switch (LexCode) { default: assert(0 && "Unhandled code!"); - //case tgtok::XForEach: { - //TypedInit *MHSt = dynamic_cast(MHS); - //if (MHSt == 0) { - // TokError("could not get type for !foreach"); - // return 0; - //} - //Type = MHSt->getType(); - //break; - //} + case tgtok::XForEach: { + TypedInit *MHSt = dynamic_cast(MHS); + if (MHSt == 0) { + TokError("could not get type for !foreach"); + return 0; + } + Type = MHSt->getType(); + break; + } case tgtok::XSubst: { TypedInit *RHSt = dynamic_cast(RHS); if (RHSt == 0) { @@ -1079,7 +1079,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec) { case tgtok::XSHL: case tgtok::XStrConcat: case tgtok::XNameConcat: // Value ::= !binop '(' Value ',' Value ')' - // case tgtok::XForEach: + case tgtok::XForEach: case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')' return ParseOperation(CurRec); break; -- cgit v1.2.3