annotate lib/Target/X86/X86LegalizerInfo.cpp @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents
children 3a76565eade5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 //===- X86LegalizerInfo.cpp --------------------------------------*- C++ -*-==//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9 /// \file
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 /// This file implements the targeting of the Machinelegalizer class for X86.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 /// \todo This should be generated by TableGen.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14 #include "X86LegalizerInfo.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 #include "X86Subtarget.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16 #include "X86TargetMachine.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17 #include "llvm/CodeGen/ValueTypes.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18 #include "llvm/IR/DerivedTypes.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19 #include "llvm/IR/Type.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 #include "llvm/Target/TargetOpcodes.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 using namespace llvm;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23 using namespace TargetOpcode;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26 const X86TargetMachine &TM)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27 : Subtarget(STI), TM(TM) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 setLegalizerInfo32bit();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 setLegalizerInfo64bit();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 setLegalizerInfoSSE1();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 setLegalizerInfoSSE2();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 setLegalizerInfoSSE41();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34 setLegalizerInfoAVX();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 setLegalizerInfoAVX2();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36 setLegalizerInfoAVX512();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37 setLegalizerInfoAVX512DQ();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 setLegalizerInfoAVX512BW();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40 computeTables();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 void X86LegalizerInfo::setLegalizerInfo32bit() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45 const LLT p0 = LLT::pointer(0, TM.getPointerSize() * 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46 const LLT s1 = LLT::scalar(1);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47 const LLT s8 = LLT::scalar(8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48 const LLT s16 = LLT::scalar(16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
49 const LLT s32 = LLT::scalar(32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
50 const LLT s64 = LLT::scalar(64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
51
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
52 for (auto Ty : {p0, s1, s8, s16, s32})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
53 setAction({G_IMPLICIT_DEF, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
54
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
55 for (auto Ty : {s8, s16, s32, p0})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
56 setAction({G_PHI, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
57
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
58 setAction({G_PHI, s1}, WidenScalar);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
59
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
60 for (unsigned BinOp : {G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
61 for (auto Ty : {s8, s16, s32})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
62 setAction({BinOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
63
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
64 setAction({BinOp, s1}, WidenScalar);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
65 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
66
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
67 for (unsigned Op : {G_UADDE}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
68 setAction({Op, s32}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
69 setAction({Op, 1, s1}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
70 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
71
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
72 for (unsigned MemOp : {G_LOAD, G_STORE}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
73 for (auto Ty : {s8, s16, s32, p0})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
74 setAction({MemOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
75
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
76 setAction({MemOp, s1}, WidenScalar);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
77 // And everything's fine in addrspace 0.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
78 setAction({MemOp, 1, p0}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
79 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
80
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
81 // Pointer-handling
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
82 setAction({G_FRAME_INDEX, p0}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
83 setAction({G_GLOBAL_VALUE, p0}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
84
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
85 setAction({G_GEP, p0}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
86 setAction({G_GEP, 1, s32}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
87
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
88 for (auto Ty : {s1, s8, s16})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
89 setAction({G_GEP, 1, Ty}, WidenScalar);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
90
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
91 // Control-flow
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
92 setAction({G_BRCOND, s1}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
93
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
94 // Constants
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
95 for (auto Ty : {s8, s16, s32, p0})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
96 setAction({TargetOpcode::G_CONSTANT, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
97
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
98 setAction({TargetOpcode::G_CONSTANT, s1}, WidenScalar);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
99 setAction({TargetOpcode::G_CONSTANT, s64}, NarrowScalar);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
100
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
101 // Extensions
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
102 for (auto Ty : {s8, s16, s32}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
103 setAction({G_ZEXT, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
104 setAction({G_SEXT, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
105 setAction({G_ANYEXT, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
106 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
107
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
108 for (auto Ty : {s1, s8, s16}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
109 setAction({G_ZEXT, 1, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
110 setAction({G_SEXT, 1, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
111 setAction({G_ANYEXT, 1, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
112 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
113
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
114 // Comparison
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
115 setAction({G_ICMP, s1}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
116
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
117 for (auto Ty : {s8, s16, s32, p0})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
118 setAction({G_ICMP, 1, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
119 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
120
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
121 void X86LegalizerInfo::setLegalizerInfo64bit() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
122
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
123 if (!Subtarget.is64Bit())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
124 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
125
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
126 const LLT s32 = LLT::scalar(32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
127 const LLT s64 = LLT::scalar(64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
128
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
129 setAction({G_IMPLICIT_DEF, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
130
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
131 setAction({G_PHI, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
132
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
133 for (unsigned BinOp : {G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
134 setAction({BinOp, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
135
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
136 for (unsigned MemOp : {G_LOAD, G_STORE})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
137 setAction({MemOp, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
138
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
139 // Pointer-handling
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
140 setAction({G_GEP, 1, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
141
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
142 // Constants
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
143 setAction({TargetOpcode::G_CONSTANT, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
144
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
145 // Extensions
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
146 for (unsigned extOp : {G_ZEXT, G_SEXT, G_ANYEXT}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
147 setAction({extOp, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
148 setAction({extOp, 1, s32}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
149 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
150
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
151 // Comparison
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
152 setAction({G_ICMP, 1, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
153 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
154
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
155 void X86LegalizerInfo::setLegalizerInfoSSE1() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
156 if (!Subtarget.hasSSE1())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
157 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
158
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
159 const LLT s32 = LLT::scalar(32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
160 const LLT v4s32 = LLT::vector(4, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
161 const LLT v2s64 = LLT::vector(2, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
162
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
163 for (unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
164 for (auto Ty : {s32, v4s32})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
165 setAction({BinOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
166
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
167 for (unsigned MemOp : {G_LOAD, G_STORE})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
168 for (auto Ty : {v4s32, v2s64})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
169 setAction({MemOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
170
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
171 // Constants
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
172 setAction({TargetOpcode::G_FCONSTANT, s32}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
173 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
174
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
175 void X86LegalizerInfo::setLegalizerInfoSSE2() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
176 if (!Subtarget.hasSSE2())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
177 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
178
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
179 const LLT s32 = LLT::scalar(32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
180 const LLT s64 = LLT::scalar(64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
181 const LLT v16s8 = LLT::vector(16, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
182 const LLT v8s16 = LLT::vector(8, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
183 const LLT v4s32 = LLT::vector(4, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
184 const LLT v2s64 = LLT::vector(2, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
185
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
186 for (unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
187 for (auto Ty : {s64, v2s64})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
188 setAction({BinOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
189
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
190 for (unsigned BinOp : {G_ADD, G_SUB})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
191 for (auto Ty : {v16s8, v8s16, v4s32, v2s64})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
192 setAction({BinOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
193
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
194 setAction({G_MUL, v8s16}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
195
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
196 setAction({G_FPEXT, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
197 setAction({G_FPEXT, 1, s32}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
198
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
199 // Constants
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
200 setAction({TargetOpcode::G_FCONSTANT, s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
201 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
202
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
203 void X86LegalizerInfo::setLegalizerInfoSSE41() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
204 if (!Subtarget.hasSSE41())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
205 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
206
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
207 const LLT v4s32 = LLT::vector(4, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
208
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
209 setAction({G_MUL, v4s32}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
210 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
211
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
212 void X86LegalizerInfo::setLegalizerInfoAVX() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
213 if (!Subtarget.hasAVX())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
214 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
215
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
216 const LLT v16s8 = LLT::vector(16, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
217 const LLT v8s16 = LLT::vector(8, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
218 const LLT v4s32 = LLT::vector(4, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
219 const LLT v2s64 = LLT::vector(2, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
220
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
221 const LLT v32s8 = LLT::vector(32, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
222 const LLT v16s16 = LLT::vector(16, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
223 const LLT v8s32 = LLT::vector(8, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
224 const LLT v4s64 = LLT::vector(4, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
225
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
226 for (unsigned MemOp : {G_LOAD, G_STORE})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
227 for (auto Ty : {v8s32, v4s64})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
228 setAction({MemOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
229
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
230 for (auto Ty : {v32s8, v16s16, v8s32, v4s64}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
231 setAction({G_INSERT, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
232 setAction({G_EXTRACT, 1, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
233 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
234 for (auto Ty : {v16s8, v8s16, v4s32, v2s64}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
235 setAction({G_INSERT, 1, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
236 setAction({G_EXTRACT, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
237 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
238 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
239
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
240 void X86LegalizerInfo::setLegalizerInfoAVX2() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
241 if (!Subtarget.hasAVX2())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
242 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
243
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
244 const LLT v32s8 = LLT::vector(32, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
245 const LLT v16s16 = LLT::vector(16, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
246 const LLT v8s32 = LLT::vector(8, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
247 const LLT v4s64 = LLT::vector(4, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
248
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
249 for (unsigned BinOp : {G_ADD, G_SUB})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
250 for (auto Ty : {v32s8, v16s16, v8s32, v4s64})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
251 setAction({BinOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
252
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
253 for (auto Ty : {v16s16, v8s32})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
254 setAction({G_MUL, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
255 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
256
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
257 void X86LegalizerInfo::setLegalizerInfoAVX512() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
258 if (!Subtarget.hasAVX512())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
259 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
260
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
261 const LLT v16s8 = LLT::vector(16, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
262 const LLT v8s16 = LLT::vector(8, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
263 const LLT v4s32 = LLT::vector(4, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
264 const LLT v2s64 = LLT::vector(2, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
265
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
266 const LLT v32s8 = LLT::vector(32, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
267 const LLT v16s16 = LLT::vector(16, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
268 const LLT v8s32 = LLT::vector(8, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
269 const LLT v4s64 = LLT::vector(4, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
270
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
271 const LLT v64s8 = LLT::vector(64, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
272 const LLT v32s16 = LLT::vector(32, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
273 const LLT v16s32 = LLT::vector(16, 32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
274 const LLT v8s64 = LLT::vector(8, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
275
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
276 for (unsigned BinOp : {G_ADD, G_SUB})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
277 for (auto Ty : {v16s32, v8s64})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
278 setAction({BinOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
279
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
280 setAction({G_MUL, v16s32}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
281
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
282 for (unsigned MemOp : {G_LOAD, G_STORE})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
283 for (auto Ty : {v16s32, v8s64})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
284 setAction({MemOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
285
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
286 for (auto Ty : {v64s8, v32s16, v16s32, v8s64}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
287 setAction({G_INSERT, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
288 setAction({G_EXTRACT, 1, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
289 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
290 for (auto Ty : {v32s8, v16s16, v8s32, v4s64, v16s8, v8s16, v4s32, v2s64}) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
291 setAction({G_INSERT, 1, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
292 setAction({G_EXTRACT, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
293 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
294
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
295 /************ VLX *******************/
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
296 if (!Subtarget.hasVLX())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
297 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
298
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
299 for (auto Ty : {v4s32, v8s32})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
300 setAction({G_MUL, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
301 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
302
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
303 void X86LegalizerInfo::setLegalizerInfoAVX512DQ() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
304 if (!(Subtarget.hasAVX512() && Subtarget.hasDQI()))
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
305 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
306
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
307 const LLT v8s64 = LLT::vector(8, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
308
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
309 setAction({G_MUL, v8s64}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
310
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
311 /************ VLX *******************/
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
312 if (!Subtarget.hasVLX())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
313 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
314
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
315 const LLT v2s64 = LLT::vector(2, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
316 const LLT v4s64 = LLT::vector(4, 64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
317
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
318 for (auto Ty : {v2s64, v4s64})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
319 setAction({G_MUL, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
320 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
321
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
322 void X86LegalizerInfo::setLegalizerInfoAVX512BW() {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
323 if (!(Subtarget.hasAVX512() && Subtarget.hasBWI()))
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
324 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
325
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
326 const LLT v64s8 = LLT::vector(64, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
327 const LLT v32s16 = LLT::vector(32, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
328
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
329 for (unsigned BinOp : {G_ADD, G_SUB})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
330 for (auto Ty : {v64s8, v32s16})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
331 setAction({BinOp, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
332
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
333 setAction({G_MUL, v32s16}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
334
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
335 /************ VLX *******************/
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
336 if (!Subtarget.hasVLX())
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
337 return;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
338
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
339 const LLT v8s16 = LLT::vector(8, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
340 const LLT v16s16 = LLT::vector(16, 16);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
341
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
342 for (auto Ty : {v8s16, v16s16})
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
343 setAction({G_MUL, Ty}, Legal);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
344 }