aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
diff options
context:
space:
mode:
authorPaulo Matos <pmatos@igalia.com>2021-06-10 10:02:10 +0200
committerPaulo Matos <pmatos@igalia.com>2021-06-10 10:07:45 +0200
commit31859f896cf90d64904134ce7b31230f374c3fcc (patch)
tree82be96496afd3d6408de39b8a53f6cf5f0aeb7cc /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
parentad6a84f82c4572dd92369b4f67df6e7c3536f9a2 (diff)
downloadllvm-31859f896cf90d64904134ce7b31230f374c3fcc.zip
llvm-31859f896cf90d64904134ce7b31230f374c3fcc.tar.gz
llvm-31859f896cf90d64904134ce7b31230f374c3fcc.tar.bz2
Implementation of global.get/set for reftypes in LLVM IR
This change implements new DAG notes GLOBAL_GET/GLOBAL_SET, and lowering methods for load and stores of reference types from IR globals. Once the lowering creates the new nodes, tablegen pattern matches those and converts them to Wasm global.get/set. Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D95425
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index c305da5..85625e1 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -113,6 +113,12 @@ static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM,
return *RM;
}
+// Check for reference types in Feature String, in order to extend target
+// description string
+static bool hasReferenceTypes(const StringRef &FS) {
+ return FS.find("+reference-types") != StringRef::npos;
+}
+
/// Create an WebAssembly architecture model.
///
WebAssemblyTargetMachine::WebAssemblyTargetMachine(
@@ -121,8 +127,12 @@ WebAssemblyTargetMachine::WebAssemblyTargetMachine(
Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT)
: LLVMTargetMachine(T,
TT.isArch64Bit()
- ? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
- : "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1",
+ ? (hasReferenceTypes(FS)
+ ? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20"
+ : "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1")
+ : (hasReferenceTypes(FS)
+ ? "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20"
+ : "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"),
TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT),
getEffectiveCodeModel(CM, CodeModel::Large), OL),
TLOF(new WebAssemblyTargetObjectFile()) {