aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
diff options
context:
space:
mode:
authorPaulo Matos <pmatos@igalia.com>2023-02-17 18:38:58 -0800
committerVitaly Buka <vitalybuka@google.com>2023-02-17 18:48:48 -0800
commit890146b19206827bc48ee1ae1dc1534ff2ff18d7 (patch)
treeb945a429708a5af6128a2a797fb0cc28a29c0dc8 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
parente2069be83ea88837e1d3bb710aff17cd84ee7b7e (diff)
downloadllvm-890146b19206827bc48ee1ae1dc1534ff2ff18d7.zip
llvm-890146b19206827bc48ee1ae1dc1534ff2ff18d7.tar.gz
llvm-890146b19206827bc48ee1ae1dc1534ff2ff18d7.tar.bz2
[WebAssembly] Initial support for reference type externref in clang
This patch introduces a new type __externref_t that denotes a WebAssembly opaque reference type. It also implements builtin __builtin_wasm_ref_null_extern(), that returns a null value of __externref_t. This lays the ground work for further builtins and reference types. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D122215
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 630c786..c10f070 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
#include "TargetInfo/WebAssemblyTargetInfo.h"
#include "Utils/WebAssemblyUtilities.h"
#include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblyTargetObjectFile.h"
#include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,15 @@ void WebAssemblyPassConfig::addIRPasses() {
}
void WebAssemblyPassConfig::addISelPrepare() {
+ WebAssemblyTargetMachine *WasmTM =
+ static_cast<WebAssemblyTargetMachine *>(TM);
+ const WebAssemblySubtarget *Subtarget =
+ WasmTM->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+ std::string(WasmTM->getTargetFeatureString()));
+ if (Subtarget->hasReferenceTypes()) {
+ // We need to remove allocas for reference types
+ addPass(createPromoteMemoryToRegisterPass(true));
+ }
// Lower atomics and TLS if necessary
addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));