llvm.org GIT mirror llvm / c754b57
Allow binary and for tblgen math. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214851 91177308-0d34-0410-b5e6-96231b3b80d8 Joerg Sonnenberger 5 years ago
6 changed file(s) with 18 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
927927 ///
928928 class BinOpInit : public OpInit {
929929 public:
930 enum BinaryOp { ADD, SHL, SRA, SRL, LISTCONCAT, STRCONCAT, CONCAT, EQ };
930 enum BinaryOp { ADD, AND, SHL, SRA, SRL, LISTCONCAT, STRCONCAT, CONCAT, EQ };
931931
932932 private:
933933 BinaryOp Opc;
951951 break;
952952 }
953953 case ADD:
954 case AND:
954955 case SHL:
955956 case SRA:
956957 case SRL: {
964965 switch (getOpcode()) {
965966 default: llvm_unreachable("Bad opcode!");
966967 case ADD: Result = LHSv + RHSv; break;
968 case AND: Result = LHSv & RHSv; break;
967969 case SHL: Result = LHSv << RHSv; break;
968970 case SRA: Result = LHSv >> RHSv; break;
969971 case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break;
990992 switch (Opc) {
991993 case CONCAT: Result = "!con"; break;
992994 case ADD: Result = "!add"; break;
995 case AND: Result = "!and"; break;
993996 case SHL: Result = "!shl"; break;
994997 case SRA: Result = "!sra"; break;
995998 case SRL: Result = "!srl"; break;
470470 .Case("tail", tgtok::XTail)
471471 .Case("con", tgtok::XConcat)
472472 .Case("add", tgtok::XADD)
473 .Case("and", tgtok::XAND)
473474 .Case("shl", tgtok::XSHL)
474475 .Case("sra", tgtok::XSRA)
475476 .Case("srl", tgtok::XSRL)
4646 MultiClass, String,
4747
4848 // !keywords.
49 XConcat, XADD, XSRA, XSRL, XSHL, XListConcat, XStrConcat, XCast, XSubst,
50 XForEach, XHead, XTail, XEmpty, XIf, XEq,
49 XConcat, XADD, XAND, XSRA, XSRL, XSHL, XListConcat, XStrConcat, XCast,
50 XSubst, XForEach, XHead, XTail, XEmpty, XIf, XEq,
5151
5252 // Integer value.
5353 IntVal,
910910
911911 case tgtok::XConcat:
912912 case tgtok::XADD:
913 case tgtok::XAND:
913914 case tgtok::XSRA:
914915 case tgtok::XSRL:
915916 case tgtok::XSHL:
927928 default: llvm_unreachable("Unhandled code!");
928929 case tgtok::XConcat: Code = BinOpInit::CONCAT;Type = DagRecTy::get(); break;
929930 case tgtok::XADD: Code = BinOpInit::ADD; Type = IntRecTy::get(); break;
931 case tgtok::XAND: Code = BinOpInit::AND; Type = IntRecTy::get(); break;
930932 case tgtok::XSRA: Code = BinOpInit::SRA; Type = IntRecTy::get(); break;
931933 case tgtok::XSRL: Code = BinOpInit::SRL; Type = IntRecTy::get(); break;
932934 case tgtok::XSHL: Code = BinOpInit::SHL; Type = IntRecTy::get(); break;
14451447 case tgtok::XCast: // Value ::= !unop '(' Value ')'
14461448 case tgtok::XConcat:
14471449 case tgtok::XADD:
1450 case tgtok::XAND:
14481451 case tgtok::XSRA:
14491452 case tgtok::XSRL:
14501453 case tgtok::XSHL:
1414 int Value = value;
1515 }
1616
17 // CHECK: def v0
18 // CHECK: Value = 0
19
20 // CHECK: def v1
21 // CHECK: Value = 1
22
1723 def v1024 : Int<1024>;
1824 // CHECK: def v1024
1925 // CHECK: Value = 1024
2632 // CHECK: def v2048
2733 // CHECK: Value = 2048
2834
35 def v0 : Int;
36 def v1 : Int;