Index: docs/TableGen/LangRef.rst =================================================================== --- docs/TableGen/LangRef.rst +++ docs/TableGen/LangRef.rst @@ -96,7 +96,7 @@ .. productionlist:: BangOperator: one of :!eq !if !head !tail !con - :!add !shl !sra !srl !and + :!add !shl !sra !srl !and !or :!cast !empty !subst !foreach !listconcat !strconcat Syntax Index: include/llvm/TableGen/Record.h =================================================================== --- include/llvm/TableGen/Record.h +++ include/llvm/TableGen/Record.h @@ -798,7 +798,7 @@ /// class BinOpInit : public OpInit, public FoldingSetNode { public: - enum BinaryOp : uint8_t { ADD, AND, SHL, SRA, SRL, LISTCONCAT, + enum BinaryOp : uint8_t { ADD, AND, OR, SHL, SRA, SRL, LISTCONCAT, STRCONCAT, CONCAT, EQ }; private: Index: lib/TableGen/Record.cpp =================================================================== --- lib/TableGen/Record.cpp +++ lib/TableGen/Record.cpp @@ -865,6 +865,7 @@ } case ADD: case AND: + case OR: case SHL: case SRA: case SRL: { @@ -879,6 +880,7 @@ default: llvm_unreachable("Bad opcode!"); case ADD: Result = LHSv + RHSv; break; case AND: Result = LHSv & RHSv; break; + case OR: Result = LHSv | RHSv; break; case SHL: Result = LHSv << RHSv; break; case SRA: Result = LHSv >> RHSv; break; case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break; @@ -906,6 +908,7 @@ case CONCAT: Result = "!con"; break; case ADD: Result = "!add"; break; case AND: Result = "!and"; break; + case OR: Result = "!or"; break; case SHL: Result = "!shl"; break; case SRA: Result = "!sra"; break; case SRL: Result = "!srl"; break; Index: lib/TableGen/TGLexer.h =================================================================== --- lib/TableGen/TGLexer.h +++ lib/TableGen/TGLexer.h @@ -45,9 +45,9 @@ // Keywords. Bit, Bits, Class, Code, Dag, Def, Foreach, Defm, Field, In, Int, Let, List, MultiClass, String, - + // !keywords. - XConcat, XADD, XAND, XSRA, XSRL, XSHL, XListConcat, XStrConcat, XCast, + XConcat, XADD, XAND, XOR, XSRA, XSRL, XSHL, XListConcat, XStrConcat, XCast, XSubst, XForEach, XHead, XTail, XEmpty, XIf, XEq, // Integer value. Index: lib/TableGen/TGLexer.cpp =================================================================== --- lib/TableGen/TGLexer.cpp +++ lib/TableGen/TGLexer.cpp @@ -472,6 +472,7 @@ .Case("con", tgtok::XConcat) .Case("add", tgtok::XADD) .Case("and", tgtok::XAND) + .Case("or", tgtok::XOR) .Case("shl", tgtok::XSHL) .Case("sra", tgtok::XSRA) .Case("srl", tgtok::XSRL) Index: lib/TableGen/TGParser.cpp =================================================================== --- lib/TableGen/TGParser.cpp +++ lib/TableGen/TGParser.cpp @@ -881,6 +881,7 @@ case tgtok::XConcat: case tgtok::XADD: case tgtok::XAND: + case tgtok::XOR: case tgtok::XSRA: case tgtok::XSRL: case tgtok::XSHL: @@ -899,6 +900,7 @@ case tgtok::XConcat: Code = BinOpInit::CONCAT;Type = DagRecTy::get(); break; case tgtok::XADD: Code = BinOpInit::ADD; Type = IntRecTy::get(); break; case tgtok::XAND: Code = BinOpInit::AND; Type = IntRecTy::get(); break; + case tgtok::XOR: Code = BinOpInit::OR; Type = IntRecTy::get(); break; case tgtok::XSRA: Code = BinOpInit::SRA; Type = IntRecTy::get(); break; case tgtok::XSRL: Code = BinOpInit::SRL; Type = IntRecTy::get(); break; case tgtok::XSHL: Code = BinOpInit::SHL; Type = IntRecTy::get(); break; @@ -1446,6 +1448,7 @@ case tgtok::XConcat: case tgtok::XADD: case tgtok::XAND: + case tgtok::XOR: case tgtok::XSRA: case tgtok::XSRL: case tgtok::XSHL: Index: test/TableGen/math.td =================================================================== --- test/TableGen/math.td +++ test/TableGen/math.td @@ -15,12 +15,18 @@ int Value = value; } +def v1022 : Int<1022>; + // CHECK: def v0 // CHECK: Value = 0 // CHECK: def v1 // CHECK: Value = 1 +// CHECK: def v1023 +// CHECK: Value = 1023 +def v1023 : Int; + def v1024 : Int<1024>; // CHECK: def v1024 // CHECK: Value = 1024 @@ -35,3 +41,7 @@ def v0 : Int; def v1 : Int; + +// CHECK: def v3072 +// CHECK: Value = 3072 +def v3072 : Int;