From: Thomas Lively Date: Thu, 31 Jan 2019 21:02:19 +0000 (+0000) Subject: [WebAssembly] Add bulk memory target feature X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4760046cd21dd7c8cf6f405f44338a643830985;p=llvm [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352793 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/WebAssembly/WebAssembly.td b/lib/Target/WebAssembly/WebAssembly.td index bb0cae9305d..230c1208e54 100644 --- a/lib/Target/WebAssembly/WebAssembly.td +++ b/lib/Target/WebAssembly/WebAssembly.td @@ -47,6 +47,10 @@ def FeatureExceptionHandling : SubtargetFeature<"exception-handling", "HasExceptionHandling", "true", "Enable Wasm exception handling">; +def FeatureBulkMemory : + SubtargetFeature<"bulk-memory", "HasBulkMemory", "true", + "Enable bulk memory operations">; + //===----------------------------------------------------------------------===// // Architectures. //===----------------------------------------------------------------------===// diff --git a/lib/Target/WebAssembly/WebAssemblyInstrInfo.td b/lib/Target/WebAssembly/WebAssemblyInstrInfo.td index 35d663903e4..71d21094189 100644 --- a/lib/Target/WebAssembly/WebAssemblyInstrInfo.td +++ b/lib/Target/WebAssembly/WebAssemblyInstrInfo.td @@ -16,40 +16,48 @@ //===----------------------------------------------------------------------===// def HasAddr32 : Predicate<"!Subtarget->hasAddr64()">; + def HasAddr64 : Predicate<"Subtarget->hasAddr64()">; -def HasSIMD128 : Predicate<"Subtarget->hasSIMD128()">, - AssemblerPredicate<"FeatureSIMD128", "simd128">; + +def HasSIMD128 : + Predicate<"Subtarget->hasSIMD128()">, + AssemblerPredicate<"FeatureSIMD128", "simd128">; + def HasUnimplementedSIMD128 : Predicate<"Subtarget->hasUnimplementedSIMD128()">, AssemblerPredicate<"FeatureUnimplementedSIMD128", "unimplemented-simd128">; -def HasAtomics : Predicate<"Subtarget->hasAtomics()">, - AssemblerPredicate<"FeatureAtomics", "atomics">; + +def HasAtomics : + Predicate<"Subtarget->hasAtomics()">, + AssemblerPredicate<"FeatureAtomics", "atomics">; + def HasNontrappingFPToInt : Predicate<"Subtarget->hasNontrappingFPToInt()">, - AssemblerPredicate<"FeatureNontrappingFPToInt", - "nontrapping-fptoint">; + AssemblerPredicate<"FeatureNontrappingFPToInt", "nontrapping-fptoint">; + def NotHasNontrappingFPToInt : Predicate<"!Subtarget->hasNontrappingFPToInt()">, - AssemblerPredicate<"!FeatureNontrappingFPToInt", - "nontrapping-fptoint">; + AssemblerPredicate<"!FeatureNontrappingFPToInt", "nontrapping-fptoint">; + def HasSignExt : Predicate<"Subtarget->hasSignExt()">, - AssemblerPredicate<"FeatureSignExt", - "sign-ext">; + AssemblerPredicate<"FeatureSignExt", "sign-ext">; + def NotHasSignExt : Predicate<"!Subtarget->hasSignExt()">, - AssemblerPredicate<"!FeatureSignExt", - "sign-ext">; + AssemblerPredicate<"!FeatureSignExt", "sign-ext">; def HasExceptionHandling : Predicate<"Subtarget->hasExceptionHandling()">, - AssemblerPredicate<"FeatureExceptionHandling", - "exception-handling">; + AssemblerPredicate<"FeatureExceptionHandling", "exception-handling">; def NotHasExceptionHandling : Predicate<"!Subtarget->hasExceptionHandling()">, - AssemblerPredicate<"!FeatureExceptionHandling", - "exception-handling">; + AssemblerPredicate<"!FeatureExceptionHandling", "exception-handling">; + +def HasBulkMemory : + Predicate<"Subtarget->hasBulkMemory()">, + AssemblerPredicate<"FeatureBulkMemory", "bulk-memory">; //===----------------------------------------------------------------------===// // WebAssembly-specific DAG Node Types. diff --git a/lib/Target/WebAssembly/WebAssemblySubtarget.h b/lib/Target/WebAssembly/WebAssemblySubtarget.h index e6ee2f54c5e..b6f3e6b4a10 100644 --- a/lib/Target/WebAssembly/WebAssemblySubtarget.h +++ b/lib/Target/WebAssembly/WebAssemblySubtarget.h @@ -38,6 +38,7 @@ class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { bool HasNontrappingFPToInt = false; bool HasSignExt = false; bool HasExceptionHandling = false; + bool HasBulkMemory = false; /// String name of used CPU. std::string CPUString; @@ -89,6 +90,7 @@ public: bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; } bool hasSignExt() const { return HasSignExt; } bool hasExceptionHandling() const { return HasExceptionHandling; } + bool hasBulkMemory() const { return HasBulkMemory; } /// Parses features string setting specified subtarget options. Definition of /// function is auto generated by tblgen. diff --git a/test/CodeGen/WebAssembly/bulk-memory.ll b/test/CodeGen/WebAssembly/bulk-memory.ll new file mode 100644 index 00000000000..aa0454b266a --- /dev/null +++ b/test/CodeGen/WebAssembly/bulk-memory.ll @@ -0,0 +1,7 @@ +; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+bulk-memory + +; Test that basic bulk memory codegen works correctly +; TODO: implement basic bulk memory codegen + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm32-unknown-unknown"