@@ -45,20 +45,20 @@ bool WebAssemblyTargetInfo::setABI(const std::string &Name) {
4545
4646bool WebAssemblyTargetInfo::hasFeature (StringRef Feature) const {
4747 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)
5052 .Case (" half-precision" , HasHalfPrecision)
53+ .Case (" multimemory" , HasMultiMemory)
54+ .Case (" multivalue" , HasMultivalue)
55+ .Case (" mutable-globals" , HasMutableGlobals)
5156 .Case (" nontrapping-fptoint" , HasNontrappingFPToInt)
57+ .Case (" reference-types" , HasReferenceTypes)
58+ .Case (" relaxed-simd" , SIMDLevel >= RelaxedSIMD)
5259 .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)
5861 .Case (" tail-call" , HasTailCall)
59- .Case (" reference-types" , HasReferenceTypes)
60- .Case (" extended-const" , HasExtendedConst)
61- .Case (" multimemory" , HasMultiMemory)
6262 .Default (false );
6363}
6464
@@ -74,34 +74,34 @@ void WebAssemblyTargetInfo::fillValidCPUList(
7474void WebAssemblyTargetInfo::getTargetDefines (const LangOptions &Opts,
7575 MacroBuilder &Builder) const {
7676 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__" );
8977 if (HasAtomics)
9078 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__" );
9983 if (HasExtendedConst)
10084 Builder.defineMacro (" __wasm_extended_const__" );
10185 if (HasMultiMemory)
10286 Builder.defineMacro (" __wasm_multimemory__" );
10387 if (HasHalfPrecision)
10488 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__" );
105105
106106 Builder.defineMacro (" __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1" );
107107 Builder.defineMacro (" __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2" );
@@ -159,11 +159,11 @@ bool WebAssemblyTargetInfo::initFeatureMap(
159159 addGenericFeatures ();
160160 Features[" atomics" ] = true ;
161161 Features[" bulk-memory" ] = true ;
162+ Features[" half-precision" ] = true ;
162163 Features[" multimemory" ] = true ;
163164 Features[" nontrapping-fptoint" ] = true ;
164165 Features[" reference-types" ] = true ;
165166 Features[" tail-call" ] = true ;
166- Features[" half-precision" ] = true ;
167167 setSIMDLevel (Features, SIMD128, true );
168168 };
169169 if (CPU == " generic" ) {
@@ -178,36 +178,20 @@ bool WebAssemblyTargetInfo::initFeatureMap(
178178bool WebAssemblyTargetInfo::handleTargetFeatures (
179179 std::vector<std::string> &Features, DiagnosticsEngine &Diags) {
180180 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 ;
199183 continue ;
200184 }
201- if (Feature == " -nontrapping-fptoint " ) {
202- HasNontrappingFPToInt = false ;
185+ if (Feature == " -atomics " ) {
186+ HasAtomics = false ;
203187 continue ;
204188 }
205- if (Feature == " +sign-ext " ) {
206- HasSignExt = true ;
189+ if (Feature == " +bulk-memory " ) {
190+ HasBulkMemory = true ;
207191 continue ;
208192 }
209- if (Feature == " -sign-ext " ) {
210- HasSignExt = false ;
193+ if (Feature == " -bulk-memory " ) {
194+ HasBulkMemory = false ;
211195 continue ;
212196 }
213197 if (Feature == " +exception-handling" ) {
@@ -218,12 +202,12 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
218202 HasExceptionHandling = false ;
219203 continue ;
220204 }
221- if (Feature == " +bulk-memory " ) {
222- HasBulkMemory = true ;
205+ if (Feature == " +extended-const " ) {
206+ HasExtendedConst = true ;
223207 continue ;
224208 }
225- if (Feature == " -bulk-memory " ) {
226- HasBulkMemory = false ;
209+ if (Feature == " -extended-const " ) {
210+ HasExtendedConst = false ;
227211 continue ;
228212 }
229213 if (Feature == " +half-precision" ) {
@@ -235,20 +219,12 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
235219 HasHalfPrecision = false ;
236220 continue ;
237221 }
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 ;
248224 continue ;
249225 }
250- if (Feature == " -mutable-globals " ) {
251- HasMutableGlobals = false ;
226+ if (Feature == " -multimemory " ) {
227+ HasMultiMemory = false ;
252228 continue ;
253229 }
254230 if (Feature == " +multivalue" ) {
@@ -259,12 +235,20 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
259235 HasMultivalue = false ;
260236 continue ;
261237 }
262- if (Feature == " +tail-call " ) {
263- HasTailCall = true ;
238+ if (Feature == " +mutable-globals " ) {
239+ HasMutableGlobals = true ;
264240 continue ;
265241 }
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 ;
268252 continue ;
269253 }
270254 if (Feature == " +reference-types" ) {
@@ -275,20 +259,36 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
275259 HasReferenceTypes = false ;
276260 continue ;
277261 }
278- if (Feature == " +extended-const " ) {
279- HasExtendedConst = true ;
262+ if (Feature == " +relaxed-simd " ) {
263+ SIMDLevel = std::max (SIMDLevel, RelaxedSIMD) ;
280264 continue ;
281265 }
282- if (Feature == " -extended-const " ) {
283- HasExtendedConst = false ;
266+ if (Feature == " -relaxed-simd " ) {
267+ SIMDLevel = std::min (SIMDLevel, SIMDEnum (RelaxedSIMD - 1 )) ;
284268 continue ;
285269 }
286- if (Feature == " +multimemory " ) {
287- HasMultiMemory = true ;
270+ if (Feature == " +sign-ext " ) {
271+ HasSignExt = true ;
288272 continue ;
289273 }
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 ;
292292 continue ;
293293 }
294294
0 commit comments