Skip to content

Commit 32e5df8

Browse files
committed
Reorganize the CPU feature detection
Move the code from i386-rust.cc to i386-rust-and-jit.inc so that it can be reused by libgccjit.
1 parent 1c3ab85 commit 32e5df8

File tree

2 files changed

+96
-93
lines changed

2 files changed

+96
-93
lines changed

Diff for: gcc/config/i386/i386-rust-and-jit.inc

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
if (TARGET_64BIT)
2+
ADD_TARGET_INFO ("target_arch", "x86_64");
3+
else
4+
ADD_TARGET_INFO ("target_arch", "x86");
5+
6+
// features officially "stabilised" in rustc
7+
if (TARGET_MMX)
8+
ADD_TARGET_INFO ("target_feature", "mmx");
9+
if (TARGET_SSE)
10+
ADD_TARGET_INFO ("target_feature", "sse");
11+
if (TARGET_SSE2)
12+
ADD_TARGET_INFO ("target_feature", "sse2");
13+
if (TARGET_SSE3)
14+
ADD_TARGET_INFO ("target_feature", "sse3");
15+
if (TARGET_SSSE3)
16+
ADD_TARGET_INFO ("target_feature", "ssse3");
17+
if (TARGET_SSE4_1)
18+
ADD_TARGET_INFO ("target_feature", "sse4.1");
19+
if (TARGET_SSE4_2)
20+
ADD_TARGET_INFO ("target_feature", "sse4.2");
21+
if (TARGET_AES)
22+
ADD_TARGET_INFO ("target_feature", "aes");
23+
if (TARGET_SHA)
24+
ADD_TARGET_INFO ("target_feature", "sha");
25+
if (TARGET_AVX)
26+
ADD_TARGET_INFO ("target_feature", "avx");
27+
if (TARGET_AVX2)
28+
ADD_TARGET_INFO ("target_feature", "avx2");
29+
if (TARGET_AVX512F)
30+
ADD_TARGET_INFO ("target_feature", "avx512f");
31+
if (TARGET_AVX512CD)
32+
ADD_TARGET_INFO ("target_feature", "avx512cd");
33+
if (TARGET_AVX512DQ)
34+
ADD_TARGET_INFO ("target_feature", "avx512dq");
35+
if (TARGET_AVX512BW)
36+
ADD_TARGET_INFO ("target_feature", "avx512bw");
37+
if (TARGET_AVX512VL)
38+
ADD_TARGET_INFO ("target_feature", "avx512vl");
39+
if (TARGET_AVX512VBMI)
40+
ADD_TARGET_INFO ("target_feature", "avx512vbmi");
41+
if (TARGET_AVX512IFMA)
42+
ADD_TARGET_INFO ("target_feature", "avx512ifma");
43+
if (TARGET_AVX512VPOPCNTDQ)
44+
ADD_TARGET_INFO ("target_feature", "avx512vpopcntdq");
45+
if (TARGET_FMA)
46+
ADD_TARGET_INFO ("target_feature", "fma");
47+
if (TARGET_RTM)
48+
ADD_TARGET_INFO ("target_feature", "rtm");
49+
if (TARGET_SSE4A)
50+
ADD_TARGET_INFO ("target_feature", "sse4a");
51+
if (TARGET_BMI)
52+
{
53+
ADD_TARGET_INFO ("target_feature", "bmi1");
54+
ADD_TARGET_INFO ("target_feature", "bmi");
55+
}
56+
if (TARGET_BMI2)
57+
ADD_TARGET_INFO ("target_feature", "bmi2");
58+
if (TARGET_LZCNT)
59+
ADD_TARGET_INFO ("target_feature", "lzcnt");
60+
if (TARGET_TBM)
61+
ADD_TARGET_INFO ("target_feature", "tbm");
62+
if (TARGET_POPCNT)
63+
ADD_TARGET_INFO ("target_feature", "popcnt");
64+
if (TARGET_RDRND)
65+
{
66+
ADD_TARGET_INFO ("target_feature", "rdrand");
67+
ADD_TARGET_INFO ("target_feature", "rdrnd");
68+
}
69+
if (TARGET_F16C)
70+
ADD_TARGET_INFO ("target_feature", "f16c");
71+
if (TARGET_RDSEED)
72+
ADD_TARGET_INFO ("target_feature", "rdseed");
73+
if (TARGET_ADX)
74+
ADD_TARGET_INFO ("target_feature", "adx");
75+
if (TARGET_FXSR)
76+
ADD_TARGET_INFO ("target_feature", "fxsr");
77+
if (TARGET_XSAVE)
78+
ADD_TARGET_INFO ("target_feature", "xsave");
79+
if (TARGET_XSAVEOPT)
80+
ADD_TARGET_INFO ("target_feature", "xsaveopt");
81+
if (TARGET_XSAVEC)
82+
ADD_TARGET_INFO ("target_feature", "xsavec");
83+
if (TARGET_XSAVES)
84+
ADD_TARGET_INFO ("target_feature", "xsaves");
85+
if (TARGET_VPCLMULQDQ)
86+
{
87+
ADD_TARGET_INFO ("target_feature", "pclmulqdq");
88+
ADD_TARGET_INFO ("target_feature", "vpclmulqdq");
89+
}
90+
if (TARGET_CMPXCHG16B)
91+
ADD_TARGET_INFO ("target_feature", "cmpxchg16b");
92+
if (TARGET_MOVBE)
93+
ADD_TARGET_INFO ("target_feature", "movbe");

Diff for: gcc/config/i386/i386-rust.cc

+3-93
Original file line numberDiff line numberDiff line change
@@ -29,97 +29,7 @@ along with GCC; see the file COPYING3. If not see
2929
void
3030
ix86_rust_target_cpu_info (void)
3131
{
32-
if (TARGET_64BIT)
33-
rust_add_target_info ("target_arch", "x86_64");
34-
else
35-
rust_add_target_info ("target_arch", "x86");
36-
37-
// features officially "stabilised" in rustc
38-
if (TARGET_MMX)
39-
rust_add_target_info ("target_feature", "mmx");
40-
if (TARGET_SSE)
41-
rust_add_target_info ("target_feature", "sse");
42-
if (TARGET_SSE2)
43-
rust_add_target_info ("target_feature", "sse2");
44-
if (TARGET_SSE3)
45-
rust_add_target_info ("target_feature", "sse3");
46-
if (TARGET_SSSE3)
47-
rust_add_target_info ("target_feature", "ssse3");
48-
if (TARGET_SSE4_1)
49-
rust_add_target_info ("target_feature", "sse4.1");
50-
if (TARGET_SSE4_2)
51-
rust_add_target_info ("target_feature", "sse4.2");
52-
if (TARGET_AES)
53-
rust_add_target_info ("target_feature", "aes");
54-
if (TARGET_SHA)
55-
rust_add_target_info ("target_feature", "sha");
56-
if (TARGET_AVX)
57-
rust_add_target_info ("target_feature", "avx");
58-
if (TARGET_AVX2)
59-
rust_add_target_info ("target_feature", "avx2");
60-
if (TARGET_AVX512F)
61-
rust_add_target_info ("target_feature", "avx512f");
62-
if (TARGET_AVX512CD)
63-
rust_add_target_info ("target_feature", "avx512cd");
64-
if (TARGET_AVX512DQ)
65-
rust_add_target_info ("target_feature", "avx512dq");
66-
if (TARGET_AVX512BW)
67-
rust_add_target_info ("target_feature", "avx512bw");
68-
if (TARGET_AVX512VL)
69-
rust_add_target_info ("target_feature", "avx512vl");
70-
if (TARGET_AVX512VBMI)
71-
rust_add_target_info ("target_feature", "avx512vbmi");
72-
if (TARGET_AVX512IFMA)
73-
rust_add_target_info ("target_feature", "avx512ifma");
74-
if (TARGET_AVX512VPOPCNTDQ)
75-
rust_add_target_info ("target_feature", "avx512vpopcntdq");
76-
if (TARGET_FMA)
77-
rust_add_target_info ("target_feature", "fma");
78-
if (TARGET_RTM)
79-
rust_add_target_info ("target_feature", "rtm");
80-
if (TARGET_SSE4A)
81-
rust_add_target_info ("target_feature", "sse4a");
82-
if (TARGET_BMI)
83-
{
84-
rust_add_target_info ("target_feature", "bmi1");
85-
rust_add_target_info ("target_feature", "bmi");
86-
}
87-
if (TARGET_BMI2)
88-
rust_add_target_info ("target_feature", "bmi2");
89-
if (TARGET_LZCNT)
90-
rust_add_target_info ("target_feature", "lzcnt");
91-
if (TARGET_TBM)
92-
rust_add_target_info ("target_feature", "tbm");
93-
if (TARGET_POPCNT)
94-
rust_add_target_info ("target_feature", "popcnt");
95-
if (TARGET_RDRND)
96-
{
97-
rust_add_target_info ("target_feature", "rdrand");
98-
rust_add_target_info ("target_feature", "rdrnd");
99-
}
100-
if (TARGET_F16C)
101-
rust_add_target_info ("target_feature", "f16c");
102-
if (TARGET_RDSEED)
103-
rust_add_target_info ("target_feature", "rdseed");
104-
if (TARGET_ADX)
105-
rust_add_target_info ("target_feature", "adx");
106-
if (TARGET_FXSR)
107-
rust_add_target_info ("target_feature", "fxsr");
108-
if (TARGET_XSAVE)
109-
rust_add_target_info ("target_feature", "xsave");
110-
if (TARGET_XSAVEOPT)
111-
rust_add_target_info ("target_feature", "xsaveopt");
112-
if (TARGET_XSAVEC)
113-
rust_add_target_info ("target_feature", "xsavec");
114-
if (TARGET_XSAVES)
115-
rust_add_target_info ("target_feature", "xsaves");
116-
if (TARGET_VPCLMULQDQ)
117-
{
118-
rust_add_target_info ("target_feature", "pclmulqdq");
119-
rust_add_target_info ("target_feature", "vpclmulqdq");
120-
}
121-
if (TARGET_CMPXCHG16B)
122-
rust_add_target_info ("target_feature", "cmpxchg16b");
123-
if (TARGET_MOVBE)
124-
rust_add_target_info ("target_feature", "movbe");
32+
#define ADD_TARGET_INFO rust_add_target_info
33+
#include "i386-rust-and-jit.inc"
34+
#undef ADD_TARGET_INFO
12535
}

0 commit comments

Comments
 (0)