Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 1 | // WebAssemblyInstrInfo.td-Describe the WebAssembly Instructions-*- 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 Instruction definitions. |
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 | |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | // WebAssembly Instruction Predicate Definitions. |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | |
JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 19 | def HasAddr32 : Predicate<"!Subtarget->hasAddr64()">; |
| 20 | def HasAddr64 : Predicate<"Subtarget->hasAddr64()">; |
| 21 | def HasSIMD128 : Predicate<"Subtarget->hasSIMD128()">, |
| 22 | AssemblerPredicate<"FeatureSIMD128", "simd128">; |
Thomas Lively | 8dbf29af | 2018-12-20 02:10:22 +0000 | [diff] [blame^] | 23 | def HasUnimplementedSIMD : Predicate<"EnableUnimplementedWasmSIMDInstrs">; |
Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame] | 24 | def HasAtomics : Predicate<"Subtarget->hasAtomics()">, |
| 25 | AssemblerPredicate<"FeatureAtomics", "atomics">; |
Dan Gohman | cdd48b8 | 2017-11-28 01:13:40 +0000 | [diff] [blame] | 26 | def HasNontrappingFPToInt : |
| 27 | Predicate<"Subtarget->hasNontrappingFPToInt()">, |
| 28 | AssemblerPredicate<"FeatureNontrappingFPToInt", |
| 29 | "nontrapping-fptoint">; |
| 30 | def NotHasNontrappingFPToInt : |
| 31 | Predicate<"!Subtarget->hasNontrappingFPToInt()">, |
| 32 | AssemblerPredicate<"!FeatureNontrappingFPToInt", |
| 33 | "nontrapping-fptoint">; |
Dan Gohman | 5d2b935 | 2018-01-19 17:16:24 +0000 | [diff] [blame] | 34 | def HasSignExt : |
| 35 | Predicate<"Subtarget->hasSignExt()">, |
| 36 | AssemblerPredicate<"FeatureSignExt", |
| 37 | "sign-ext">; |
| 38 | def NotHasSignExt : |
| 39 | Predicate<"!Subtarget->hasSignExt()">, |
| 40 | AssemblerPredicate<"!FeatureSignExt", |
| 41 | "sign-ext">; |
JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 42 | |
Heejin Ahn | 9386bde | 2018-02-24 00:40:50 +0000 | [diff] [blame] | 43 | def HasExceptionHandling : |
| 44 | Predicate<"Subtarget->hasExceptionHandling()">, |
| 45 | AssemblerPredicate<"FeatureExceptionHandling", |
| 46 | "exception-handling">; |
| 47 | |
| 48 | def NotHasExceptionHandling : |
| 49 | Predicate<"!Subtarget->hasExceptionHandling()">, |
| 50 | AssemblerPredicate<"!FeatureExceptionHandling", |
| 51 | "exception-handling">; |
| 52 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 53 | //===----------------------------------------------------------------------===// |
| 54 | // WebAssembly-specific DAG Node Types. |
| 55 | //===----------------------------------------------------------------------===// |
| 56 | |
Serge Pavlov | d526b13 | 2017-05-09 13:35:13 +0000 | [diff] [blame] | 57 | def SDT_WebAssemblyCallSeqStart : SDCallSeqStart<[SDTCisVT<0, iPTR>, |
| 58 | SDTCisVT<1, iPTR>]>; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 59 | def SDT_WebAssemblyCallSeqEnd : |
| 60 | SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>; |
Dan Gohman | f71abef | 2015-09-09 16:13:47 +0000 | [diff] [blame] | 61 | def SDT_WebAssemblyCall0 : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>; |
| 62 | def SDT_WebAssemblyCall1 : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>; |
Dan Gohman | 1402606 | 2016-03-08 03:18:12 +0000 | [diff] [blame] | 63 | def SDT_WebAssemblyBrTable : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 64 | def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>; |
JF Bastien | 4a2d560 | 2015-07-31 21:04:18 +0000 | [diff] [blame] | 65 | def SDT_WebAssemblyReturn : SDTypeProfile<0, -1, []>; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 66 | def SDT_WebAssemblyWrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, |
| 67 | SDTCisPtrTy<0>]>; |
Heejin Ahn | da419bd | 2018-11-14 02:46:21 +0000 | [diff] [blame] | 68 | def SDT_WebAssemblyThrow : SDTypeProfile<0, 2, [SDTCisPtrTy<0>]>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 69 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 70 | //===----------------------------------------------------------------------===// |
| 71 | // WebAssembly-specific DAG Nodes. |
| 72 | //===----------------------------------------------------------------------===// |
| 73 | |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 74 | def WebAssemblycallseq_start : |
| 75 | SDNode<"ISD::CALLSEQ_START", SDT_WebAssemblyCallSeqStart, |
| 76 | [SDNPHasChain, SDNPOutGlue]>; |
| 77 | def WebAssemblycallseq_end : |
| 78 | SDNode<"ISD::CALLSEQ_END", SDT_WebAssemblyCallSeqEnd, |
| 79 | [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; |
Dan Gohman | f71abef | 2015-09-09 16:13:47 +0000 | [diff] [blame] | 80 | def WebAssemblycall0 : SDNode<"WebAssemblyISD::CALL0", |
| 81 | SDT_WebAssemblyCall0, |
| 82 | [SDNPHasChain, SDNPVariadic]>; |
| 83 | def WebAssemblycall1 : SDNode<"WebAssemblyISD::CALL1", |
| 84 | SDT_WebAssemblyCall1, |
| 85 | [SDNPHasChain, SDNPVariadic]>; |
Dan Gohman | 1402606 | 2016-03-08 03:18:12 +0000 | [diff] [blame] | 86 | def WebAssemblybr_table : SDNode<"WebAssemblyISD::BR_TABLE", |
| 87 | SDT_WebAssemblyBrTable, |
| 88 | [SDNPHasChain, SDNPVariadic]>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 89 | def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT", |
| 90 | SDT_WebAssemblyArgument>; |
| 91 | def WebAssemblyreturn : SDNode<"WebAssemblyISD::RETURN", |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 92 | SDT_WebAssemblyReturn, [SDNPHasChain]>; |
| 93 | def WebAssemblywrapper : SDNode<"WebAssemblyISD::Wrapper", |
| 94 | SDT_WebAssemblyWrapper>; |
Heejin Ahn | da419bd | 2018-11-14 02:46:21 +0000 | [diff] [blame] | 95 | def WebAssemblythrow : SDNode<"WebAssemblyISD::THROW", SDT_WebAssemblyThrow, |
| 96 | [SDNPHasChain]>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 97 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 98 | //===----------------------------------------------------------------------===// |
| 99 | // WebAssembly-specific Operands. |
| 100 | //===----------------------------------------------------------------------===// |
| 101 | |
Dan Gohman | a11fb23 | 2016-01-12 03:09:16 +0000 | [diff] [blame] | 102 | let OperandNamespace = "WebAssembly" in { |
| 103 | |
| 104 | let OperandType = "OPERAND_BASIC_BLOCK" in |
Dan Gohman | 950a13c | 2015-09-16 16:51:30 +0000 | [diff] [blame] | 105 | def bb_op : Operand<OtherVT>; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 106 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 107 | let OperandType = "OPERAND_LOCAL" in |
| 108 | def local_op : Operand<i32>; |
| 109 | |
Dan Gohman | b89f2d3 | 2017-02-02 19:29:44 +0000 | [diff] [blame] | 110 | let OperandType = "OPERAND_GLOBAL" in |
| 111 | def global_op : Operand<i32>; |
| 112 | |
Dan Gohman | 5a68ec7 | 2016-10-05 21:24:08 +0000 | [diff] [blame] | 113 | let OperandType = "OPERAND_I32IMM" in |
| 114 | def i32imm_op : Operand<i32>; |
| 115 | |
| 116 | let OperandType = "OPERAND_I64IMM" in |
| 117 | def i64imm_op : Operand<i64>; |
| 118 | |
Dan Gohman | 4b8e8be | 2016-10-03 21:31:31 +0000 | [diff] [blame] | 119 | let OperandType = "OPERAND_F32IMM" in |
Dan Gohman | a11fb23 | 2016-01-12 03:09:16 +0000 | [diff] [blame] | 120 | def f32imm_op : Operand<f32>; |
Dan Gohman | aa74291 | 2016-02-16 15:14:23 +0000 | [diff] [blame] | 121 | |
Dan Gohman | 4b8e8be | 2016-10-03 21:31:31 +0000 | [diff] [blame] | 122 | let OperandType = "OPERAND_F64IMM" in |
Dan Gohman | a11fb23 | 2016-01-12 03:09:16 +0000 | [diff] [blame] | 123 | def f64imm_op : Operand<f64>; |
Dan Gohman | a11fb23 | 2016-01-12 03:09:16 +0000 | [diff] [blame] | 124 | |
Thomas Lively | 2244292 | 2018-08-21 21:03:18 +0000 | [diff] [blame] | 125 | let OperandType = "OPERAND_VEC_I8IMM" in |
| 126 | def vec_i8imm_op : Operand<i32>; |
| 127 | |
| 128 | let OperandType = "OPERAND_VEC_I16IMM" in |
| 129 | def vec_i16imm_op : Operand<i32>; |
| 130 | |
| 131 | let OperandType = "OPERAND_VEC_I32IMM" in |
| 132 | def vec_i32imm_op : Operand<i32>; |
| 133 | |
| 134 | let OperandType = "OPERAND_VEC_I64IMM" in |
| 135 | def vec_i64imm_op : Operand<i64>; |
| 136 | |
Dan Gohman | 00d734d | 2016-12-23 03:23:52 +0000 | [diff] [blame] | 137 | let OperandType = "OPERAND_FUNCTION32" in |
| 138 | def function32_op : Operand<i32>; |
| 139 | |
| 140 | let OperandType = "OPERAND_OFFSET32" in |
| 141 | def offset32_op : Operand<i32>; |
| 142 | |
Dan Gohman | bb37224 | 2016-01-26 03:39:31 +0000 | [diff] [blame] | 143 | let OperandType = "OPERAND_P2ALIGN" in { |
| 144 | def P2Align : Operand<i32> { |
| 145 | let PrintMethod = "printWebAssemblyP2AlignOperand"; |
| 146 | } |
Heejin Ahn | da419bd | 2018-11-14 02:46:21 +0000 | [diff] [blame] | 147 | |
| 148 | let OperandType = "OPERAND_EVENT" in |
| 149 | def event_op : Operand<i32>; |
| 150 | |
Dan Gohman | bb37224 | 2016-01-26 03:39:31 +0000 | [diff] [blame] | 151 | } // OperandType = "OPERAND_P2ALIGN" |
| 152 | |
Dan Gohman | 2726b88 | 2016-10-06 22:29:32 +0000 | [diff] [blame] | 153 | let OperandType = "OPERAND_SIGNATURE" in { |
| 154 | def Signature : Operand<i32> { |
| 155 | let PrintMethod = "printWebAssemblySignatureOperand"; |
| 156 | } |
| 157 | } // OperandType = "OPERAND_SIGNATURE" |
| 158 | |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 159 | let OperandType = "OPERAND_TYPEINDEX" in |
| 160 | def TypeIndex : Operand<i32>; |
| 161 | |
Dan Gohman | a11fb23 | 2016-01-12 03:09:16 +0000 | [diff] [blame] | 162 | } // OperandNamespace = "WebAssembly" |
| 163 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 164 | //===----------------------------------------------------------------------===// |
Thomas Lively | c63b5fc | 2018-10-22 21:55:26 +0000 | [diff] [blame] | 165 | // WebAssembly Register to Stack instruction mapping |
| 166 | //===----------------------------------------------------------------------===// |
| 167 | |
| 168 | class StackRel; |
| 169 | def getStackOpcode : InstrMapping { |
| 170 | let FilterClass = "StackRel"; |
| 171 | let RowFields = ["BaseName"]; |
| 172 | let ColFields = ["StackBased"]; |
| 173 | let KeyCol = ["false"]; |
| 174 | let ValueCols = [["true"]]; |
| 175 | } |
| 176 | |
| 177 | //===----------------------------------------------------------------------===// |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 178 | // WebAssembly Instruction Format Definitions. |
| 179 | //===----------------------------------------------------------------------===// |
| 180 | |
| 181 | include "WebAssemblyInstrFormats.td" |
| 182 | |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 183 | //===----------------------------------------------------------------------===// |
| 184 | // Additional instructions. |
| 185 | //===----------------------------------------------------------------------===// |
| 186 | |
Thomas Lively | 0ff82ac | 2018-10-13 07:09:10 +0000 | [diff] [blame] | 187 | multiclass ARGUMENT<WebAssemblyRegClass reg, ValueType vt> { |
Thomas Lively | f04bed8 | 2018-10-11 20:21:22 +0000 | [diff] [blame] | 188 | let hasSideEffects = 1, isCodeGenOnly = 1, |
| 189 | Defs = []<Register>, Uses = [ARGUMENTS] in |
Thomas Lively | 0ff82ac | 2018-10-13 07:09:10 +0000 | [diff] [blame] | 190 | defm ARGUMENT_#vt : |
| 191 | I<(outs reg:$res), (ins i32imm:$argno), (outs), (ins i32imm:$argno), |
| 192 | [(set (vt reg:$res), (WebAssemblyargument timm:$argno))]>; |
JF Bastien | 8f9aea0 | 2015-08-01 04:48:44 +0000 | [diff] [blame] | 193 | } |
Thomas Lively | 0ff82ac | 2018-10-13 07:09:10 +0000 | [diff] [blame] | 194 | defm "": ARGUMENT<I32, i32>; |
| 195 | defm "": ARGUMENT<I64, i64>; |
| 196 | defm "": ARGUMENT<F32, f32>; |
| 197 | defm "": ARGUMENT<F64, f64>; |
| 198 | defm "": ARGUMENT<EXCEPT_REF, ExceptRef>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 199 | |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 200 | // get_local and set_local are not generated by instruction selection; they |
Dan Gohman | adf2817 | 2016-01-28 01:22:44 +0000 | [diff] [blame] | 201 | // are implied by virtual register uses and defs. |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 202 | multiclass LOCAL<WebAssemblyRegClass vt> { |
Dan Gohman | 4817a75 | 2016-05-16 19:16:32 +0000 | [diff] [blame] | 203 | let hasSideEffects = 0 in { |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 204 | // COPY is not an actual instruction in wasm, but since we allow get_local and |
| 205 | // set_local to be implicit during most of codegen, we can have a COPY which |
| 206 | // is actually a no-op because all the work is done in the implied get_local |
| 207 | // and set_local. COPYs are eliminated (and replaced with |
| 208 | // get_local/set_local) in the ExplicitLocals pass. |
| 209 | let isAsCheapAsAMove = 1, isCodeGenOnly = 1 in |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 210 | defm COPY_#vt : I<(outs vt:$res), (ins vt:$src), (outs), (ins), [], |
| 211 | "copy_local\t$res, $src", "copy_local">; |
Dan Gohman | adf2817 | 2016-01-28 01:22:44 +0000 | [diff] [blame] | 212 | |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 213 | // TEE is similar to COPY, but writes two copies of its result. Typically |
| 214 | // this would be used to stackify one result and write the other result to a |
| 215 | // local. |
| 216 | let isAsCheapAsAMove = 1, isCodeGenOnly = 1 in |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 217 | defm TEE_#vt : I<(outs vt:$res, vt:$also), (ins vt:$src), (outs), (ins), [], |
| 218 | "tee_local\t$res, $also, $src", "tee_local">; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 219 | |
| 220 | // This is the actual get_local instruction in wasm. These are made explicit |
| 221 | // by the ExplicitLocals pass. It has mayLoad because it reads from a wasm |
| 222 | // local, which is a side effect not otherwise modeled in LLVM. |
| 223 | let mayLoad = 1, isAsCheapAsAMove = 1 in |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 224 | defm GET_LOCAL_#vt : I<(outs vt:$res), (ins local_op:$local), |
| 225 | (outs), (ins local_op:$local), [], |
| 226 | "get_local\t$res, $local", "get_local\t$local", 0x20>; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 227 | |
| 228 | // This is the actual set_local instruction in wasm. These are made explicit |
| 229 | // by the ExplicitLocals pass. It has mayStore because it writes to a wasm |
| 230 | // local, which is a side effect not otherwise modeled in LLVM. |
| 231 | let mayStore = 1, isAsCheapAsAMove = 1 in |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 232 | defm SET_LOCAL_#vt : I<(outs), (ins local_op:$local, vt:$src), |
| 233 | (outs), (ins local_op:$local), [], |
| 234 | "set_local\t$local, $src", "set_local\t$local", 0x21>; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 235 | |
| 236 | // This is the actual tee_local instruction in wasm. TEEs are turned into |
| 237 | // TEE_LOCALs by the ExplicitLocals pass. It has mayStore for the same reason |
| 238 | // as SET_LOCAL. |
| 239 | let mayStore = 1, isAsCheapAsAMove = 1 in |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 240 | defm TEE_LOCAL_#vt : I<(outs vt:$res), (ins local_op:$local, vt:$src), |
| 241 | (outs), (ins local_op:$local), [], |
| 242 | "tee_local\t$res, $local, $src", "tee_local\t$local", |
| 243 | 0x22>; |
Dan Gohman | 4fc4e42 | 2016-10-24 19:49:43 +0000 | [diff] [blame] | 244 | |
Dan Gohman | b89f2d3 | 2017-02-02 19:29:44 +0000 | [diff] [blame] | 245 | // Unused values must be dropped in some contexts. |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 246 | defm DROP_#vt : I<(outs), (ins vt:$src), (outs), (ins), [], |
| 247 | "drop\t$src", "drop", 0x1a>; |
Dan Gohman | b89f2d3 | 2017-02-02 19:29:44 +0000 | [diff] [blame] | 248 | |
| 249 | let mayLoad = 1 in |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 250 | defm GET_GLOBAL_#vt : I<(outs vt:$res), (ins global_op:$local), |
| 251 | (outs), (ins global_op:$local), [], |
| 252 | "get_global\t$res, $local", "get_global\t$local", |
| 253 | 0x23>; |
Dan Gohman | b89f2d3 | 2017-02-02 19:29:44 +0000 | [diff] [blame] | 254 | |
| 255 | let mayStore = 1 in |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 256 | defm SET_GLOBAL_#vt : I<(outs), (ins global_op:$local, vt:$src), |
| 257 | (outs), (ins global_op:$local), [], |
| 258 | "set_global\t$local, $src", "set_global\t$local", |
| 259 | 0x24>; |
Dan Gohman | b89f2d3 | 2017-02-02 19:29:44 +0000 | [diff] [blame] | 260 | |
Dan Gohman | 4817a75 | 2016-05-16 19:16:32 +0000 | [diff] [blame] | 261 | } // hasSideEffects = 0 |
Dan Gohman | 4ba4816 | 2015-11-18 16:12:01 +0000 | [diff] [blame] | 262 | } |
Sam Clegg | 537afe6 | 2018-06-04 16:59:26 +0000 | [diff] [blame] | 263 | defm "" : LOCAL<I32>; |
| 264 | defm "" : LOCAL<I64>; |
| 265 | defm "" : LOCAL<F32>; |
| 266 | defm "" : LOCAL<F64>; |
| 267 | defm "" : LOCAL<V128>, Requires<[HasSIMD128]>; |
| 268 | defm "" : LOCAL<EXCEPT_REF>, Requires<[HasExceptionHandling]>; |
JF Bastien | 4a64225 | 2015-08-10 22:36:48 +0000 | [diff] [blame] | 269 | |
Dan Gohman | b6fd39a | 2016-01-19 16:59:23 +0000 | [diff] [blame] | 270 | let isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1 in { |
Wouter van Oortmerssen | 48dac31 | 2018-06-18 21:22:44 +0000 | [diff] [blame] | 271 | defm CONST_I32 : I<(outs I32:$res), (ins i32imm_op:$imm), |
| 272 | (outs), (ins i32imm_op:$imm), |
| 273 | [(set I32:$res, imm:$imm)], |
| 274 | "i32.const\t$res, $imm", "i32.const\t$imm", 0x41>; |
| 275 | defm CONST_I64 : I<(outs I64:$res), (ins i64imm_op:$imm), |
| 276 | (outs), (ins i64imm_op:$imm), |
| 277 | [(set I64:$res, imm:$imm)], |
| 278 | "i64.const\t$res, $imm", "i64.const\t$imm", 0x42>; |
| 279 | defm CONST_F32 : I<(outs F32:$res), (ins f32imm_op:$imm), |
| 280 | (outs), (ins f32imm_op:$imm), |
| 281 | [(set F32:$res, fpimm:$imm)], |
| 282 | "f32.const\t$res, $imm", "f32.const\t$imm", 0x43>; |
| 283 | defm CONST_F64 : I<(outs F64:$res), (ins f64imm_op:$imm), |
| 284 | (outs), (ins f64imm_op:$imm), |
| 285 | [(set F64:$res, fpimm:$imm)], |
| 286 | "f64.const\t$res, $imm", "f64.const\t$imm", 0x44>; |
Dan Gohman | b6fd39a | 2016-01-19 16:59:23 +0000 | [diff] [blame] | 287 | } // isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1 |
JF Bastien | 4a64225 | 2015-08-10 22:36:48 +0000 | [diff] [blame] | 288 | |
Dan Gohman | 8633eed | 2016-01-08 00:50:33 +0000 | [diff] [blame] | 289 | def : Pat<(i32 (WebAssemblywrapper tglobaladdr:$addr)), |
| 290 | (CONST_I32 tglobaladdr:$addr)>; |
| 291 | def : Pat<(i32 (WebAssemblywrapper texternalsym:$addr)), |
| 292 | (CONST_I32 texternalsym:$addr)>; |
Heejin Ahn | 24faf85 | 2018-10-25 23:55:10 +0000 | [diff] [blame] | 293 | def : Pat<(i32 (WebAssemblywrapper mcsym:$sym)), (CONST_I32 mcsym:$sym)>; |
| 294 | def : Pat<(i64 (WebAssemblywrapper mcsym:$sym)), (CONST_I64 mcsym:$sym)>; |
Derek Schuff | 71e8169 | 2015-11-17 00:20:44 +0000 | [diff] [blame] | 295 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 296 | //===----------------------------------------------------------------------===// |
| 297 | // Additional sets of instructions. |
| 298 | //===----------------------------------------------------------------------===// |
| 299 | |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 300 | include "WebAssemblyInstrMemory.td" |
| 301 | include "WebAssemblyInstrCall.td" |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 302 | include "WebAssemblyInstrControl.td" |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 303 | include "WebAssemblyInstrInteger.td" |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 304 | include "WebAssemblyInstrConv.td" |
Dan Gohman | f170ba0 | 2015-12-10 04:55:31 +0000 | [diff] [blame] | 305 | include "WebAssemblyInstrFloat.td" |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 306 | include "WebAssemblyInstrAtomics.td" |
| 307 | include "WebAssemblyInstrSIMD.td" |
Heejin Ahn | 0de5872 | 2018-03-08 04:05:37 +0000 | [diff] [blame] | 308 | include "WebAssemblyInstrExceptRef.td" |