Add a !patsubst operator. Use on string types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73099 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Greene
2009-06-08 23:05:37 +00:00
parent 2e7ccfce98
commit 0d973999f3
8 changed files with 97 additions and 3 deletions
+9
View File
@@ -878,6 +878,7 @@ Init *TGParser::ParseOperation(Record *CurRec) {
case tgtok::XIf:
case tgtok::XForEach:
case tgtok::XPatSubst:
case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')'
TernOpInit::TernaryOp Code;
RecTy *Type = 0;
@@ -896,6 +897,9 @@ Init *TGParser::ParseOperation(Record *CurRec) {
case tgtok::XSubst:
Code = TernOpInit::SUBST;
break;
case tgtok::XPatSubst:
Code = TernOpInit::PATSUBST;
break;
}
if (Lex.getCode() != tgtok::l_paren) {
TokError("expected '(' after ternary operator");
@@ -969,6 +973,10 @@ Init *TGParser::ParseOperation(Record *CurRec) {
Type = RHSt->getType();
break;
}
case tgtok::XPatSubst: {
Type = new StringRecTy;
break;
}
}
return (new TernOpInit(Code, LHS, MHS, RHS, Type))->Fold(CurRec, CurMultiClass);
}
@@ -1277,6 +1285,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
case tgtok::XNameConcat: // Value ::= !binop '(' Value ',' Value ')'
case tgtok::XIf:
case tgtok::XForEach:
case tgtok::XPatSubst:
case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')'
return ParseOperation(CurRec);
break;