1 // RUN: llvm-tblgen %s | FileCheck %s
8 class ValueType<int size, int value> {
13 def v2i64 : ValueType<128, 22>; // 2 x i64 vector value
14 def v2f64 : ValueType<128, 28>; // 2 x f64 vector value
16 class Intrinsic<string name> {
20 class Inst<bits<8> opcode, dag oopnds, dag iopnds, string asmstr,
22 bits<8> Opcode = opcode;
23 dag OutOperands = oopnds;
24 dag InOperands = iopnds;
25 string AssemblyString = asmstr;
26 list<dag> Pattern = pattern;
36 class Register<string n> {
40 class RegisterClass<list<ValueType> regTypes, list<Register> regList> {
41 list<ValueType> RegTypes = regTypes;
42 list<Register> MemberList = regList;
45 def XMM0: Register<"xmm0">;
46 def XMM1: Register<"xmm1">;
47 def XMM2: Register<"xmm2">;
48 def XMM3: Register<"xmm3">;
49 def XMM4: Register<"xmm4">;
50 def XMM5: Register<"xmm5">;
51 def XMM6: Register<"xmm6">;
52 def XMM7: Register<"xmm7">;
53 def XMM8: Register<"xmm8">;
54 def XMM9: Register<"xmm9">;
55 def XMM10: Register<"xmm10">;
56 def XMM11: Register<"xmm11">;
57 def XMM12: Register<"xmm12">;
58 def XMM13: Register<"xmm13">;
59 def XMM14: Register<"xmm14">;
60 def XMM15: Register<"xmm15">;
62 def VR128 : RegisterClass<[v2i64, v2f64],
63 [XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
64 XMM8, XMM9, XMM10, XMM11,
65 XMM12, XMM13, XMM14, XMM15]>;
68 def int_x86_sse2_add_ps : Intrinsic<"addps">;
69 def int_x86_sse2_add_pd : Intrinsic<"addpd">;
71 multiclass arith<bits<8> opcode, string asmstr, string Intr> {
72 def PS : Inst<opcode, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
73 !strconcat(asmstr, "\t$dst, $src1, $src2"),
74 [(set VR128:$dst, (!cast<Intrinsic>(!strconcat(Intr, "_ps")) VR128:$src1, VR128:$src2))]>;
76 def PD : Inst<opcode, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
77 !strconcat(asmstr, "\t$dst, $src1, $src2"),
78 [(set VR128:$dst, (!cast<Intrinsic>(!strconcat(Intr, "_pd")) VR128:$src1, VR128:$src2))]>;
81 defm ADD : arith<0x58, "add", "int_x86_sse2_add">;
83 class IntInst<bits<8> opcode, string asmstr, Intrinsic Intr> :
84 Inst<opcode,(outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
85 !strconcat(asmstr, "\t$dst, $src1, $src2"),
86 [(set VR128:$dst, (Intr VR128:$src1, VR128:$src2))]>;
89 multiclass arith_int<bits<8> opcode, string asmstr, string Intr> {
90 def PS_Int : IntInst<opcode, asmstr, !cast<Intrinsic>(!strconcat(Intr, "_ps"))>;
92 def PD_Int : IntInst<opcode, asmstr, !cast<Intrinsic>(!strconcat(Intr, "_pd"))>;
95 defm ADD : arith_int<0x58, "add", "int_x86_sse2_add">;