From: Thomas Lively Date: Fri, 29 Mar 2019 22:00:18 +0000 (+0000) Subject: [WebAssembly] Add mutable globals feature X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ef436534eb2c6147d187e033f3446d0c17e1b2f;p=llvm [WebAssembly] Add mutable globals feature Summary: This feature is not actually used for anything in the WebAssembly backend, but adding it allows users to get it into the target features sections of their objects, which makes these objects future-compatible. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, jdoerfert, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D60013 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357321 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/WebAssembly/WebAssembly.td b/lib/Target/WebAssembly/WebAssembly.td index 230c1208e54..9138683d498 100644 --- a/lib/Target/WebAssembly/WebAssembly.td +++ b/lib/Target/WebAssembly/WebAssembly.td @@ -51,6 +51,10 @@ def FeatureBulkMemory : SubtargetFeature<"bulk-memory", "HasBulkMemory", "true", "Enable bulk memory operations">; +def FeatureMutableGlobals : + SubtargetFeature<"mutable-globals", "HasMutableGlobals", "true", + "Enable mutable globals">; + //===----------------------------------------------------------------------===// // Architectures. //===----------------------------------------------------------------------===// diff --git a/lib/Target/WebAssembly/WebAssemblySubtarget.h b/lib/Target/WebAssembly/WebAssemblySubtarget.h index ae1f3fe3946..22e11726f33 100644 --- a/lib/Target/WebAssembly/WebAssemblySubtarget.h +++ b/lib/Target/WebAssembly/WebAssemblySubtarget.h @@ -44,6 +44,7 @@ class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { bool HasSignExt = false; bool HasExceptionHandling = false; bool HasBulkMemory = false; + bool HasMutableGlobals = false; /// String name of used CPU. std::string CPUString; @@ -97,6 +98,7 @@ public: bool hasSignExt() const { return HasSignExt; } bool hasExceptionHandling() const { return HasExceptionHandling; } bool hasBulkMemory() const { return HasBulkMemory; } + bool hasMutableGlobals() const { return HasMutableGlobals; } /// Parses features string setting specified subtarget options. Definition of /// function is auto generated by tblgen. diff --git a/test/CodeGen/WebAssembly/mutable-globals.ll b/test/CodeGen/WebAssembly/mutable-globals.ll new file mode 100644 index 00000000000..45b485482c8 --- /dev/null +++ b/test/CodeGen/WebAssembly/mutable-globals.ll @@ -0,0 +1,16 @@ +; RUN: llc < %s -mattr=+mutable-globals | FileCheck %s + +; Test that mutable globals is properly emitted into the target features section + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm32-unknown-unknown" + +define void @foo() { + ret void +} + +; CHECK-LABEL: .custom_section.target_features +; CHECK-NEXT: .int8 1 +; CHECK-NEXT: .int8 43 +; CHECK-NEXT: .int8 15 +; CHECK-NEXT: .ascii "mutable-globals"