@@ -45,20 +45,20 @@ bool WebAssemblyTargetInfo::setABI(const std::string &Name) {
45
45
46
46
bool WebAssemblyTargetInfo::hasFeature (StringRef Feature) const {
47
47
return llvm::StringSwitch<bool >(Feature)
48
- .Case (" simd128" , SIMDLevel >= SIMD128)
49
- .Case (" relaxed-simd" , SIMDLevel >= RelaxedSIMD)
48
+ .Case (" atomics" , HasAtomics)
49
+ .Case (" bulk-memory" , HasBulkMemory)
50
+ .Case (" exception-handling" , HasExceptionHandling)
51
+ .Case (" extended-const" , HasExtendedConst)
50
52
.Case (" half-precision" , HasHalfPrecision)
53
+ .Case (" multimemory" , HasMultiMemory)
54
+ .Case (" multivalue" , HasMultivalue)
55
+ .Case (" mutable-globals" , HasMutableGlobals)
51
56
.Case (" nontrapping-fptoint" , HasNontrappingFPToInt)
57
+ .Case (" reference-types" , HasReferenceTypes)
58
+ .Case (" relaxed-simd" , SIMDLevel >= RelaxedSIMD)
52
59
.Case (" sign-ext" , HasSignExt)
53
- .Case (" exception-handling" , HasExceptionHandling)
54
- .Case (" bulk-memory" , HasBulkMemory)
55
- .Case (" atomics" , HasAtomics)
56
- .Case (" mutable-globals" , HasMutableGlobals)
57
- .Case (" multivalue" , HasMultivalue)
60
+ .Case (" simd128" , SIMDLevel >= SIMD128)
58
61
.Case (" tail-call" , HasTailCall)
59
- .Case (" reference-types" , HasReferenceTypes)
60
- .Case (" extended-const" , HasExtendedConst)
61
- .Case (" multimemory" , HasMultiMemory)
62
62
.Default (false );
63
63
}
64
64
@@ -74,34 +74,34 @@ void WebAssemblyTargetInfo::fillValidCPUList(
74
74
void WebAssemblyTargetInfo::getTargetDefines (const LangOptions &Opts,
75
75
MacroBuilder &Builder) const {
76
76
defineCPUMacros (Builder, " wasm" , /* Tuning=*/ false );
77
- if (SIMDLevel >= SIMD128)
78
- Builder.defineMacro (" __wasm_simd128__" );
79
- if (SIMDLevel >= RelaxedSIMD)
80
- Builder.defineMacro (" __wasm_relaxed_simd__" );
81
- if (HasNontrappingFPToInt)
82
- Builder.defineMacro (" __wasm_nontrapping_fptoint__" );
83
- if (HasSignExt)
84
- Builder.defineMacro (" __wasm_sign_ext__" );
85
- if (HasExceptionHandling)
86
- Builder.defineMacro (" __wasm_exception_handling__" );
87
- if (HasBulkMemory)
88
- Builder.defineMacro (" __wasm_bulk_memory__" );
89
77
if (HasAtomics)
90
78
Builder.defineMacro (" __wasm_atomics__" );
91
- if (HasMutableGlobals)
92
- Builder.defineMacro (" __wasm_mutable_globals__" );
93
- if (HasMultivalue)
94
- Builder.defineMacro (" __wasm_multivalue__" );
95
- if (HasTailCall)
96
- Builder.defineMacro (" __wasm_tail_call__" );
97
- if (HasReferenceTypes)
98
- Builder.defineMacro (" __wasm_reference_types__" );
79
+ if (HasBulkMemory)
80
+ Builder.defineMacro (" __wasm_bulk_memory__" );
81
+ if (HasExceptionHandling)
82
+ Builder.defineMacro (" __wasm_exception_handling__" );
99
83
if (HasExtendedConst)
100
84
Builder.defineMacro (" __wasm_extended_const__" );
101
85
if (HasMultiMemory)
102
86
Builder.defineMacro (" __wasm_multimemory__" );
103
87
if (HasHalfPrecision)
104
88
Builder.defineMacro (" __wasm_half_precision__" );
89
+ if (HasMultivalue)
90
+ Builder.defineMacro (" __wasm_multivalue__" );
91
+ if (HasMutableGlobals)
92
+ Builder.defineMacro (" __wasm_mutable_globals__" );
93
+ if (HasNontrappingFPToInt)
94
+ Builder.defineMacro (" __wasm_nontrapping_fptoint__" );
95
+ if (HasReferenceTypes)
96
+ Builder.defineMacro (" __wasm_reference_types__" );
97
+ if (SIMDLevel >= RelaxedSIMD)
98
+ Builder.defineMacro (" __wasm_relaxed_simd__" );
99
+ if (HasSignExt)
100
+ Builder.defineMacro (" __wasm_sign_ext__" );
101
+ if (SIMDLevel >= SIMD128)
102
+ Builder.defineMacro (" __wasm_simd128__" );
103
+ if (HasTailCall)
104
+ Builder.defineMacro (" __wasm_tail_call__" );
105
105
106
106
Builder.defineMacro (" __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1" );
107
107
Builder.defineMacro (" __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2" );
@@ -159,11 +159,11 @@ bool WebAssemblyTargetInfo::initFeatureMap(
159
159
addGenericFeatures ();
160
160
Features[" atomics" ] = true ;
161
161
Features[" bulk-memory" ] = true ;
162
+ Features[" half-precision" ] = true ;
162
163
Features[" multimemory" ] = true ;
163
164
Features[" nontrapping-fptoint" ] = true ;
164
165
Features[" reference-types" ] = true ;
165
166
Features[" tail-call" ] = true ;
166
- Features[" half-precision" ] = true ;
167
167
setSIMDLevel (Features, SIMD128, true );
168
168
};
169
169
if (CPU == " generic" ) {
@@ -178,36 +178,20 @@ bool WebAssemblyTargetInfo::initFeatureMap(
178
178
bool WebAssemblyTargetInfo::handleTargetFeatures (
179
179
std::vector<std::string> &Features, DiagnosticsEngine &Diags) {
180
180
for (const auto &Feature : Features) {
181
- if (Feature == " +simd128" ) {
182
- SIMDLevel = std::max (SIMDLevel, SIMD128);
183
- continue ;
184
- }
185
- if (Feature == " -simd128" ) {
186
- SIMDLevel = std::min (SIMDLevel, SIMDEnum (SIMD128 - 1 ));
187
- continue ;
188
- }
189
- if (Feature == " +relaxed-simd" ) {
190
- SIMDLevel = std::max (SIMDLevel, RelaxedSIMD);
191
- continue ;
192
- }
193
- if (Feature == " -relaxed-simd" ) {
194
- SIMDLevel = std::min (SIMDLevel, SIMDEnum (RelaxedSIMD - 1 ));
195
- continue ;
196
- }
197
- if (Feature == " +nontrapping-fptoint" ) {
198
- HasNontrappingFPToInt = true ;
181
+ if (Feature == " +atomics" ) {
182
+ HasAtomics = true ;
199
183
continue ;
200
184
}
201
- if (Feature == " -nontrapping-fptoint " ) {
202
- HasNontrappingFPToInt = false ;
185
+ if (Feature == " -atomics " ) {
186
+ HasAtomics = false ;
203
187
continue ;
204
188
}
205
- if (Feature == " +sign-ext " ) {
206
- HasSignExt = true ;
189
+ if (Feature == " +bulk-memory " ) {
190
+ HasBulkMemory = true ;
207
191
continue ;
208
192
}
209
- if (Feature == " -sign-ext " ) {
210
- HasSignExt = false ;
193
+ if (Feature == " -bulk-memory " ) {
194
+ HasBulkMemory = false ;
211
195
continue ;
212
196
}
213
197
if (Feature == " +exception-handling" ) {
@@ -218,12 +202,12 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
218
202
HasExceptionHandling = false ;
219
203
continue ;
220
204
}
221
- if (Feature == " +bulk-memory " ) {
222
- HasBulkMemory = true ;
205
+ if (Feature == " +extended-const " ) {
206
+ HasExtendedConst = true ;
223
207
continue ;
224
208
}
225
- if (Feature == " -bulk-memory " ) {
226
- HasBulkMemory = false ;
209
+ if (Feature == " -extended-const " ) {
210
+ HasExtendedConst = false ;
227
211
continue ;
228
212
}
229
213
if (Feature == " +half-precision" ) {
@@ -235,20 +219,12 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
235
219
HasHalfPrecision = false ;
236
220
continue ;
237
221
}
238
- if (Feature == " +atomics" ) {
239
- HasAtomics = true ;
240
- continue ;
241
- }
242
- if (Feature == " -atomics" ) {
243
- HasAtomics = false ;
244
- continue ;
245
- }
246
- if (Feature == " +mutable-globals" ) {
247
- HasMutableGlobals = true ;
222
+ if (Feature == " +multimemory" ) {
223
+ HasMultiMemory = true ;
248
224
continue ;
249
225
}
250
- if (Feature == " -mutable-globals " ) {
251
- HasMutableGlobals = false ;
226
+ if (Feature == " -multimemory " ) {
227
+ HasMultiMemory = false ;
252
228
continue ;
253
229
}
254
230
if (Feature == " +multivalue" ) {
@@ -259,12 +235,20 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
259
235
HasMultivalue = false ;
260
236
continue ;
261
237
}
262
- if (Feature == " +tail-call " ) {
263
- HasTailCall = true ;
238
+ if (Feature == " +mutable-globals " ) {
239
+ HasMutableGlobals = true ;
264
240
continue ;
265
241
}
266
- if (Feature == " -tail-call" ) {
267
- HasTailCall = false ;
242
+ if (Feature == " -mutable-globals" ) {
243
+ HasMutableGlobals = false ;
244
+ continue ;
245
+ }
246
+ if (Feature == " +nontrapping-fptoint" ) {
247
+ HasNontrappingFPToInt = true ;
248
+ continue ;
249
+ }
250
+ if (Feature == " -nontrapping-fptoint" ) {
251
+ HasNontrappingFPToInt = false ;
268
252
continue ;
269
253
}
270
254
if (Feature == " +reference-types" ) {
@@ -275,20 +259,36 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
275
259
HasReferenceTypes = false ;
276
260
continue ;
277
261
}
278
- if (Feature == " +extended-const " ) {
279
- HasExtendedConst = true ;
262
+ if (Feature == " +relaxed-simd " ) {
263
+ SIMDLevel = std::max (SIMDLevel, RelaxedSIMD) ;
280
264
continue ;
281
265
}
282
- if (Feature == " -extended-const " ) {
283
- HasExtendedConst = false ;
266
+ if (Feature == " -relaxed-simd " ) {
267
+ SIMDLevel = std::min (SIMDLevel, SIMDEnum (RelaxedSIMD - 1 )) ;
284
268
continue ;
285
269
}
286
- if (Feature == " +multimemory " ) {
287
- HasMultiMemory = true ;
270
+ if (Feature == " +sign-ext " ) {
271
+ HasSignExt = true ;
288
272
continue ;
289
273
}
290
- if (Feature == " -multimemory" ) {
291
- HasMultiMemory = false ;
274
+ if (Feature == " -sign-ext" ) {
275
+ HasSignExt = false ;
276
+ continue ;
277
+ }
278
+ if (Feature == " +simd128" ) {
279
+ SIMDLevel = std::max (SIMDLevel, SIMD128);
280
+ continue ;
281
+ }
282
+ if (Feature == " -simd128" ) {
283
+ SIMDLevel = std::min (SIMDLevel, SIMDEnum (SIMD128 - 1 ));
284
+ continue ;
285
+ }
286
+ if (Feature == " +tail-call" ) {
287
+ HasTailCall = true ;
288
+ continue ;
289
+ }
290
+ if (Feature == " -tail-call" ) {
291
+ HasTailCall = false ;
292
292
continue ;
293
293
}
294
294
0 commit comments