Skip to content

Commit 53dfdf7

Browse files
authored
[X86] BuiltinsX86.td - attempt to pack the builtins for each SSE level close together. NFC. (#168844)
Avoid some repeated feature blocks - we should have a single place in each file that we can find most builtins for a particular ISA level. Also, avoid some of the 80col wrapping that just makes it harder to find anything at all. There's a lot more we can do - but I don't want to completely refactor this while we still have so much work to do for #30794
1 parent 95d788c commit 53dfdf7

File tree

1 file changed

+27
-64
lines changed

1 file changed

+27
-64
lines changed

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 27 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -91,42 +91,6 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
9191
def cmppd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant char)">;
9292
def cmpsd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant char)">;
9393
}
94-
95-
let Features = "sse3",
96-
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
97-
foreach Op = ["addsub"] in {
98-
def Op#ps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>)">;
99-
def Op#pd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>)">;
100-
}
101-
}
102-
103-
let Features = "sse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
104-
foreach Op = ["hadd", "hsub"] in {
105-
def Op#ps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>)">;
106-
def Op#pd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>)">;
107-
}
108-
}
109-
110-
let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
111-
def psignb128
112-
: X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
113-
def psignw128
114-
: X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
115-
def psignd128
116-
: X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>)">;
117-
def pmulhrsw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
118-
def pmaddubsw128 : X86Builtin<"_Vector<8, short>(_Vector<16, char>, _Vector<16, char>)">;
119-
def pshufb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
120-
}
121-
}
122-
123-
// AVX
124-
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>],
125-
Features = "avx" in {
126-
foreach Op = ["max", "min"] in {
127-
def Op#pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
128-
def Op#ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
129-
}
13094
}
13195

13296
let Features = "mmx", Header = "mmintrin.h", Attributes = [NoThrow, Const] in {
@@ -312,11 +276,22 @@ let Features = "sse3", Attributes = [NoThrow, RequiredVectorWidth<128>] in {
312276
def lddqu : X86Builtin<"_Vector<16, char>(char const *)">;
313277
}
314278

315-
let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
316-
def palignr128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Constant int)">;
279+
let Features = "sse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
280+
foreach Op = ["addsub", "hadd", "hsub"] in {
281+
def Op#ps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>)">;
282+
def Op#pd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>)">;
283+
}
317284
}
318285

319286
let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
287+
def palignr128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Constant int)">;
288+
def pmulhrsw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
289+
def pmaddubsw128 : X86Builtin<"_Vector<8, short>(_Vector<16, char>, _Vector<16, char>)">;
290+
def pshufb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
291+
def psignb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
292+
def psignw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
293+
def psignd128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>)">;
294+
320295
foreach Op = ["phadd", "phsub"] in {
321296
def Op#w128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
322297
def Op#sw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
@@ -330,25 +305,13 @@ let Features = "sse4.1", Attributes = [NoThrow, Const, RequiredVectorWidth<128>]
330305
def roundsd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant int)">;
331306
def roundpd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Constant int)">;
332307
def dpps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant char)">;
333-
def dppd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, "
334-
"_Vector<2,double>, _Constant char)">;
335-
def mpsadbw128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, "
336-
"_Vector<16, char>, _Constant char)">;
337-
}
338-
339-
let Features = "sse4.1",
340-
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
341-
def insertps128 : X86Builtin<"_Vector<4, float>(_Vector<4, float>, "
342-
"_Vector<4, float>, _Constant char)">;
343-
def ptestz128
344-
: X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
345-
def ptestc128
346-
: X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
347-
def ptestnzc128
348-
: X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
308+
def dppd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2,double>, _Constant char)">;
309+
def mpsadbw128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>, _Constant char)">;
349310
}
350311

351312
let Features = "sse4.1", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
313+
def insertps128 : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant char)">;
314+
352315
def pblendw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>, _Constant int)">;
353316
def blendpd : X86Builtin<"_Vector<2, double>(_Vector<2, double>, _Vector<2, double>, _Constant int)">;
354317
def blendps : X86Builtin<"_Vector<4, float>(_Vector<4, float>, _Vector<4, float>, _Constant int)">;
@@ -360,6 +323,10 @@ let Features = "sse4.1", Attributes = [NoThrow, Const, Constexpr, RequiredVector
360323
def packusdw128 : X86Builtin<"_Vector<8, short>(_Vector<4, int>, _Vector<4, int>)">;
361324
def phminposuw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>)">;
362325

326+
def ptestz128 : X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
327+
def ptestc128 : X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
328+
def ptestnzc128 : X86Builtin<"int(_Vector<2, long long int>, _Vector<2, long long int>)">;
329+
363330
def vec_ext_v16qi : X86Builtin<"char(_Vector<16, char>, _Constant int)">;
364331
def vec_set_v16qi : X86Builtin<"_Vector<16, char>(_Vector<16, char>, char, _Constant int)">;
365332
def vec_set_v4si : X86Builtin<"_Vector<4, int>(_Vector<4, int>, int, _Constant int)">;
@@ -510,6 +477,11 @@ let Features = "avx", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in
510477
def vperm2f128_pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>, _Constant int)">;
511478
def vperm2f128_ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>, _Constant int)">;
512479
def vperm2f128_si256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>, _Constant int)">;
480+
481+
foreach Op = ["max", "min"] in {
482+
def Op#pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
483+
def Op#ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
484+
}
513485
}
514486

515487
let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
@@ -531,7 +503,7 @@ let Features = "avx", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWid
531503
def vpermilpd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Constant int)">;
532504
def vpermilps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Constant int)">;
533505

534-
foreach Op = ["hadd", "hsub"] in {
506+
foreach Op = ["addsub", "hadd", "hsub"] in {
535507
def Op#pd256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
536508
def Op#ps256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
537509
}
@@ -572,15 +544,6 @@ let Features = "avx",
572544
def movmskps256 : X86Builtin<"int(_Vector<8, float>)">;
573545
}
574546

575-
let Features = "avx",
576-
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
577-
def addsubpd256
578-
: X86Builtin<
579-
"_Vector<4, double>(_Vector<4, double>, _Vector<4, double>)">;
580-
def addsubps256
581-
: X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, float>)">;
582-
}
583-
584547
let Features = "avx", Attributes = [NoThrow] in {
585548
def vzeroall : X86Builtin<"void()">;
586549
def vzeroupper : X86Builtin<"void()">;

0 commit comments

Comments
 (0)