r352793 - [WebAssembly] Add bulk memory target feature
Thomas Lively via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 31 13:02:20 PST 2019
Author: tlively
Date: Thu Jan 31 13:02:19 2019
New Revision: 352793
URL: http://llvm.org/viewvc/llvm-project?rev=352793&view=rev
Log:
[WebAssembly] Add bulk memory target feature
Summary: Also clean up some preexisting target feature code.
Reviewers: aheejin
Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, jfb
Differential Revision: https://reviews.llvm.org/D57495
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=352793&r1=352792&r2=352793&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Jan 31 13:02:19 2019
@@ -2155,6 +2155,8 @@ def msign_ext : Flag<["-"], "msign-ext">
def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group<m_wasm_Features_Group>;
def mexception_handing : Flag<["-"], "mexception-handling">, Group<m_wasm_Features_Group>;
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 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=352793&r1=352792&r2=352793&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp Thu Jan 31 13:02:19 2019
@@ -40,6 +40,7 @@ bool WebAssemblyTargetInfo::hasFeature(S
.Case("nontrapping-fptoint", HasNontrappingFPToInt)
.Case("sign-ext", HasSignExt)
.Case("exception-handling", HasExceptionHandling)
+ .Case("bulk-memory", HasBulkMemory)
.Default(false);
}
@@ -59,6 +60,14 @@ void WebAssemblyTargetInfo::getTargetDef
Builder.defineMacro("__wasm_simd128__");
if (SIMDLevel >= UnimplementedSIMD128)
Builder.defineMacro("__wasm_unimplemented_simd128__");
+ if (HasNontrappingFPToInt)
+ Builder.defineMacro("__wasm_nontrapping_fptoint__");
+ if (HasSignExt)
+ Builder.defineMacro("__wasm_sign_ext__");
+ if (HasExceptionHandling)
+ Builder.defineMacro("__wasm_exception_handling__");
+ if (HasBulkMemory)
+ Builder.defineMacro("__wasm_bulk_memory__");
}
void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features,
@@ -93,6 +102,8 @@ bool WebAssemblyTargetInfo::initFeatureM
Features["sign-ext"] = true;
if (HasExceptionHandling)
Features["exception-handling"] = true;
+ if (HasBulkMemory)
+ Features["bulk-memory"] = true;
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
@@ -140,6 +151,14 @@ bool WebAssemblyTargetInfo::handleTarget
HasExceptionHandling = false;
continue;
}
+ if (Feature == "+bulk-memory") {
+ HasBulkMemory = true;
+ continue;
+ }
+ if (Feature == "-bulk-memory") {
+ HasBulkMemory = 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=352793&r1=352792&r2=352793&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/WebAssembly.h (original)
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.h Thu Jan 31 13:02:19 2019
@@ -30,14 +30,14 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl
UnimplementedSIMD128,
} SIMDLevel = NoSIMD;
- bool HasNontrappingFPToInt;
- bool HasSignExt;
- bool HasExceptionHandling;
+ bool HasNontrappingFPToInt = false;
+ bool HasSignExt = false;
+ bool HasExceptionHandling = false;
+ bool HasBulkMemory = false;
public:
explicit WebAssemblyTargetInfo(const llvm::Triple &T, const TargetOptions &)
- : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
- HasSignExt(false), HasExceptionHandling(false) {
+ : TargetInfo(T) {
NoAsmVariants = true;
SuitableAlign = 128;
LargeArrayMinWidth = 128;
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=352793&r1=352792&r2=352793&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/wasm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/wasm-target-features.c Thu Jan 31 13:02:19 2019
@@ -17,6 +17,42 @@
// SIMD128-UNIMPLEMENTED:#define __wasm_unimplemented_simd128__ 1{{$}}
//
// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mnontrapping-fptoint \
+// RUN: | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mnontrapping-fptoint \
+// RUN: | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
+//
+// NONTRAPPING-FPTOINT:#define __wasm_nontrapping_fptoint__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -msign-ext \
+// RUN: | FileCheck %s -check-prefix=SIGN-EXT
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -msign-ext \
+// RUN: | FileCheck %s -check-prefix=SIGN-EXT
+//
+// SIGN-EXT:#define __wasm_sign_ext__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mexception-handling \
+// RUN: | FileCheck %s -check-prefix=EXCEPTION-HANDLING
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mexception-handling \
+// RUN: | FileCheck %s -check-prefix=EXCEPTION-HANDLING
+//
+// EXCEPTION-HANDLING:#define __wasm_exception_handling__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mbulk-memory \
+// RUN: | FileCheck %s -check-prefix=BULK-MEMORY
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mbulk-memory \
+// RUN: | FileCheck %s -check-prefix=BULK-MEMORY
+//
+// BULK-MEMORY:#define __wasm_bulk_memory__ 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 \
@@ -24,21 +60,29 @@
// RUN: | FileCheck %s -check-prefix=MVP
//
// MVP-NOT:#define __wasm_simd128__
+// MVP-NOT:#define __wasm_unimplemented_simd128__
+// MVP-NOT:#define __wasm_nontrapping_fptoint__
+// MVP-NOT:#define __wasm_sign_ext__
+// MVP-NOT:#define __wasm_exception_handling__
+// MVP-NOT:#define __wasm_bulk_memory__
//
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge \
-// RUN: | FileCheck %s -check-prefix=BLEEDING_EDGE
+// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge \
-// RUN: | FileCheck %s -check-prefix=BLEEDING_EDGE
+// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE
//
-// BLEEDING_EDGE:#define __wasm_simd128__ 1{{$}}
+// BLEEDING-EDGE:#define __wasm_nontrapping_fptoint__ 1{{$}}
+// BLEEDING-EDGE:#define __wasm_sign_ext__ 1{{$}}
+// BLEEDING-EDGE:#define __wasm_simd128__ 1{{$}}
+// BLEEDING-EDGE-NOT:#define __wasm_unimplemented_simd128__ 1{{$}}
//
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
-// RUN: | FileCheck %s -check-prefix=BLEEDING_EDGE_NO_SIMD128
+// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE-NO-SIMD128
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
-// RUN: | FileCheck %s -check-prefix=BLEEDING_EDGE_NO_SIMD128
+// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE-NO-SIMD128
//
-// BLEEDING_EDGE_NO_SIMD128-NOT:#define __wasm_simd128__
+// BLEEDING-EDGE-NO-SIMD128-NOT:#define __wasm_simd128__
More information about the cfe-commits
mailing list