Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 1 | // WebAssemblyInstrAtomics.td-WebAssembly Atomic codegen support-*- tablegen -*- |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 11 | /// WebAssembly Atomic operand code-gen constructs. |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 12 | /// |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 15 | //===----------------------------------------------------------------------===// |
| 16 | // Atomic loads |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | |
Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame] | 19 | let Defs = [ARGUMENTS] in { |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 20 | defm ATOMIC_LOAD_I32 : WebAssemblyLoad<I32, "i32.atomic.load", 0xfe10>; |
| 21 | defm ATOMIC_LOAD_I64 : WebAssemblyLoad<I64, "i64.atomic.load", 0xfe11>; |
Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame] | 22 | } // Defs = [ARGUMENTS] |
| 23 | |
| 24 | // Select loads with no constant offset. |
| 25 | let Predicates = [HasAtomics] in { |
Derek Schuff | 885dc59 | 2017-10-05 21:18:42 +0000 | [diff] [blame] | 26 | def : LoadPatNoOffset<i32, atomic_load_32, ATOMIC_LOAD_I32>; |
| 27 | def : LoadPatNoOffset<i64, atomic_load_64, ATOMIC_LOAD_I64>; |
Derek Schuff | 0f3bc0f | 2017-08-31 21:51:48 +0000 | [diff] [blame] | 28 | |
Derek Schuff | 885dc59 | 2017-10-05 21:18:42 +0000 | [diff] [blame] | 29 | // Select loads with a constant offset. |
| 30 | |
| 31 | // Pattern with address + immediate offset |
| 32 | def : LoadPatImmOff<i32, atomic_load_32, regPlusImm, ATOMIC_LOAD_I32>; |
| 33 | def : LoadPatImmOff<i64, atomic_load_64, regPlusImm, ATOMIC_LOAD_I64>; |
| 34 | def : LoadPatImmOff<i32, atomic_load_32, or_is_add, ATOMIC_LOAD_I32>; |
| 35 | def : LoadPatImmOff<i64, atomic_load_64, or_is_add, ATOMIC_LOAD_I64>; |
| 36 | |
| 37 | def : LoadPatGlobalAddr<i32, atomic_load_32, ATOMIC_LOAD_I32>; |
| 38 | def : LoadPatGlobalAddr<i64, atomic_load_64, ATOMIC_LOAD_I64>; |
| 39 | |
| 40 | def : LoadPatExternalSym<i32, atomic_load_32, ATOMIC_LOAD_I32>; |
| 41 | def : LoadPatExternalSym<i64, atomic_load_64, ATOMIC_LOAD_I64>; |
| 42 | |
| 43 | |
| 44 | // Select loads with just a constant offset. |
| 45 | def : LoadPatOffsetOnly<i32, atomic_load_32, ATOMIC_LOAD_I32>; |
| 46 | def : LoadPatOffsetOnly<i64, atomic_load_64, ATOMIC_LOAD_I64>; |
| 47 | |
| 48 | def : LoadPatGlobalAddrOffOnly<i32, atomic_load_32, ATOMIC_LOAD_I32>; |
| 49 | def : LoadPatGlobalAddrOffOnly<i64, atomic_load_64, ATOMIC_LOAD_I64>; |
| 50 | |
| 51 | def : LoadPatExternSymOffOnly<i32, atomic_load_32, ATOMIC_LOAD_I32>; |
| 52 | def : LoadPatExternSymOffOnly<i64, atomic_load_64, ATOMIC_LOAD_I64>; |
| 53 | |
| 54 | } // Predicates = [HasAtomics] |
| 55 | |
| 56 | // Extending loads. Note that there are only zero-extending atomic loads, no |
| 57 | // sign-extending loads. |
| 58 | let Defs = [ARGUMENTS] in { |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 59 | defm ATOMIC_LOAD8_U_I32 : WebAssemblyLoad<I32, "i32.atomic.load8_u", 0xfe12>; |
| 60 | defm ATOMIC_LOAD16_U_I32 : WebAssemblyLoad<I32, "i32.atomic.load16_u", 0xfe13>; |
| 61 | defm ATOMIC_LOAD8_U_I64 : WebAssemblyLoad<I64, "i64.atomic.load8_u", 0xfe14>; |
| 62 | defm ATOMIC_LOAD16_U_I64 : WebAssemblyLoad<I64, "i64.atomic.load16_u", 0xfe15>; |
| 63 | defm ATOMIC_LOAD32_U_I64 : WebAssemblyLoad<I64, "i64.atomic.load32_u", 0xfe16>; |
Derek Schuff | 885dc59 | 2017-10-05 21:18:42 +0000 | [diff] [blame] | 64 | } // Defs = [ARGUMENTS] |
| 65 | |
| 66 | // Fragments for exending loads. These are different from regular loads because |
| 67 | // the SDNodes are derived from AtomicSDNode rather than LoadSDNode and |
| 68 | // therefore don't have the extension type field. So instead of matching that, |
| 69 | // we match the patterns that the type legalizer expands them to. |
| 70 | |
| 71 | // We directly match zext patterns and select the zext atomic loads. |
| 72 | // i32 (zext (i8 (atomic_load_8))) gets legalized to |
| 73 | // i32 (and (i32 (atomic_load_8)), 255) |
| 74 | // These can be selected to a single zero-extending atomic load instruction. |
| 75 | def zext_aload_8 : PatFrag<(ops node:$addr), |
| 76 | (and (i32 (atomic_load_8 node:$addr)), 255)>; |
| 77 | def zext_aload_16 : PatFrag<(ops node:$addr), |
| 78 | (and (i32 (atomic_load_16 node:$addr)), 65535)>; |
| 79 | // Unlike regular loads, extension to i64 is handled differently than i32. |
| 80 | // i64 (zext (i8 (atomic_load_8))) gets legalized to |
| 81 | // i64 (and (i64 (anyext (i32 (atomic_load_8)))), 255) |
| 82 | def zext_aload_8_64 : |
| 83 | PatFrag<(ops node:$addr), |
| 84 | (and (i64 (anyext (i32 (atomic_load_8 node:$addr)))), 255)>; |
| 85 | def zext_aload_16_64 : |
| 86 | PatFrag<(ops node:$addr), |
| 87 | (and (i64 (anyext (i32 (atomic_load_16 node:$addr)))), 65535)>; |
| 88 | def zext_aload_32_64 : |
| 89 | PatFrag<(ops node:$addr), |
| 90 | (zext (i32 (atomic_load node:$addr)))>; |
| 91 | |
| 92 | // We don't have single sext atomic load instructions. So for sext loads, we |
| 93 | // match bare subword loads (for 32-bit results) and anyext loads (for 64-bit |
| 94 | // results) and select a zext load; the next instruction will be sext_inreg |
| 95 | // which is selected by itself. |
| 96 | def anyext_aload_8_64 : |
| 97 | PatFrag<(ops node:$addr), (anyext (i32 (atomic_load_8 node:$addr)))>; |
| 98 | def anyext_aload_16_64 : |
| 99 | PatFrag<(ops node:$addr), (anyext (i32 (atomic_load_16 node:$addr)))>; |
| 100 | |
| 101 | let Predicates = [HasAtomics] in { |
| 102 | // Select zero-extending loads with no constant offset. |
| 103 | def : LoadPatNoOffset<i32, zext_aload_8, ATOMIC_LOAD8_U_I32>; |
| 104 | def : LoadPatNoOffset<i32, zext_aload_16, ATOMIC_LOAD16_U_I32>; |
| 105 | def : LoadPatNoOffset<i64, zext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 106 | def : LoadPatNoOffset<i64, zext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 107 | def : LoadPatNoOffset<i64, zext_aload_32_64, ATOMIC_LOAD32_U_I64>; |
| 108 | |
| 109 | // Select sign-extending loads with no constant offset |
| 110 | def : LoadPatNoOffset<i32, atomic_load_8, ATOMIC_LOAD8_U_I32>; |
| 111 | def : LoadPatNoOffset<i32, atomic_load_16, ATOMIC_LOAD16_U_I32>; |
| 112 | def : LoadPatNoOffset<i64, anyext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 113 | def : LoadPatNoOffset<i64, anyext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 114 | // 32->64 sext load gets selected as i32.atomic.load, i64.extend_s/i64 |
| 115 | |
| 116 | |
| 117 | // Zero-extending loads with constant offset |
| 118 | def : LoadPatImmOff<i32, zext_aload_8, regPlusImm, ATOMIC_LOAD8_U_I32>; |
| 119 | def : LoadPatImmOff<i32, zext_aload_16, regPlusImm, ATOMIC_LOAD16_U_I32>; |
| 120 | def : LoadPatImmOff<i32, zext_aload_8, or_is_add, ATOMIC_LOAD8_U_I32>; |
| 121 | def : LoadPatImmOff<i32, zext_aload_16, or_is_add, ATOMIC_LOAD16_U_I32>; |
| 122 | def : LoadPatImmOff<i64, zext_aload_8_64, regPlusImm, ATOMIC_LOAD8_U_I64>; |
| 123 | def : LoadPatImmOff<i64, zext_aload_16_64, regPlusImm, ATOMIC_LOAD16_U_I64>; |
| 124 | def : LoadPatImmOff<i64, zext_aload_32_64, regPlusImm, ATOMIC_LOAD32_U_I64>; |
| 125 | def : LoadPatImmOff<i64, zext_aload_8_64, or_is_add, ATOMIC_LOAD8_U_I64>; |
| 126 | def : LoadPatImmOff<i64, zext_aload_16_64, or_is_add, ATOMIC_LOAD16_U_I64>; |
| 127 | def : LoadPatImmOff<i64, zext_aload_32_64, or_is_add, ATOMIC_LOAD32_U_I64>; |
| 128 | |
| 129 | // Sign-extending loads with constant offset |
| 130 | def : LoadPatImmOff<i32, atomic_load_8, regPlusImm, ATOMIC_LOAD8_U_I32>; |
| 131 | def : LoadPatImmOff<i32, atomic_load_16, regPlusImm, ATOMIC_LOAD16_U_I32>; |
| 132 | def : LoadPatImmOff<i32, atomic_load_8, or_is_add, ATOMIC_LOAD8_U_I32>; |
| 133 | def : LoadPatImmOff<i32, atomic_load_16, or_is_add, ATOMIC_LOAD16_U_I32>; |
| 134 | def : LoadPatImmOff<i64, anyext_aload_8_64, regPlusImm, ATOMIC_LOAD8_U_I64>; |
| 135 | def : LoadPatImmOff<i64, anyext_aload_16_64, regPlusImm, ATOMIC_LOAD16_U_I64>; |
| 136 | def : LoadPatImmOff<i64, anyext_aload_8_64, or_is_add, ATOMIC_LOAD8_U_I64>; |
| 137 | def : LoadPatImmOff<i64, anyext_aload_16_64, or_is_add, ATOMIC_LOAD16_U_I64>; |
| 138 | // No 32->64 patterns, just use i32.atomic.load and i64.extend_s/i64 |
| 139 | |
| 140 | def : LoadPatGlobalAddr<i32, zext_aload_8, ATOMIC_LOAD8_U_I32>; |
| 141 | def : LoadPatGlobalAddr<i32, zext_aload_16, ATOMIC_LOAD16_U_I32>; |
| 142 | def : LoadPatGlobalAddr<i64, zext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 143 | def : LoadPatGlobalAddr<i64, zext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 144 | def : LoadPatGlobalAddr<i64, zext_aload_32_64, ATOMIC_LOAD32_U_I64>; |
| 145 | def : LoadPatGlobalAddr<i32, atomic_load_8, ATOMIC_LOAD8_U_I32>; |
| 146 | def : LoadPatGlobalAddr<i32, atomic_load_16, ATOMIC_LOAD16_U_I32>; |
| 147 | def : LoadPatGlobalAddr<i64, anyext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 148 | def : LoadPatGlobalAddr<i64, anyext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 149 | |
| 150 | def : LoadPatExternalSym<i32, zext_aload_8, ATOMIC_LOAD8_U_I32>; |
| 151 | def : LoadPatExternalSym<i32, zext_aload_16, ATOMIC_LOAD16_U_I32>; |
| 152 | def : LoadPatExternalSym<i64, zext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 153 | def : LoadPatExternalSym<i64, zext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 154 | def : LoadPatExternalSym<i64, zext_aload_32_64, ATOMIC_LOAD32_U_I64>; |
| 155 | def : LoadPatExternalSym<i32, atomic_load_8, ATOMIC_LOAD8_U_I32>; |
| 156 | def : LoadPatExternalSym<i32, atomic_load_16, ATOMIC_LOAD16_U_I32>; |
| 157 | def : LoadPatExternalSym<i64, anyext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 158 | def : LoadPatExternalSym<i64, anyext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 159 | |
| 160 | |
| 161 | // Extending loads with just a constant offset |
| 162 | def : LoadPatOffsetOnly<i32, zext_aload_8, ATOMIC_LOAD8_U_I32>; |
| 163 | def : LoadPatOffsetOnly<i32, zext_aload_16, ATOMIC_LOAD16_U_I32>; |
| 164 | def : LoadPatOffsetOnly<i64, zext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 165 | def : LoadPatOffsetOnly<i64, zext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 166 | def : LoadPatOffsetOnly<i64, zext_aload_32_64, ATOMIC_LOAD32_U_I64>; |
| 167 | def : LoadPatOffsetOnly<i32, atomic_load_8, ATOMIC_LOAD8_U_I32>; |
| 168 | def : LoadPatOffsetOnly<i32, atomic_load_16, ATOMIC_LOAD16_U_I32>; |
| 169 | def : LoadPatOffsetOnly<i64, anyext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 170 | def : LoadPatOffsetOnly<i64, anyext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 171 | |
| 172 | def : LoadPatGlobalAddrOffOnly<i32, zext_aload_8, ATOMIC_LOAD8_U_I32>; |
| 173 | def : LoadPatGlobalAddrOffOnly<i32, zext_aload_16, ATOMIC_LOAD16_U_I32>; |
| 174 | def : LoadPatGlobalAddrOffOnly<i64, zext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 175 | def : LoadPatGlobalAddrOffOnly<i64, zext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 176 | def : LoadPatGlobalAddrOffOnly<i64, zext_aload_32_64, ATOMIC_LOAD32_U_I64>; |
| 177 | def : LoadPatGlobalAddrOffOnly<i32, atomic_load_8, ATOMIC_LOAD8_U_I32>; |
| 178 | def : LoadPatGlobalAddrOffOnly<i32, atomic_load_16, ATOMIC_LOAD16_U_I32>; |
| 179 | def : LoadPatGlobalAddrOffOnly<i64, anyext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 180 | def : LoadPatGlobalAddrOffOnly<i64, anyext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 181 | |
| 182 | def : LoadPatExternSymOffOnly<i32, zext_aload_8, ATOMIC_LOAD8_U_I32>; |
| 183 | def : LoadPatExternSymOffOnly<i32, zext_aload_16, ATOMIC_LOAD16_U_I32>; |
| 184 | def : LoadPatExternSymOffOnly<i64, zext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 185 | def : LoadPatExternSymOffOnly<i64, zext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 186 | def : LoadPatExternSymOffOnly<i64, zext_aload_32_64, ATOMIC_LOAD32_U_I64>; |
| 187 | def : LoadPatExternSymOffOnly<i32, atomic_load_8, ATOMIC_LOAD8_U_I32>; |
| 188 | def : LoadPatExternSymOffOnly<i32, atomic_load_16, ATOMIC_LOAD16_U_I32>; |
| 189 | def : LoadPatExternSymOffOnly<i64, anyext_aload_8_64, ATOMIC_LOAD8_U_I64>; |
| 190 | def : LoadPatExternSymOffOnly<i64, anyext_aload_16_64, ATOMIC_LOAD16_U_I64>; |
| 191 | |
| 192 | |
| 193 | } // Predicates = [HasAtomics] |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 194 | |
| 195 | //===----------------------------------------------------------------------===// |
| 196 | // Atomic stores |
| 197 | //===----------------------------------------------------------------------===// |
| 198 | |
Heejin Ahn | 402b490 | 2018-07-02 21:22:59 +0000 | [diff] [blame^] | 199 | let Defs = [ARGUMENTS] in { |
| 200 | defm ATOMIC_STORE_I32 : WebAssemblyStore<I32, "i32.atomic.store", 0xfe17>; |
| 201 | defm ATOMIC_STORE_I64 : WebAssemblyStore<I64, "i64.atomic.store", 0xfe18>; |
| 202 | } // Defs = [ARGUMENTS] |
| 203 | |
| 204 | // We need an 'atomic' version of store patterns because store and atomic_store |
| 205 | // nodes have different operand orders: |
| 206 | // store: (store $val, $ptr) |
| 207 | // atomic_store: (store $ptr, $val) |
| 208 | |
| 209 | let Predicates = [HasAtomics] in { |
| 210 | |
| 211 | // Select stores with no constant offset. |
| 212 | class AStorePatNoOffset<ValueType ty, PatFrag node, NI inst> : |
| 213 | Pat<(node I32:$addr, ty:$val), (inst 0, 0, $addr, $val)>; |
| 214 | def : AStorePatNoOffset<i32, atomic_store_32, ATOMIC_STORE_I32>; |
| 215 | def : AStorePatNoOffset<i64, atomic_store_64, ATOMIC_STORE_I64>; |
| 216 | |
| 217 | // Select stores with a constant offset. |
| 218 | |
| 219 | // Pattern with address + immediate offset |
| 220 | class AStorePatImmOff<ValueType ty, PatFrag storekind, PatFrag operand, |
| 221 | NI inst> : |
| 222 | Pat<(storekind (operand I32:$addr, imm:$off), ty:$val), |
| 223 | (inst 0, imm:$off, $addr, ty:$val)>; |
| 224 | def : AStorePatImmOff<i32, atomic_store_32, regPlusImm, ATOMIC_STORE_I32>; |
| 225 | def : AStorePatImmOff<i64, atomic_store_64, regPlusImm, ATOMIC_STORE_I64>; |
| 226 | def : AStorePatImmOff<i32, atomic_store_32, or_is_add, ATOMIC_STORE_I32>; |
| 227 | def : AStorePatImmOff<i64, atomic_store_64, or_is_add, ATOMIC_STORE_I64>; |
| 228 | |
| 229 | class AStorePatGlobalAddr<ValueType ty, PatFrag storekind, NI inst> : |
| 230 | Pat<(storekind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), |
| 231 | ty:$val), |
| 232 | (inst 0, tglobaladdr:$off, I32:$addr, ty:$val)>; |
| 233 | def : AStorePatGlobalAddr<i32, atomic_store_32, ATOMIC_STORE_I32>; |
| 234 | def : AStorePatGlobalAddr<i64, atomic_store_64, ATOMIC_STORE_I64>; |
| 235 | |
| 236 | class AStorePatExternalSym<ValueType ty, PatFrag storekind, NI inst> : |
| 237 | Pat<(storekind (add I32:$addr, (WebAssemblywrapper texternalsym:$off)), |
| 238 | ty:$val), |
| 239 | (inst 0, texternalsym:$off, I32:$addr, ty:$val)>; |
| 240 | def : AStorePatExternalSym<i32, atomic_store_32, ATOMIC_STORE_I32>; |
| 241 | def : AStorePatExternalSym<i64, atomic_store_64, ATOMIC_STORE_I64>; |
| 242 | |
| 243 | // Select stores with just a constant offset. |
| 244 | class AStorePatOffsetOnly<ValueType ty, PatFrag storekind, NI inst> : |
| 245 | Pat<(storekind imm:$off, ty:$val), |
| 246 | (inst 0, imm:$off, (CONST_I32 0), ty:$val)>; |
| 247 | def : AStorePatOffsetOnly<i32, atomic_store_32, ATOMIC_STORE_I32>; |
| 248 | def : AStorePatOffsetOnly<i64, atomic_store_64, ATOMIC_STORE_I64>; |
| 249 | |
| 250 | class AStorePatGlobalAddrOffOnly<ValueType ty, PatFrag storekind, NI inst> : |
| 251 | Pat<(storekind (WebAssemblywrapper tglobaladdr:$off), ty:$val), |
| 252 | (inst 0, tglobaladdr:$off, (CONST_I32 0), ty:$val)>; |
| 253 | def : AStorePatGlobalAddrOffOnly<i32, atomic_store_32, ATOMIC_STORE_I32>; |
| 254 | def : AStorePatGlobalAddrOffOnly<i64, atomic_store_64, ATOMIC_STORE_I64>; |
| 255 | |
| 256 | class AStorePatExternSymOffOnly<ValueType ty, PatFrag storekind, NI inst> : |
| 257 | Pat<(storekind (WebAssemblywrapper texternalsym:$off), ty:$val), |
| 258 | (inst 0, texternalsym:$off, (CONST_I32 0), ty:$val)>; |
| 259 | def : AStorePatExternSymOffOnly<i32, atomic_store_32, ATOMIC_STORE_I32>; |
| 260 | def : AStorePatExternSymOffOnly<i64, atomic_store_64, ATOMIC_STORE_I64>; |
| 261 | |
| 262 | } // Predicates = [HasAtomics] |
| 263 | |
| 264 | // Truncating stores. |
| 265 | let Defs = [ARGUMENTS] in { |
| 266 | defm ATOMIC_STORE8_I32 : WebAssemblyStore<I32, "i32.atomic.store8", 0xfe19>; |
| 267 | defm ATOMIC_STORE16_I32 : WebAssemblyStore<I32, "i32.atomic.store16", 0xfe1a>; |
| 268 | defm ATOMIC_STORE8_I64 : WebAssemblyStore<I64, "i64.atomic.store8", 0xfe1b>; |
| 269 | defm ATOMIC_STORE16_I64 : WebAssemblyStore<I64, "i64.atomic.store16", 0xfe1c>; |
| 270 | defm ATOMIC_STORE32_I64 : WebAssemblyStore<I64, "i64.atomic.store32", 0xfe1d>; |
| 271 | } // Defs = [ARGUMENTS] |
| 272 | |
| 273 | // Fragments for truncating stores. |
| 274 | |
| 275 | // We don't have single truncating atomic store instructions. For 32-bit |
| 276 | // instructions, we just need to match bare atomic stores. On the other hand, |
| 277 | // truncating stores from i64 values are once truncated to i32 first. |
| 278 | class trunc_astore_64<PatFrag storekind> : |
| 279 | PatFrag<(ops node:$addr, node:$val), |
| 280 | (storekind node:$addr, (i32 (trunc (i64 node:$val))))>; |
| 281 | def trunc_astore_8_64 : trunc_astore_64<atomic_store_8>; |
| 282 | def trunc_astore_16_64 : trunc_astore_64<atomic_store_16>; |
| 283 | def trunc_astore_32_64 : trunc_astore_64<atomic_store_32>; |
| 284 | |
| 285 | let Predicates = [HasAtomics] in { |
| 286 | |
| 287 | // Truncating stores with no constant offset |
| 288 | def : AStorePatNoOffset<i32, atomic_store_8, ATOMIC_STORE8_I32>; |
| 289 | def : AStorePatNoOffset<i32, atomic_store_16, ATOMIC_STORE16_I32>; |
| 290 | def : AStorePatNoOffset<i64, trunc_astore_8_64, ATOMIC_STORE8_I64>; |
| 291 | def : AStorePatNoOffset<i64, trunc_astore_16_64, ATOMIC_STORE16_I64>; |
| 292 | def : AStorePatNoOffset<i64, trunc_astore_32_64, ATOMIC_STORE32_I64>; |
| 293 | |
| 294 | // Truncating stores with a constant offset |
| 295 | def : AStorePatImmOff<i32, atomic_store_8, regPlusImm, ATOMIC_STORE8_I32>; |
| 296 | def : AStorePatImmOff<i32, atomic_store_16, regPlusImm, ATOMIC_STORE16_I32>; |
| 297 | def : AStorePatImmOff<i64, trunc_astore_8_64, regPlusImm, ATOMIC_STORE8_I64>; |
| 298 | def : AStorePatImmOff<i64, trunc_astore_16_64, regPlusImm, ATOMIC_STORE16_I64>; |
| 299 | def : AStorePatImmOff<i64, trunc_astore_32_64, regPlusImm, ATOMIC_STORE32_I64>; |
| 300 | def : AStorePatImmOff<i32, atomic_store_8, or_is_add, ATOMIC_STORE8_I32>; |
| 301 | def : AStorePatImmOff<i32, atomic_store_16, or_is_add, ATOMIC_STORE16_I32>; |
| 302 | def : AStorePatImmOff<i64, trunc_astore_8_64, or_is_add, ATOMIC_STORE8_I64>; |
| 303 | def : AStorePatImmOff<i64, trunc_astore_16_64, or_is_add, ATOMIC_STORE16_I64>; |
| 304 | def : AStorePatImmOff<i64, trunc_astore_32_64, or_is_add, ATOMIC_STORE32_I64>; |
| 305 | |
| 306 | def : AStorePatGlobalAddr<i32, atomic_store_8, ATOMIC_STORE8_I32>; |
| 307 | def : AStorePatGlobalAddr<i32, atomic_store_16, ATOMIC_STORE16_I32>; |
| 308 | def : AStorePatGlobalAddr<i64, trunc_astore_8_64, ATOMIC_STORE8_I64>; |
| 309 | def : AStorePatGlobalAddr<i64, trunc_astore_16_64, ATOMIC_STORE16_I64>; |
| 310 | def : AStorePatGlobalAddr<i64, trunc_astore_32_64, ATOMIC_STORE32_I64>; |
| 311 | |
| 312 | def : AStorePatExternalSym<i32, atomic_store_8, ATOMIC_STORE8_I32>; |
| 313 | def : AStorePatExternalSym<i32, atomic_store_16, ATOMIC_STORE16_I32>; |
| 314 | def : AStorePatExternalSym<i64, trunc_astore_8_64, ATOMIC_STORE8_I64>; |
| 315 | def : AStorePatExternalSym<i64, trunc_astore_16_64, ATOMIC_STORE16_I64>; |
| 316 | def : AStorePatExternalSym<i64, trunc_astore_32_64, ATOMIC_STORE32_I64>; |
| 317 | |
| 318 | // Truncating stores with just a constant offset |
| 319 | def : AStorePatOffsetOnly<i32, atomic_store_8, ATOMIC_STORE8_I32>; |
| 320 | def : AStorePatOffsetOnly<i32, atomic_store_16, ATOMIC_STORE16_I32>; |
| 321 | def : AStorePatOffsetOnly<i64, trunc_astore_8_64, ATOMIC_STORE8_I64>; |
| 322 | def : AStorePatOffsetOnly<i64, trunc_astore_16_64, ATOMIC_STORE16_I64>; |
| 323 | def : AStorePatOffsetOnly<i64, trunc_astore_32_64, ATOMIC_STORE32_I64>; |
| 324 | |
| 325 | def : AStorePatGlobalAddrOffOnly<i32, atomic_store_8, ATOMIC_STORE8_I32>; |
| 326 | def : AStorePatGlobalAddrOffOnly<i32, atomic_store_16, ATOMIC_STORE16_I32>; |
| 327 | def : AStorePatGlobalAddrOffOnly<i64, trunc_astore_8_64, ATOMIC_STORE8_I64>; |
| 328 | def : AStorePatGlobalAddrOffOnly<i64, trunc_astore_16_64, ATOMIC_STORE16_I64>; |
| 329 | def : AStorePatGlobalAddrOffOnly<i64, trunc_astore_32_64, ATOMIC_STORE32_I64>; |
| 330 | |
| 331 | def : AStorePatExternSymOffOnly<i32, atomic_store_8, ATOMIC_STORE8_I32>; |
| 332 | def : AStorePatExternSymOffOnly<i32, atomic_store_16, ATOMIC_STORE16_I32>; |
| 333 | def : AStorePatExternSymOffOnly<i64, trunc_astore_8_64, ATOMIC_STORE8_I64>; |
| 334 | def : AStorePatExternSymOffOnly<i64, trunc_astore_16_64, ATOMIC_STORE16_I64>; |
| 335 | def : AStorePatExternSymOffOnly<i64, trunc_astore_32_64, ATOMIC_STORE32_I64>; |
| 336 | |
| 337 | } // Predicates = [HasAtomics] |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 338 | |
| 339 | //===----------------------------------------------------------------------===// |
| 340 | // Low-level exclusive operations |
| 341 | //===----------------------------------------------------------------------===// |
| 342 | |
| 343 | // TODO: add exclusive operations here... |
| 344 | |
| 345 | // Load-exclusives. |
| 346 | |
| 347 | // Store-exclusives. |
| 348 | |
| 349 | // Store-release-exclusives. |
| 350 | |
| 351 | // And clear exclusive. |
Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame] | 352 | |