[llvm] r357321 - [WebAssembly] Add mutable globals feature
Thomas Lively via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 29 15:00:18 PDT 2019
Author: tlively
Date: Fri Mar 29 15:00:18 2019
New Revision: 357321
URL: http://llvm.org/viewvc/llvm-project?rev=357321&view=rev
Log:
[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
Added:
llvm/trunk/test/CodeGen/WebAssembly/mutable-globals.ll
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssembly.td
llvm/trunk/lib/Target/WebAssembly/WebAssemblySubtarget.h
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssembly.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssembly.td?rev=357321&r1=357320&r2=357321&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssembly.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssembly.td Fri Mar 29 15:00:18 2019
@@ -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.
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblySubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblySubtarget.h?rev=357321&r1=357320&r2=357321&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblySubtarget.h (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblySubtarget.h Fri Mar 29 15:00:18 2019
@@ -44,6 +44,7 @@ class WebAssemblySubtarget final : publi
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.
Added: llvm/trunk/test/CodeGen/WebAssembly/mutable-globals.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/mutable-globals.ll?rev=357321&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/mutable-globals.ll (added)
+++ llvm/trunk/test/CodeGen/WebAssembly/mutable-globals.ll Fri Mar 29 15:00:18 2019
@@ -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"
More information about the llvm-commits
mailing list