diff options
author | Paulo Matos <pmatos@igalia.com> | 2021-05-04 14:13:08 +0200 |
---|---|---|
committer | Andy Wingo <wingo@igalia.com> | 2021-05-11 11:19:29 +0200 |
commit | d7086af2143d58a6535e0837c4d8789c69c6985f (patch) | |
tree | 17f56deba8b467fb5bdd2797cfd2ac57fea78671 /llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp | |
parent | 04adfb660987072ad31756e0d04803f96c3c39f7 (diff) | |
download | llvm-d7086af2143d58a6535e0837c4d8789c69c6985f.zip llvm-d7086af2143d58a6535e0837c4d8789c69c6985f.tar.gz llvm-d7086af2143d58a6535e0837c4d8789c69c6985f.tar.bz2 |
[WebAssembly] Support for WebAssembly globals in LLVM IR
This patch adds support for WebAssembly globals in LLVM IR, representing
them as pointers to global values, in a non-default, non-integral
address space. Instruction selection legalizes loads and stores to
these pointers to new WebAssemblyISD nodes GLOBAL_GET and GLOBAL_SET.
Once the lowering creates the new nodes, tablegen pattern matches those
and converts them to Wasm global.get/set of the appropriate type.
Based on work by Paulo Matos in https://reviews.llvm.org/D95425.
Reviewed By: pmatos
Differential Revision: https://reviews.llvm.org/D101608
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp index 68e4b9c..cb0cdf1 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -1182,6 +1182,8 @@ bool WebAssemblyFastISel::selectLoad(const Instruction *I) { const auto *Load = cast<LoadInst>(I); if (Load->isAtomic()) return false; + if (!WebAssembly::isDefaultAddressSpace(Load->getPointerAddressSpace())) + return false; if (!Subtarget->hasSIMD128() && Load->getType()->isVectorTy()) return false; @@ -1240,6 +1242,8 @@ bool WebAssemblyFastISel::selectStore(const Instruction *I) { const auto *Store = cast<StoreInst>(I); if (Store->isAtomic()) return false; + if (!WebAssembly::isDefaultAddressSpace(Store->getPointerAddressSpace())) + return false; if (!Subtarget->hasSIMD128() && Store->getValueOperand()->getType()->isVectorTy()) return false; |