llvm.org GIT mirror llvm / c7252ce
remove the !nameconcat tblgen feature. It "shorthand" and only used in 4 places where !cast is just as short. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115722 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 8 years ago
8 changed file(s) with 26 addition(s) and 222 deletion(s). Raw diff Collapse all Expand all
404404 the symbol table. If the type of 'a' does not match type, TableGen
405405 aborts with an error. !cast<string> is a special case in that the argument must
406406 be an object defined by a 'def' construct.
407
!nameconcat<type>(a, b)
408
Shorthand for !cast<type>(!strconcat(a, b))
409407
!subst(a, b, c)
410408
If 'a' and 'b' are of string type or are symbol references, substitute
411409 'b' for 'a' in 'c.' This operation is analogous to $(subst) in GNU make.
4444 !if(Is2Addr,
4545 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
4646 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
47 [(set RC:$dst, (!nameconcat("int_x86_sse",
48 !strconcat(SSEVer, "_", OpcodeStr, FPSizeStr))
47 [(set RC:$dst, (!cast(
48 !strconcat("int_x86_sse", SSEVer, "_", OpcodeStr, FPSizeStr))
4949 RC:$src1, RC:$src2))]>;
5050 def rm_Int : SI
5151 !if(Is2Addr,
5252 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
5353 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
54 [(set RC:$dst, (!nameconcat("int_x86_sse",
55 !strconcat(SSEVer, "_", OpcodeStr, FPSizeStr))
54 [(set RC:$dst, (!cast(!strconcat("int_x86_sse",
55 SSEVer, "_", OpcodeStr, FPSizeStr))
5656 RC:$src1, mem_cpat:$src2))]>;
5757 }
5858
102102 !if(Is2Addr,
103103 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
104104 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
105 [(set RC:$dst, (!nameconcat("int_x86_",
106 !strconcat(SSEVer, "_", OpcodeStr, FPSizeStr))
105 [(set RC:$dst, (!cast(
106 !strconcat("int_x86_", SSEVer, "_", OpcodeStr, FPSizeStr))
107107 RC:$src1, RC:$src2))], d>;
108108 def rm_Int : PI
109109 !if(Is2Addr,
110110 !strconcat(asm, "\t{$src2, $dst|$dst, $src2}"),
111111 !strconcat(asm, "\t{$src2, $src1, $dst|$dst, $src1, $src2}")),
112 [(set RC:$dst, (!nameconcat("int_x86_",
113 !strconcat(SSEVer, "_", OpcodeStr, FPSizeStr))
112 [(set RC:$dst, (!cast(
113 !strconcat("int_x86_", SSEVer, "_", OpcodeStr, FPSizeStr))
114114 RC:$src1, (mem_frag addr:$src2)))], d>;
115115 }
116116
+0
-91
test/TableGen/nameconcat.td less more
None // RUN: tblgen %s | grep {add_ps} | count 3
1 // XFAIL: vg_leak
2
3 class ValueType {
4 int Size = size;
5 int Value = value;
6 }
7
8 def v2i64 : ValueType<128, 22>; // 2 x i64 vector value
9 def v2f64 : ValueType<128, 28>; // 2 x f64 vector value
10
11 class Intrinsic {
12 string Name = name;
13 }
14
15 class Inst opcode, dag oopnds, dag iopnds, string asmstr,
16 list pattern> {
17 bits<8> Opcode = opcode;
18 dag OutOperands = oopnds;
19 dag InOperands = iopnds;
20 string AssemblyString = asmstr;
21 list Pattern = pattern;
22 }
23
24 def ops;
25 def outs;
26 def ins;
27
28 def set;
29
30 // Define registers
31 class Register {
32 string Name = n;
33 }
34
35 class RegisterClass regTypes, list regList> {
36 list RegTypes = regTypes;
37 list MemberList = regList;
38 }
39
40 def XMM0: Register<"xmm0">;
41 def XMM1: Register<"xmm1">;
42 def XMM2: Register<"xmm2">;
43 def XMM3: Register<"xmm3">;
44 def XMM4: Register<"xmm4">;
45 def XMM5: Register<"xmm5">;
46 def XMM6: Register<"xmm6">;
47 def XMM7: Register<"xmm7">;
48 def XMM8: Register<"xmm8">;
49 def XMM9: Register<"xmm9">;
50 def XMM10: Register<"xmm10">;
51 def XMM11: Register<"xmm11">;
52 def XMM12: Register<"xmm12">;
53 def XMM13: Register<"xmm13">;
54 def XMM14: Register<"xmm14">;
55 def XMM15: Register<"xmm15">;
56
57 def VR128 : RegisterClass<[v2i64, v2f64],
58 [XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
59 XMM8, XMM9, XMM10, XMM11,
60 XMM12, XMM13, XMM14, XMM15]>;
61
62 // Define intrinsics
63 def int_x86_sse2_add_ps : Intrinsic<"addps">;
64 def int_x86_sse2_add_pd : Intrinsic<"addpd">;
65
66 multiclass arith opcode, string asmstr, string Intr> {
67 def PS : Inst
68 !strconcat(asmstr, "\t$dst, $src1, $src2"),
69 [(set VR128:$dst, (!nameconcat(Intr, "_ps") VR128:$src1, VR128:$src2))]>;
70
71 def PD : Inst
72 !strconcat(asmstr, "\t$dst, $src1, $src2"),
73 [(set VR128:$dst, (!nameconcat(Intr, "_pd") VR128:$src1, VR128:$src2))]>;
74 }
75
76 defm ADD : arith<0x58, "add", "int_x86_sse2_add">;
77
78 class IntInst opcode, string asmstr, Intrinsic Intr> :
79 Inst
80 !strconcat(asmstr, "\t$dst, $src1, $src2"),
81 [(set VR128:$dst, (Intr VR128:$src1, VR128:$src2))]>;
82
83
84 multiclass arith_int opcode, string asmstr, string Intr> {
85 def PS_Int : IntInst(Intr, "_ps")>;
86
87 def PD_Int : IntInst(Intr, "_pd")>;
88 }
89
90 defm ADD : arith_int<0x58, "add", "int_x86_sse2_add">;
151151 return new BinOpInit(BinOpInit::STRCONCAT, L, R, new StringRecTy);
152152 return BO;
153153 }
154 if (BO->getOpcode() == BinOpInit::NAMECONCAT) {
155 if (BO->getType()->getAsString() == getAsString()) {
156 Init *L = BO->getLHS()->convertInitializerTo(this);
157 Init *R = BO->getRHS()->convertInitializerTo(this);
158 if (L == 0 || R == 0) return 0;
159 if (L != BO->getLHS() || R != BO->getRHS())
160 return new BinOpInit(BinOpInit::NAMECONCAT, L, R, new StringRecTy);
161 return BO;
162 }
163 }
164154
165155 return convertValue((TypedInit*)BO);
166156 }
234224 if (L != BO->getLHS() || R != BO->getRHS())
235225 return new BinOpInit(BinOpInit::CONCAT, L, R, new DagRecTy);
236226 return BO;
237 }
238 if (BO->getOpcode() == BinOpInit::NAMECONCAT) {
239 if (BO->getType()->getAsString() == getAsString()) {
240 Init *L = BO->getLHS()->convertInitializerTo(this);
241 Init *R = BO->getRHS()->convertInitializerTo(this);
242 if (L == 0 || R == 0) return 0;
243 if (L != BO->getLHS() || R != BO->getRHS())
244 return new BinOpInit(BinOpInit::CONCAT, L, R, new DagRecTy);
245 return BO;
246 }
247227 }
248228 return 0;
249229 }
517497 // From TGParser::ParseIDValue
518498 if (CurRec) {
519499 if (const RecordVal *RV = CurRec->getValue(Name)) {
520 if (RV->getType() != getType()) {
521 throw "type mismatch in nameconcat";
522 }
500 if (RV->getType() != getType())
501 throw "type mismatch in cast";
523502 return new VarInit(Name, RV->getType());
524503 }
525504
528507 const RecordVal *RV = CurRec->getValue(TemplateArgName);
529508 assert(RV && "Template arg doesn't exist??");
530509
531 if (RV->getType() != getType()) {
532 throw "type mismatch in nameconcat";
533 }
510 if (RV->getType() != getType())
511 throw "type mismatch in cast";
534512
535513 return new VarInit(TemplateArgName, RV->getType());
536514 }
542520 const RecordVal *RV = CurMultiClass->Rec.getValue(MCName);
543521 assert(RV && "Template arg doesn't exist??");
544522
545 if (RV->getType() != getType()) {
546 throw "type mismatch in nameconcat";
547 }
523 if (RV->getType() != getType())
524 throw "type mismatch in cast";
548525
549526 return new VarInit(MCName, RV->getType());
550527 }
659636 return new StringInit(LHSs->getValue() + RHSs->getValue());
660637 break;
661638 }
662 case NAMECONCAT: {
663 StringInit *LHSs = dynamic_cast(LHS);
664 StringInit *RHSs = dynamic_cast(RHS);
665 if (LHSs && RHSs) {
666 std::string Name(LHSs->getValue() + RHSs->getValue());
667
668 // From TGParser::ParseIDValue
669 if (CurRec) {
670 if (const RecordVal *RV = CurRec->getValue(Name)) {
671 if (RV->getType() != getType()) {
672 throw "type mismatch in nameconcat";
673 }
674 return new VarInit(Name, RV->getType());
675 }
676
677 std::string TemplateArgName = CurRec->getName()+":"+Name;
678 if (CurRec->isTemplateArg(TemplateArgName)) {
679 const RecordVal *RV = CurRec->getValue(TemplateArgName);
680 assert(RV && "Template arg doesn't exist??");
681
682 if (RV->getType() != getType()) {
683 throw "type mismatch in nameconcat";
684 }
685
686 return new VarInit(TemplateArgName, RV->getType());
687 }
688 }
689
690 if (CurMultiClass) {
691 std::string MCName = CurMultiClass->Rec.getName()+"::"+Name;
692 if (CurMultiClass->Rec.isTemplateArg(MCName)) {
693 const RecordVal *RV = CurMultiClass->Rec.getValue(MCName);
694 assert(RV && "Template arg doesn't exist??");
695
696 if (RV->getType() != getType()) {
697 throw "type mismatch in nameconcat";
698 }
699
700 return new VarInit(MCName, RV->getType());
701 }
702 }
703
704 if (Record *D = Records.getDef(Name))
705 return new DefInit(D);
706
707 errs() << "Variable not defined in !nameconcat: '" + Name + "'\n";
708 assert(0 && "Variable not found in !nameconcat");
709 return 0;
710 }
711 break;
712 }
713639 case EQ: {
714640 // try to fold eq comparison for 'bit' and 'int', otherwise fallback
715641 // to string objects.
770696 case SRL: Result = "!srl"; break;
771697 case EQ: Result = "!eq"; break;
772698 case STRCONCAT: Result = "!strconcat"; break;
773 case NAMECONCAT:
774 Result = "!nameconcat<" + getType()->getAsString() + ">"; break;
775699 }
776700 return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")";
777701 }
847847 ///
848848 class BinOpInit : public OpInit {
849849 public:
850 enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, NAMECONCAT, EQ };
850 enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, EQ };
851851 private:
852852 BinaryOp Opc;
853853 Init *LHS, *RHS;
426426 if (Len == 3 && !memcmp(Start, "shl", 3)) return tgtok::XSHL;
427427 if (Len == 2 && !memcmp(Start, "eq", 2)) return tgtok::XEq;
428428 if (Len == 9 && !memcmp(Start, "strconcat", 9)) return tgtok::XStrConcat;
429 if (Len == 10 && !memcmp(Start, "nameconcat", 10)) return tgtok::XNameConcat;
430429 if (Len == 5 && !memcmp(Start, "subst", 5)) return tgtok::XSubst;
431430 if (Len == 7 && !memcmp(Start, "foreach", 7)) return tgtok::XForEach;
432431 if (Len == 4 && !memcmp(Start, "cast", 4)) return tgtok::XCast;
4444 MultiClass, String,
4545
4646 // !keywords.
47 XConcat, XSRA, XSRL, XSHL, XStrConcat, XNameConcat, XCast, XSubst,
47 XConcat, XSRA, XSRL, XSHL, XStrConcat, XCast, XSubst,
4848 XForEach, XCar, XCdr, XNull, XIf, XEq,
4949
5050 // Integer value.
796796 case tgtok::XSRL:
797797 case tgtok::XSHL:
798798 case tgtok::XEq:
799 case tgtok::XStrConcat:
800 case tgtok::XNameConcat: { // Value ::= !binop '(' Value ',' Value ')'
799 case tgtok::XStrConcat: { // Value ::= !binop '(' Value ',' Value ')'
801800 tgtok::TokKind OpTok = Lex.getCode();
802801 SMLoc OpLoc = Lex.getLoc();
803802 Lex.Lex(); // eat the operation
807806
808807 switch (OpTok) {
809808 default: assert(0 && "Unhandled code!");
810 case tgtok::XConcat:
811 Code = BinOpInit::CONCAT;
812 Type = new DagRecTy();
813 break;
814 case tgtok::XSRA:
815 Code = BinOpInit::SRA;
816 Type = new IntRecTy();
817 break;
818 case tgtok::XSRL:
819 Code = BinOpInit::SRL;
820 Type = new IntRecTy();
821 break;
822 case tgtok::XSHL:
823 Code = BinOpInit::SHL;
824 Type = new IntRecTy();
825 break;
826 case tgtok::XEq:
827 Code = BinOpInit::EQ;
828 Type = new IntRecTy();
829 break;
809 case tgtok::XConcat: Code = BinOpInit::CONCAT; Type = new DagRecTy(); break;
810 case tgtok::XSRA: Code = BinOpInit::SRA; Type = new IntRecTy(); break;
811 case tgtok::XSRL: Code = BinOpInit::SRL; Type = new IntRecTy(); break;
812 case tgtok::XSHL: Code = BinOpInit::SHL; Type = new IntRecTy(); break;
813 case tgtok::XEq: Code = BinOpInit::EQ; Type = new IntRecTy(); break;
830814 case tgtok::XStrConcat:
831815 Code = BinOpInit::STRCONCAT;
832816 Type = new StringRecTy();
833817 break;
834 case tgtok::XNameConcat:
835 Code = BinOpInit::NAMECONCAT;
836 Type = ParseOperatorType();
837 if (Type == 0) {
838 TokError("did not get type for binary operator");
839 return 0;
840 }
841 break;
842 }
818 }
819
843820 if (Lex.getCode() != tgtok::l_paren) {
844821 TokError("expected '(' after binary operator");
845822 return 0;
12251202 }
12261203 case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')'
12271204 Lex.Lex(); // eat the '('
1228 if (Lex.getCode() != tgtok::Id
1229 && Lex.getCode() != tgtok::XCast
1230 && Lex.getCode() != tgtok::XNameConcat) {
1205 if (Lex.getCode() != tgtok::Id && Lex.getCode() != tgtok::XCast) {
12311206 TokError("expected identifier in dag init");
12321207 return 0;
12331208 }
12771252 case tgtok::XSRL:
12781253 case tgtok::XSHL:
12791254 case tgtok::XEq:
1280 case tgtok::XStrConcat:
1281 case tgtok::XNameConcat: // Value ::= !binop '(' Value ',' Value ')'
1255 case tgtok::XStrConcat: // Value ::= !binop '(' Value ',' Value ')'
12821256 case tgtok::XIf:
12831257 case tgtok::XForEach:
12841258 case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')'