Index: llvm/lib/TableGen/TGParser.cpp =================================================================== --- llvm/lib/TableGen/TGParser.cpp +++ llvm/lib/TableGen/TGParser.cpp @@ -2173,6 +2173,20 @@ break; } + case tgtok::plus: { + SMLoc PlusLoc = Lex.getLoc(); + TypedInit *LHS = dyn_cast(Result); + if (!LHS) { + Error(PlusLoc, "LHS of '+' is not typed!"); + return nullptr; + } + Lex.Lex(); // Eat the '+' + Init *RHSResult = ParseValue(CurRec, ItemType, ParseNameMode); + Result = BinOpInit::get(BinOpInit::ADD, LHS, RHSResult, + IntRecTy::get())->Fold(CurRec); + break; + } + case tgtok::paste: SMLoc PasteLoc = Lex.getLoc(); TypedInit *LHS = dyn_cast(Result); Index: llvm/test/TableGen/infix-add.td =================================================================== --- /dev/null +++ llvm/test/TableGen/infix-add.td @@ -0,0 +1,28 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +class Int { + int Val = v; +} + +// CHECK: def AA1 { +// CHECK-NEXT: int Val = 1; +// CHECK: def AB1 { +// CHECK-NEXT: int Val = 11; +foreach Index = 1-1 in { + def AA#Index : Int; + def AB#Index : Int; +} + + +// CHECK: def I20 { +// CHECK-NEXT : int Val = 20; +def I20 : Int<20>; + +// CHECK: def I21 { +// CHECK-NEXT : int Val = 21; +def I21 : Int; + +// CHECK: def I300 { +// CHECK-NEXT: int Val = 300; +def I300 : Int<155 + 145>;