Author: aheejin Date: Tue Feb 5 17:41:26 2019 New Revision: 353260 URL: http://llvm.org/viewvc/llvm-project?rev=353260&view=rev Log: [WebAssembly] Add atomics target option
Reviewers: tlively Subscribers: dschuff, sbc100, jgravelle-google, sunfish, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57798 Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/Targets/WebAssembly.cpp cfe/trunk/lib/Basic/Targets/WebAssembly.h cfe/trunk/test/Preprocessor/wasm-target-features.c Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=353260&r1=353259&r2=353260&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Feb 5 17:41:26 2019 @@ -2160,6 +2160,8 @@ def mexception_handing : Flag<["-"], "me def mno_exception_handing : Flag<["-"], "mno-exception-handling">, Group<m_wasm_Features_Group>; def mbulk_memory : Flag<["-"], "mbulk-memory">, Group<m_wasm_Features_Group>; def mno_bulk_memory : Flag<["-"], "mno-bulk-memory">, Group<m_wasm_Features_Group>; +def matomics : Flag<["-"], "matomics">, Group<m_wasm_Features_Group>; +def mno_atomics : Flag<["-"], "mno-atomics">, Group<m_wasm_Features_Group>; def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">, Flags<[HelpHidden]>, Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.cpp?rev=353260&r1=353259&r2=353260&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp (original) +++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp Tue Feb 5 17:41:26 2019 @@ -41,6 +41,7 @@ bool WebAssemblyTargetInfo::hasFeature(S .Case("sign-ext", HasSignExt) .Case("exception-handling", HasExceptionHandling) .Case("bulk-memory", HasBulkMemory) + .Case("atomics", HasAtomics) .Default(false); } @@ -68,6 +69,8 @@ void WebAssemblyTargetInfo::getTargetDef Builder.defineMacro("__wasm_exception_handling__"); if (HasBulkMemory) Builder.defineMacro("__wasm_bulk_memory__"); + if (HasAtomics) + Builder.defineMacro("__wasm_atomics__"); } void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features, @@ -90,6 +93,7 @@ bool WebAssemblyTargetInfo::initFeatureM if (CPU == "bleeding-edge") { Features["nontrapping-fptoint"] = true; Features["sign-ext"] = true; + Features["atomics"] = true; setSIMDLevel(Features, SIMD128); } // Other targets do not consider user-configured features here, but while we @@ -104,6 +108,8 @@ bool WebAssemblyTargetInfo::initFeatureM Features["exception-handling"] = true; if (HasBulkMemory) Features["bulk-memory"] = true; + if (HasAtomics) + Features["atomics"] = true; return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); } @@ -159,6 +165,14 @@ bool WebAssemblyTargetInfo::handleTarget HasBulkMemory = false; continue; } + if (Feature == "+atomics") { + HasAtomics = true; + continue; + } + if (Feature == "-atomics") { + HasAtomics = false; + continue; + } Diags.Report(diag::err_opt_not_valid_with_opt) << Feature << "-target-feature"; Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.h?rev=353260&r1=353259&r2=353260&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/WebAssembly.h (original) +++ cfe/trunk/lib/Basic/Targets/WebAssembly.h Tue Feb 5 17:41:26 2019 @@ -34,6 +34,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl bool HasSignExt = false; bool HasExceptionHandling = false; bool HasBulkMemory = false; + bool HasAtomics = false; public: explicit WebAssemblyTargetInfo(const llvm::Triple &T, const TargetOptions &) Modified: cfe/trunk/test/Preprocessor/wasm-target-features.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/wasm-target-features.c?rev=353260&r1=353259&r2=353260&view=diff ============================================================================== --- cfe/trunk/test/Preprocessor/wasm-target-features.c (original) +++ cfe/trunk/test/Preprocessor/wasm-target-features.c Tue Feb 5 17:41:26 2019 @@ -53,6 +53,15 @@ // BULK-MEMORY:#define __wasm_bulk_memory__ 1{{$}} // // RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target wasm32-unknown-unknown -matomics \ +// RUN: | FileCheck %s -check-prefix=ATOMICS +// RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target wasm64-unknown-unknown -matomics \ +// RUN: | FileCheck %s -check-prefix=ATOMICS +// +// ATOMICS:#define __wasm_atomics__ 1{{$}} +// +// RUN: %clang -E -dM %s -o - 2>&1 \ // RUN: -target wasm32-unknown-unknown -mcpu=mvp \ // RUN: | FileCheck %s -check-prefix=MVP // RUN: %clang -E -dM %s -o - 2>&1 \ @@ -65,6 +74,7 @@ // MVP-NOT:#define __wasm_sign_ext__ // MVP-NOT:#define __wasm_exception_handling__ // MVP-NOT:#define __wasm_bulk_memory__ +// MVP-NOT:#define __wasm_atomics__ // // RUN: %clang -E -dM %s -o - 2>&1 \ // RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge \ @@ -73,9 +83,10 @@ // RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge \ // RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE // -// BLEEDING-EDGE:#define __wasm_nontrapping_fptoint__ 1{{$}} -// BLEEDING-EDGE:#define __wasm_sign_ext__ 1{{$}} -// BLEEDING-EDGE:#define __wasm_simd128__ 1{{$}} +// BLEEDING-EDGE-DAG:#define __wasm_nontrapping_fptoint__ 1{{$}} +// BLEEDING-EDGE-DAG:#define __wasm_sign_ext__ 1{{$}} +// BLEEDING-EDGE-DAG:#define __wasm_simd128__ 1{{$}} +// BLEEDING-EDGE-DAG:#define __wasm_atomics__ 1{{$}} // BLEEDING-EDGE-NOT:#define __wasm_unimplemented_simd128__ 1{{$}} // // RUN: %clang -E -dM %s -o - 2>&1 \ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits