Skip to content

Commit

Permalink
[WebAssembly] Refactor load ISel tablegen patterns into classes
Browse files Browse the repository at this point in the history
Not all of these will be able to be used by atomics because tablegen, but it
still seems like a good change by itself.

Differential Revision: https://reviews.llvm.org/D37345

llvm-svn: 312287
  • Loading branch information
dschuff committed Aug 31, 2017
1 parent a3b9fe6 commit 0f3bc0f
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 332 deletions.
13 changes: 7 additions & 6 deletions llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td
Expand Up @@ -18,16 +18,17 @@

let Defs = [ARGUMENTS] in {
// TODO: add the rest of the atomic loads
// TODO: factor out 0xfe atomic prefix?
def ATOMIC_LOAD_I32 : ATOMIC_I<(outs I32:$dst),
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
[], "i32.atomic.load\t$dst, ${off}(${addr})${p2align}",
0xfe10>;
def ATOMIC_LOAD_I32 : CLoadI32<"i32.atomic.load", 0xfe10>;
def ATOMIC_LOAD_I64 : CLoadI64<"i64.atomic.load", 0xfe11>;
} // Defs = [ARGUMENTS]

// Select loads with no constant offset.
let Predicates = [HasAtomics] in {
def : Pat<(i32 (atomic_load I32:$addr)), (ATOMIC_LOAD_I32 0, 0, $addr)>;
class ALoadPatNoOffset<ValueType ty, SDNode node, I inst> :
Pat<(ty (node I32:$addr)), (inst 0, 0, $addr)>;
def : ALoadPatNoOffset<i32, atomic_load, ATOMIC_LOAD_I32>;
def : ALoadPatNoOffset<i64, atomic_load, ATOMIC_LOAD_I64>;

}

//===----------------------------------------------------------------------===//
Expand Down

0 comments on commit 0f3bc0f

Please sign in to comment.