2015-07-11 02:23:10 +08:00
|
|
|
// WebAssemblyInstrMemory.td-WebAssembly Memory codegen support -*- tablegen -*-
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief WebAssembly Memory operand code-gen constructs.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-11-26 02:13:18 +08:00
|
|
|
// TODO:
|
2015-09-01 06:24:11 +08:00
|
|
|
// - HasAddr64
|
|
|
|
// - WebAssemblyTargetLowering having to do with atomics
|
2015-12-16 06:01:29 +08:00
|
|
|
// - Each has optional alignment.
|
2015-09-01 06:24:11 +08:00
|
|
|
|
|
|
|
// WebAssembly has i8/i16/i32/i64/f32/f64 memory types, but doesn't have i8/i16
|
|
|
|
// local types. These memory-only types instead zero- or sign-extend into local
|
|
|
|
// types when loading, and truncate when storing.
|
|
|
|
|
2015-12-16 06:01:29 +08:00
|
|
|
// WebAssembly constant offsets are performed as unsigned with infinite
|
|
|
|
// precision, so we need to check for NoUnsignedWrap so that we don't fold an
|
|
|
|
// offset for an add that needs wrapping.
|
2016-01-12 06:05:44 +08:00
|
|
|
def regPlusImm : PatFrag<(ops node:$addr, node:$off),
|
2015-12-16 06:01:29 +08:00
|
|
|
(add node:$addr, node:$off),
|
|
|
|
[{ return N->getFlags()->hasNoUnsignedWrap(); }]>;
|
|
|
|
|
2016-02-23 04:04:02 +08:00
|
|
|
// Treat an 'or' node as an 'add' if the or'ed bits are known to be zero.
|
|
|
|
def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
|
|
|
|
if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
|
|
|
|
return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
|
|
|
|
|
|
|
|
APInt KnownZero0, KnownOne0;
|
|
|
|
CurDAG->computeKnownBits(N->getOperand(0), KnownZero0, KnownOne0, 0);
|
|
|
|
APInt KnownZero1, KnownOne1;
|
|
|
|
CurDAG->computeKnownBits(N->getOperand(1), KnownZero1, KnownOne1, 0);
|
|
|
|
return (~KnownZero0 & ~KnownZero1) == 0;
|
|
|
|
}]>;
|
|
|
|
|
2016-01-12 06:05:44 +08:00
|
|
|
// GlobalAddresses are conceptually unsigned values, so we can also fold them
|
2016-09-01 04:27:20 +08:00
|
|
|
// into immediate values as long as the add is 'nuw'.
|
|
|
|
// TODO: We'd like to also match GA offsets but there are cases where the
|
|
|
|
// register can have a negative value. Find out what more we can do.
|
2016-01-12 06:05:44 +08:00
|
|
|
def regPlusGA : PatFrag<(ops node:$addr, node:$off),
|
|
|
|
(add node:$addr, node:$off),
|
|
|
|
[{
|
2016-09-01 04:27:20 +08:00
|
|
|
return N->getFlags()->hasNoUnsignedWrap();
|
2016-01-12 06:05:44 +08:00
|
|
|
}]>;
|
|
|
|
|
|
|
|
// We don't need a regPlusES because external symbols never have constant
|
|
|
|
// offsets folded into them, so we can just use add.
|
|
|
|
|
2015-11-26 03:36:19 +08:00
|
|
|
let Defs = [ARGUMENTS] in {
|
|
|
|
|
2015-09-01 06:24:11 +08:00
|
|
|
// Basic load.
|
2016-10-25 08:17:11 +08:00
|
|
|
// FIXME: When we can break syntax compatibility, reorder the fields in the
|
|
|
|
// asmstrings to match the binary encoding.
|
|
|
|
def LOAD_I32 : I<(outs I32:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i32.load\t$dst, ${off}(${addr})${p2align}", 0x28>;
|
|
|
|
def LOAD_I64 : I<(outs I64:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i64.load\t$dst, ${off}(${addr})${p2align}", 0x29>;
|
|
|
|
def LOAD_F32 : I<(outs F32:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "f32.load\t$dst, ${off}(${addr})${p2align}", 0x2a>;
|
|
|
|
def LOAD_F64 : I<(outs F64:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "f64.load\t$dst, ${off}(${addr})${p2align}", 0x2b>;
|
2015-09-01 06:24:11 +08:00
|
|
|
|
2015-12-16 06:01:29 +08:00
|
|
|
} // Defs = [ARGUMENTS]
|
|
|
|
|
|
|
|
// Select loads with no constant offset.
|
2016-10-25 08:17:11 +08:00
|
|
|
def : Pat<(i32 (load I32:$addr)), (LOAD_I32 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (load I32:$addr)), (LOAD_I64 0, 0, $addr)>;
|
|
|
|
def : Pat<(f32 (load I32:$addr)), (LOAD_F32 0, 0, $addr)>;
|
|
|
|
def : Pat<(f64 (load I32:$addr)), (LOAD_F64 0, 0, $addr)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
|
|
|
// Select loads with a constant offset.
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (load (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I32 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (load (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(f32 (load (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F32 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(f64 (load (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i32 (load (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I32 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (load (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(f32 (load (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F32 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(f64 (load (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (load (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I32 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (load (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(f32 (load (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F32 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(f64 (load (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I32 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I64 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(f32 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F32 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(f64 (load (add I32:$addr, (WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F64 0, texternalsym:$off, $addr)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
|
|
|
// Select loads with just a constant offset.
|
2016-10-25 08:17:11 +08:00
|
|
|
def : Pat<(i32 (load imm:$off)), (LOAD_I32 0, imm:$off, (CONST_I32 0))>;
|
|
|
|
def : Pat<(i64 (load imm:$off)), (LOAD_I64 0, imm:$off, (CONST_I32 0))>;
|
|
|
|
def : Pat<(f32 (load imm:$off)), (LOAD_F32 0, imm:$off, (CONST_I32 0))>;
|
|
|
|
def : Pat<(f64 (load imm:$off)), (LOAD_F64 0, imm:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (load (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I32 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (load (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(f32 (load (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F32 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(f64 (load (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (load (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I32 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (load (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(f32 (load (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F32 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(f64 (load (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD_F64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
|
|
|
let Defs = [ARGUMENTS] in {
|
|
|
|
|
2015-09-01 06:24:11 +08:00
|
|
|
// Extending load.
|
2016-10-25 08:17:11 +08:00
|
|
|
def LOAD8_S_I32 : I<(outs I32:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i32.load8_s\t$dst, ${off}(${addr})${p2align}", 0x2c>;
|
|
|
|
def LOAD8_U_I32 : I<(outs I32:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i32.load8_u\t$dst, ${off}(${addr})${p2align}", 0x2d>;
|
|
|
|
def LOAD16_S_I32 : I<(outs I32:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i32.load16_s\t$dst, ${off}(${addr})${p2align}", 0x2e>;
|
|
|
|
def LOAD16_U_I32 : I<(outs I32:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i32.load16_u\t$dst, ${off}(${addr})${p2align}", 0x2f>;
|
|
|
|
def LOAD8_S_I64 : I<(outs I64:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i64.load8_s\t$dst, ${off}(${addr})${p2align}", 0x30>;
|
|
|
|
def LOAD8_U_I64 : I<(outs I64:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i64.load8_u\t$dst, ${off}(${addr})${p2align}", 0x31>;
|
|
|
|
def LOAD16_S_I64 : I<(outs I64:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i64.load16_s\t$dst, ${off}(${addr})${p2align}", 0x32>;
|
|
|
|
def LOAD16_U_I64 : I<(outs I64:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i64.load16_u\t$dst, ${off}(${addr})${p2align}", 0x33>;
|
|
|
|
def LOAD32_S_I64 : I<(outs I64:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i64.load32_s\t$dst, ${off}(${addr})${p2align}", 0x34>;
|
|
|
|
def LOAD32_U_I64 : I<(outs I64:$dst),
|
2016-12-23 11:23:52 +08:00
|
|
|
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
[], "i64.load32_u\t$dst, ${off}(${addr})${p2align}", 0x35>;
|
2015-09-01 06:24:11 +08:00
|
|
|
|
2015-11-26 03:36:19 +08:00
|
|
|
} // Defs = [ARGUMENTS]
|
|
|
|
|
2015-12-05 08:26:39 +08:00
|
|
|
// Select extending loads with no constant offset.
|
2016-10-25 08:17:11 +08:00
|
|
|
def : Pat<(i32 (sextloadi8 I32:$addr)), (LOAD8_S_I32 0, 0, $addr)>;
|
|
|
|
def : Pat<(i32 (zextloadi8 I32:$addr)), (LOAD8_U_I32 0, 0, $addr)>;
|
|
|
|
def : Pat<(i32 (sextloadi16 I32:$addr)), (LOAD16_S_I32 0, 0, $addr)>;
|
|
|
|
def : Pat<(i32 (zextloadi16 I32:$addr)), (LOAD16_U_I32 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (sextloadi8 I32:$addr)), (LOAD8_S_I64 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (zextloadi8 I32:$addr)), (LOAD8_U_I64 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (sextloadi16 I32:$addr)), (LOAD16_S_I64 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (zextloadi16 I32:$addr)), (LOAD16_U_I64 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (sextloadi32 I32:$addr)), (LOAD32_S_I64 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (zextloadi32 I32:$addr)), (LOAD32_U_I64 0, 0, $addr)>;
|
2015-12-05 08:26:39 +08:00
|
|
|
|
2015-12-16 06:01:29 +08:00
|
|
|
// Select extending loads with a constant offset.
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (sextloadi8 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I32 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (zextloadi8 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (sextloadi16 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I32 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (zextloadi16 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi8 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi8 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi16 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi16 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi32 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_S_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi32 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i32 (sextloadi8 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I32 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i32 (zextloadi8 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i32 (sextloadi16 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I32 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i32 (zextloadi16 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (sextloadi8 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (zextloadi8 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (sextloadi16 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (zextloadi16 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (sextloadi32 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_S_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (zextloadi32 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (sextloadi8 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I32 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (zextloadi8 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (sextloadi16 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I32 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (zextloadi16 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi8 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi8 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi16 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi16 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi32 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_S_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi32 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (sextloadi8 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I32 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (zextloadi8 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (sextloadi16 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I32 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (zextloadi16 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi8 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I64 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi8 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi16 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I64 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi16 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (sextloadi32 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_S_I64 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (zextloadi32 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, texternalsym:$off, $addr)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
|
|
|
// Select extending loads with just a constant offset.
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i32 (sextloadi8 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I32 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i32 (zextloadi8 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i32 (sextloadi16 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I32 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i32 (zextloadi16 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (sextloadi8 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I64 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (zextloadi8 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (sextloadi16 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I64 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (zextloadi16 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (sextloadi32 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_S_I64 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (zextloadi32 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, imm:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (sextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I32 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (zextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (sextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I32 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (zextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (sextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (zextloadi8 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (sextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (zextloadi16 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (sextloadi32 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_S_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (zextloadi32 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (sextloadi8 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I32 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (zextloadi8 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (sextloadi16 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I32 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (zextloadi16 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (sextloadi8 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_S_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (zextloadi8 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (sextloadi16 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_S_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (zextloadi16 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (sextloadi32 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_S_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (zextloadi32 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
|
|
|
// Resolve "don't care" extending loads to zero-extending loads. This is
|
|
|
|
// somewhat arbitrary, but zero-extending is conceptually simpler.
|
|
|
|
|
|
|
|
// Select "don't care" extending loads with no constant offset.
|
2016-10-25 08:17:11 +08:00
|
|
|
def : Pat<(i32 (extloadi8 I32:$addr)), (LOAD8_U_I32 0, 0, $addr)>;
|
|
|
|
def : Pat<(i32 (extloadi16 I32:$addr)), (LOAD16_U_I32 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (extloadi8 I32:$addr)), (LOAD8_U_I64 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (extloadi16 I32:$addr)), (LOAD16_U_I64 0, 0, $addr)>;
|
|
|
|
def : Pat<(i64 (extloadi32 I32:$addr)), (LOAD32_U_I64 0, 0, $addr)>;
|
2015-09-01 06:24:11 +08:00
|
|
|
|
2015-12-16 06:01:29 +08:00
|
|
|
// Select "don't care" extending loads with a constant offset.
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (extloadi8 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (extloadi16 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi8 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi16 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi32 (regPlusImm I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i32 (extloadi8 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i32 (extloadi16 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (extloadi8 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (extloadi16 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, imm:$off, $addr)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(i64 (extloadi32 (or_is_add I32:$addr, imm:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, imm:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (extloadi8 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (extloadi16 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi8 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi16 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi32 (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, tglobaladdr:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (extloadi8 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i32 (extloadi16 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi8 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi16 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, texternalsym:$off, $addr)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(i64 (extloadi32 (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off)))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, texternalsym:$off, $addr)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
|
|
|
// Select "don't care" extending loads with just a constant offset.
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i32 (extloadi8 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i32 (extloadi16 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (extloadi8 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (extloadi16 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, imm:$off, (CONST_I32 0))>;
|
2016-01-26 11:39:31 +08:00
|
|
|
def : Pat<(i64 (extloadi32 imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, imm:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (extloadi8 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (extloadi16 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (extloadi8 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (extloadi16 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (extloadi32 (WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (extloadi8 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I32 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i32 (extloadi16 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I32 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (extloadi8 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD8_U_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (extloadi16 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD16_U_I64 0, texternalsym:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(i64 (extloadi32 (WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(LOAD32_U_I64 0, tglobaladdr:$off, (CONST_I32 0))>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
2015-11-26 03:36:19 +08:00
|
|
|
let Defs = [ARGUMENTS] in {
|
|
|
|
|
2015-09-01 06:24:11 +08:00
|
|
|
// Basic store.
|
|
|
|
// Note: WebAssembly inverts SelectionDAG's usual operand order.
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE_I32 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
I32:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.store\t${off}(${addr})${p2align}, $val", 0x36>;
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE_I64 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
I64:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.store\t${off}(${addr})${p2align}, $val", 0x37>;
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE_F32 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
F32:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f32.store\t${off}(${addr})${p2align}, $val", 0x38>;
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE_F64 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
F64:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f64.store\t${off}(${addr})${p2align}, $val", 0x39>;
|
2015-11-24 05:16:35 +08:00
|
|
|
|
2015-11-26 03:36:19 +08:00
|
|
|
} // Defs = [ARGUMENTS]
|
|
|
|
|
2015-12-16 06:01:29 +08:00
|
|
|
// Select stores with no constant offset.
|
2016-10-25 08:17:11 +08:00
|
|
|
def : Pat<(store I32:$val, I32:$addr), (STORE_I32 0, 0, I32:$addr, I32:$val)>;
|
|
|
|
def : Pat<(store I64:$val, I32:$addr), (STORE_I64 0, 0, I32:$addr, I64:$val)>;
|
|
|
|
def : Pat<(store F32:$val, I32:$addr), (STORE_F32 0, 0, I32:$addr, F32:$val)>;
|
|
|
|
def : Pat<(store F64:$val, I32:$addr), (STORE_F64 0, 0, I32:$addr, F64:$val)>;
|
2015-12-05 08:26:39 +08:00
|
|
|
|
2015-12-16 06:01:29 +08:00
|
|
|
// Select stores with a constant offset.
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store I32:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I32 0, imm:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store I64:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I64 0, imm:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store F32:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F32 0, imm:$off, I32:$addr, F32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store F64:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F64 0, imm:$off, I32:$addr, F64:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(store I32:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I32 0, imm:$off, I32:$addr, I32:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(store I64:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I64 0, imm:$off, I32:$addr, I64:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(store F32:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F32 0, imm:$off, I32:$addr, F32:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(store F64:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F64 0, imm:$off, I32:$addr, F64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store I32:$val, (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I32 0, tglobaladdr:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store I64:$val, (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I64 0, tglobaladdr:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store F32:$val, (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F32 0, tglobaladdr:$off, I32:$addr, F32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store F64:$val, (regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F64 0, tglobaladdr:$off, I32:$addr, F64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store I32:$val, (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I32 0, texternalsym:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store I64:$val, (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I64 0, texternalsym:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store F32:$val, (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F32 0, texternalsym:$off, I32:$addr, F32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(store F64:$val, (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F64 0, texternalsym:$off, I32:$addr, F64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
|
|
|
// Select stores with just a constant offset.
|
|
|
|
def : Pat<(store I32:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I32 0, imm:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store I64:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I64 0, imm:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store F32:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F32 0, imm:$off, (CONST_I32 0), F32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store F64:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F64 0, imm:$off, (CONST_I32 0), F64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I32 0, tglobaladdr:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I64 0, tglobaladdr:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store F32:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F32 0, tglobaladdr:$off, (CONST_I32 0), F32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store F64:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F64 0, tglobaladdr:$off, (CONST_I32 0), F64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store I32:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I32 0, texternalsym:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store I64:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_I64 0, texternalsym:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store F32:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F32 0, texternalsym:$off, (CONST_I32 0), F32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(store F64:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE_F64 0, texternalsym:$off, (CONST_I32 0), F64:$val)>;
|
2015-09-01 06:24:11 +08:00
|
|
|
|
2015-11-26 03:36:19 +08:00
|
|
|
let Defs = [ARGUMENTS] in {
|
|
|
|
|
2015-09-01 06:24:11 +08:00
|
|
|
// Truncating store.
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE8_I32 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
I32:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.store8\t${off}(${addr})${p2align}, $val", 0x3a>;
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE16_I32 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
I32:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.store16\t${off}(${addr})${p2align}, $val", 0x3b>;
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE8_I64 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
I64:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.store8\t${off}(${addr})${p2align}, $val", 0x3c>;
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE16_I64 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
I64:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.store16\t${off}(${addr})${p2align}, $val", 0x3d>;
|
2016-12-23 11:23:52 +08:00
|
|
|
def STORE32_I64 : I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr,
|
2016-10-25 08:17:11 +08:00
|
|
|
I64:$val), [],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.store32\t${off}(${addr})${p2align}, $val", 0x3e>;
|
2015-11-24 05:16:35 +08:00
|
|
|
|
2015-11-26 03:36:19 +08:00
|
|
|
} // Defs = [ARGUMENTS]
|
|
|
|
|
2015-12-16 06:01:29 +08:00
|
|
|
// Select truncating stores with no constant offset.
|
2015-11-24 05:16:35 +08:00
|
|
|
def : Pat<(truncstorei8 I32:$val, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I32 0, 0, I32:$addr, I32:$val)>;
|
2015-11-24 05:16:35 +08:00
|
|
|
def : Pat<(truncstorei16 I32:$val, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I32 0, 0, I32:$addr, I32:$val)>;
|
2015-11-24 05:16:35 +08:00
|
|
|
def : Pat<(truncstorei8 I64:$val, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I64 0, 0, I32:$addr, I64:$val)>;
|
2015-11-24 05:16:35 +08:00
|
|
|
def : Pat<(truncstorei16 I64:$val, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I64 0, 0, I32:$addr, I64:$val)>;
|
2015-11-24 05:16:35 +08:00
|
|
|
def : Pat<(truncstorei32 I64:$val, I32:$addr),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE32_I64 0, 0, I32:$addr, I64:$val)>;
|
2015-09-01 06:24:11 +08:00
|
|
|
|
2015-12-16 06:01:29 +08:00
|
|
|
// Select truncating stores with a constant offset.
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei8 I32:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I32 0, imm:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei16 I32:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I32 0, imm:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei8 I64:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I64 0, imm:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei16 I64:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I64 0, imm:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei32 I64:$val, (regPlusImm I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE32_I64 0, imm:$off, I32:$addr, I64:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(truncstorei8 I32:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I32 0, imm:$off, I32:$addr, I32:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(truncstorei16 I32:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I32 0, imm:$off, I32:$addr, I32:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(truncstorei8 I64:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I64 0, imm:$off, I32:$addr, I64:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(truncstorei16 I64:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I64 0, imm:$off, I32:$addr, I64:$val)>;
|
2016-02-23 04:04:02 +08:00
|
|
|
def : Pat<(truncstorei32 I64:$val, (or_is_add I32:$addr, imm:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE32_I64 0, imm:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei8 I32:$val,
|
|
|
|
(regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I32 0, tglobaladdr:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei16 I32:$val,
|
|
|
|
(regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I32 0, tglobaladdr:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei8 I64:$val,
|
|
|
|
(regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I64 0, tglobaladdr:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei16 I64:$val,
|
|
|
|
(regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I64 0, tglobaladdr:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei32 I64:$val,
|
|
|
|
(regPlusGA I32:$addr,
|
|
|
|
(WebAssemblywrapper tglobaladdr:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE32_I64 0, tglobaladdr:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei8 I32:$val, (add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I32 0, texternalsym:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei16 I32:$val,
|
|
|
|
(add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I32 0, texternalsym:$off, I32:$addr, I32:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei8 I64:$val,
|
|
|
|
(add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I64 0, texternalsym:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei16 I64:$val,
|
|
|
|
(add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I64 0, texternalsym:$off, I32:$addr, I64:$val)>;
|
2016-01-12 06:05:44 +08:00
|
|
|
def : Pat<(truncstorei32 I64:$val,
|
|
|
|
(add I32:$addr,
|
|
|
|
(WebAssemblywrapper texternalsym:$off))),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE32_I64 0, texternalsym:$off, I32:$addr, I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
|
|
|
// Select truncating stores with just a constant offset.
|
|
|
|
def : Pat<(truncstorei8 I32:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I32 0, imm:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei16 I32:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I32 0, imm:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei8 I64:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I64 0, imm:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei16 I64:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I64 0, imm:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei32 I64:$val, imm:$off),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE32_I64 0, imm:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei8 I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I32 0, tglobaladdr:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei16 I32:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I32 0, tglobaladdr:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei8 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I64 0, tglobaladdr:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei16 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I64 0, tglobaladdr:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei32 I64:$val, (WebAssemblywrapper tglobaladdr:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE32_I64 0, tglobaladdr:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei8 I32:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I32 0, texternalsym:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei16 I32:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I32 0, texternalsym:$off, (CONST_I32 0), I32:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei8 I64:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE8_I64 0, texternalsym:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei16 I64:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE16_I64 0, texternalsym:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
def : Pat<(truncstorei32 I64:$val, (WebAssemblywrapper texternalsym:$off)),
|
2016-10-25 08:17:11 +08:00
|
|
|
(STORE32_I64 0, texternalsym:$off, (CONST_I32 0), I64:$val)>;
|
2015-12-16 06:01:29 +08:00
|
|
|
|
2015-11-26 03:36:19 +08:00
|
|
|
let Defs = [ARGUMENTS] in {
|
|
|
|
|
2016-05-03 01:25:22 +08:00
|
|
|
// Current memory size.
|
2016-10-26 00:55:52 +08:00
|
|
|
def CURRENT_MEMORY_I32 : I<(outs I32:$dst), (ins i32imm:$flags),
|
|
|
|
[],
|
2016-10-25 04:21:49 +08:00
|
|
|
"current_memory\t$dst", 0x3f>,
|
2016-05-03 01:25:22 +08:00
|
|
|
Requires<[HasAddr32]>;
|
2015-10-03 04:10:26 +08:00
|
|
|
|
2015-11-06 04:16:59 +08:00
|
|
|
// Grow memory.
|
2016-10-26 00:55:52 +08:00
|
|
|
def GROW_MEMORY_I32 : I<(outs), (ins i32imm:$flags, I32:$delta),
|
|
|
|
[],
|
2016-10-25 04:21:49 +08:00
|
|
|
"grow_memory\t$delta", 0x40>,
|
2015-11-06 04:16:59 +08:00
|
|
|
Requires<[HasAddr32]>;
|
2015-11-26 03:36:19 +08:00
|
|
|
|
|
|
|
} // Defs = [ARGUMENTS]
|
2016-10-26 00:55:52 +08:00
|
|
|
|
|
|
|
def : Pat<(int_wasm_current_memory),
|
|
|
|
(CURRENT_MEMORY_I32 0)>;
|
|
|
|
def : Pat<(int_wasm_grow_memory I32:$delta),
|
|
|
|
(GROW_MEMORY_I32 0, $delta)>;
|