10b57cec5SDimitry Andric// WebAssemblyInstrInfo.td-Describe the WebAssembly Instructions-*- tablegen -*- 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric/// 90b57cec5SDimitry Andric/// \file 100b57cec5SDimitry Andric/// WebAssembly Instruction definitions. 110b57cec5SDimitry Andric/// 120b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 150b57cec5SDimitry Andric// WebAssembly Instruction Predicate Definitions. 160b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 170b57cec5SDimitry Andric 180b57cec5SDimitry Andricdef IsPIC : Predicate<"TM.isPositionIndependent()">; 190b57cec5SDimitry Andricdef IsNotPIC : Predicate<"!TM.isPositionIndependent()">; 200b57cec5SDimitry Andric 210b57cec5SDimitry Andricdef HasAddr32 : Predicate<"!Subtarget->hasAddr64()">; 220b57cec5SDimitry Andric 230b57cec5SDimitry Andricdef HasAddr64 : Predicate<"Subtarget->hasAddr64()">; 240b57cec5SDimitry Andric 250b57cec5SDimitry Andricdef HasSIMD128 : 260b57cec5SDimitry Andric Predicate<"Subtarget->hasSIMD128()">, 27*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureSIMD128), "simd128">; 280b57cec5SDimitry Andric 290b57cec5SDimitry Andricdef HasUnimplementedSIMD128 : 300b57cec5SDimitry Andric Predicate<"Subtarget->hasUnimplementedSIMD128()">, 31*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureUnimplementedSIMD128), "unimplemented-simd128">; 320b57cec5SDimitry Andric 330b57cec5SDimitry Andricdef HasAtomics : 340b57cec5SDimitry Andric Predicate<"Subtarget->hasAtomics()">, 35*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureAtomics), "atomics">; 360b57cec5SDimitry Andric 370b57cec5SDimitry Andricdef HasMultivalue : 380b57cec5SDimitry Andric Predicate<"Subtarget->hasMultivalue()">, 39*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureMultivalue), "multivalue">; 400b57cec5SDimitry Andric 410b57cec5SDimitry Andricdef HasNontrappingFPToInt : 420b57cec5SDimitry Andric Predicate<"Subtarget->hasNontrappingFPToInt()">, 43*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureNontrappingFPToInt), "nontrapping-fptoint">; 440b57cec5SDimitry Andric 450b57cec5SDimitry Andricdef NotHasNontrappingFPToInt : 460b57cec5SDimitry Andric Predicate<"!Subtarget->hasNontrappingFPToInt()">, 47*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of (not FeatureNontrappingFPToInt)), "nontrapping-fptoint">; 480b57cec5SDimitry Andric 490b57cec5SDimitry Andricdef HasSignExt : 500b57cec5SDimitry Andric Predicate<"Subtarget->hasSignExt()">, 51*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureSignExt), "sign-ext">; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andricdef HasTailCall : 540b57cec5SDimitry Andric Predicate<"Subtarget->hasTailCall()">, 55*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureTailCall), "tail-call">; 560b57cec5SDimitry Andric 570b57cec5SDimitry Andricdef HasExceptionHandling : 580b57cec5SDimitry Andric Predicate<"Subtarget->hasExceptionHandling()">, 59*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureExceptionHandling), "exception-handling">; 600b57cec5SDimitry Andric 610b57cec5SDimitry Andricdef HasBulkMemory : 620b57cec5SDimitry Andric Predicate<"Subtarget->hasBulkMemory()">, 63*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureBulkMemory), "bulk-memory">; 64*5ffd83dbSDimitry Andric 65*5ffd83dbSDimitry Andricdef HasReferenceTypes : 66*5ffd83dbSDimitry Andric Predicate<"Subtarget->hasReferenceTypes()">, 67*5ffd83dbSDimitry Andric AssemblerPredicate<(all_of FeatureReferenceTypes), "reference-types">; 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 700b57cec5SDimitry Andric// WebAssembly-specific DAG Node Types. 710b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 720b57cec5SDimitry Andric 730b57cec5SDimitry Andricdef SDT_WebAssemblyCallSeqStart : SDCallSeqStart<[SDTCisVT<0, iPTR>, 740b57cec5SDimitry Andric SDTCisVT<1, iPTR>]>; 750b57cec5SDimitry Andricdef SDT_WebAssemblyCallSeqEnd : 760b57cec5SDimitry Andric SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>; 770b57cec5SDimitry Andricdef SDT_WebAssemblyCall0 : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>; 780b57cec5SDimitry Andricdef SDT_WebAssemblyCall1 : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>; 790b57cec5SDimitry Andricdef SDT_WebAssemblyBrTable : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>; 800b57cec5SDimitry Andricdef SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>; 810b57cec5SDimitry Andricdef SDT_WebAssemblyReturn : SDTypeProfile<0, -1, []>; 820b57cec5SDimitry Andricdef SDT_WebAssemblyWrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, 830b57cec5SDimitry Andric SDTCisPtrTy<0>]>; 840b57cec5SDimitry Andricdef SDT_WebAssemblyWrapperPIC : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, 850b57cec5SDimitry Andric SDTCisPtrTy<0>]>; 860b57cec5SDimitry Andricdef SDT_WebAssemblyThrow : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>; 870b57cec5SDimitry Andric 880b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 890b57cec5SDimitry Andric// WebAssembly-specific DAG Nodes. 900b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 910b57cec5SDimitry Andric 920b57cec5SDimitry Andricdef WebAssemblycallseq_start : 930b57cec5SDimitry Andric SDNode<"ISD::CALLSEQ_START", SDT_WebAssemblyCallSeqStart, 940b57cec5SDimitry Andric [SDNPHasChain, SDNPOutGlue]>; 950b57cec5SDimitry Andricdef WebAssemblycallseq_end : 960b57cec5SDimitry Andric SDNode<"ISD::CALLSEQ_END", SDT_WebAssemblyCallSeqEnd, 970b57cec5SDimitry Andric [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 980b57cec5SDimitry Andricdef WebAssemblybr_table : SDNode<"WebAssemblyISD::BR_TABLE", 990b57cec5SDimitry Andric SDT_WebAssemblyBrTable, 1000b57cec5SDimitry Andric [SDNPHasChain, SDNPVariadic]>; 1010b57cec5SDimitry Andricdef WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT", 1020b57cec5SDimitry Andric SDT_WebAssemblyArgument>; 1030b57cec5SDimitry Andricdef WebAssemblyreturn : SDNode<"WebAssemblyISD::RETURN", 1048bcb0991SDimitry Andric SDT_WebAssemblyReturn, 1058bcb0991SDimitry Andric [SDNPHasChain, SDNPVariadic]>; 1060b57cec5SDimitry Andricdef WebAssemblywrapper : SDNode<"WebAssemblyISD::Wrapper", 1070b57cec5SDimitry Andric SDT_WebAssemblyWrapper>; 1080b57cec5SDimitry Andricdef WebAssemblywrapperPIC : SDNode<"WebAssemblyISD::WrapperPIC", 1090b57cec5SDimitry Andric SDT_WebAssemblyWrapperPIC>; 1100b57cec5SDimitry Andricdef WebAssemblythrow : SDNode<"WebAssemblyISD::THROW", SDT_WebAssemblyThrow, 1110b57cec5SDimitry Andric [SDNPHasChain, SDNPVariadic]>; 1120b57cec5SDimitry Andric 1130b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 1140b57cec5SDimitry Andric// WebAssembly-specific Operands. 1150b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 1160b57cec5SDimitry Andric 1170b57cec5SDimitry Andric// Default Operand has AsmOperandClass "Imm" which is for integers (and 1180b57cec5SDimitry Andric// symbols), so specialize one for floats: 1190b57cec5SDimitry Andricdef FPImmAsmOperand : AsmOperandClass { 1200b57cec5SDimitry Andric let Name = "FPImm"; 1210b57cec5SDimitry Andric let PredicateMethod = "isFPImm"; 1220b57cec5SDimitry Andric} 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andricclass FPOperand<ValueType ty> : Operand<ty> { 1250b57cec5SDimitry Andric AsmOperandClass ParserMatchClass = FPImmAsmOperand; 1260b57cec5SDimitry Andric} 1270b57cec5SDimitry Andric 1280b57cec5SDimitry Andriclet OperandNamespace = "WebAssembly" in { 1290b57cec5SDimitry Andric 1300b57cec5SDimitry Andriclet OperandType = "OPERAND_BASIC_BLOCK" in 1310b57cec5SDimitry Andricdef bb_op : Operand<OtherVT>; 1320b57cec5SDimitry Andric 1330b57cec5SDimitry Andriclet OperandType = "OPERAND_LOCAL" in 1340b57cec5SDimitry Andricdef local_op : Operand<i32>; 1350b57cec5SDimitry Andric 1360b57cec5SDimitry Andriclet OperandType = "OPERAND_GLOBAL" in 1370b57cec5SDimitry Andricdef global_op : Operand<i32>; 1380b57cec5SDimitry Andric 1390b57cec5SDimitry Andriclet OperandType = "OPERAND_I32IMM" in 1400b57cec5SDimitry Andricdef i32imm_op : Operand<i32>; 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andriclet OperandType = "OPERAND_I64IMM" in 1430b57cec5SDimitry Andricdef i64imm_op : Operand<i64>; 1440b57cec5SDimitry Andric 1450b57cec5SDimitry Andriclet OperandType = "OPERAND_F32IMM" in 1460b57cec5SDimitry Andricdef f32imm_op : FPOperand<f32>; 1470b57cec5SDimitry Andric 1480b57cec5SDimitry Andriclet OperandType = "OPERAND_F64IMM" in 1490b57cec5SDimitry Andricdef f64imm_op : FPOperand<f64>; 1500b57cec5SDimitry Andric 1510b57cec5SDimitry Andriclet OperandType = "OPERAND_VEC_I8IMM" in 1520b57cec5SDimitry Andricdef vec_i8imm_op : Operand<i32>; 1530b57cec5SDimitry Andric 1540b57cec5SDimitry Andriclet OperandType = "OPERAND_VEC_I16IMM" in 1550b57cec5SDimitry Andricdef vec_i16imm_op : Operand<i32>; 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andriclet OperandType = "OPERAND_VEC_I32IMM" in 1580b57cec5SDimitry Andricdef vec_i32imm_op : Operand<i32>; 1590b57cec5SDimitry Andric 1600b57cec5SDimitry Andriclet OperandType = "OPERAND_VEC_I64IMM" in 1610b57cec5SDimitry Andricdef vec_i64imm_op : Operand<i64>; 1620b57cec5SDimitry Andric 1630b57cec5SDimitry Andriclet OperandType = "OPERAND_FUNCTION32" in 1640b57cec5SDimitry Andricdef function32_op : Operand<i32>; 1650b57cec5SDimitry Andric 1660b57cec5SDimitry Andriclet OperandType = "OPERAND_OFFSET32" in 1670b57cec5SDimitry Andricdef offset32_op : Operand<i32>; 1680b57cec5SDimitry Andric 169*5ffd83dbSDimitry Andriclet OperandType = "OPERAND_OFFSET64" in 170*5ffd83dbSDimitry Andricdef offset64_op : Operand<i64>; 171*5ffd83dbSDimitry Andric 1720b57cec5SDimitry Andriclet OperandType = "OPERAND_P2ALIGN" in { 1730b57cec5SDimitry Andricdef P2Align : Operand<i32> { 1740b57cec5SDimitry Andric let PrintMethod = "printWebAssemblyP2AlignOperand"; 1750b57cec5SDimitry Andric} 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andriclet OperandType = "OPERAND_EVENT" in 1780b57cec5SDimitry Andricdef event_op : Operand<i32>; 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andric} // OperandType = "OPERAND_P2ALIGN" 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andriclet OperandType = "OPERAND_SIGNATURE" in 1830b57cec5SDimitry Andricdef Signature : Operand<i32> { 1840b57cec5SDimitry Andric let PrintMethod = "printWebAssemblySignatureOperand"; 1850b57cec5SDimitry Andric} 1860b57cec5SDimitry Andric 1870b57cec5SDimitry Andriclet OperandType = "OPERAND_TYPEINDEX" in 1880b57cec5SDimitry Andricdef TypeIndex : Operand<i32>; 1890b57cec5SDimitry Andric 1900b57cec5SDimitry Andric} // OperandNamespace = "WebAssembly" 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 1930b57cec5SDimitry Andric// WebAssembly Register to Stack instruction mapping 1940b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 1950b57cec5SDimitry Andric 1960b57cec5SDimitry Andricclass StackRel; 1970b57cec5SDimitry Andricdef getStackOpcode : InstrMapping { 1980b57cec5SDimitry Andric let FilterClass = "StackRel"; 1990b57cec5SDimitry Andric let RowFields = ["BaseName"]; 2000b57cec5SDimitry Andric let ColFields = ["StackBased"]; 2010b57cec5SDimitry Andric let KeyCol = ["false"]; 2020b57cec5SDimitry Andric let ValueCols = [["true"]]; 2030b57cec5SDimitry Andric} 2040b57cec5SDimitry Andric 2050b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 206*5ffd83dbSDimitry Andric// WebAssembly 32 to 64-bit instruction mapping 207*5ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 208*5ffd83dbSDimitry Andric 209*5ffd83dbSDimitry Andricclass Wasm64Rel; 210*5ffd83dbSDimitry Andricdef getWasm64Opcode : InstrMapping { 211*5ffd83dbSDimitry Andric let FilterClass = "Wasm64Rel"; 212*5ffd83dbSDimitry Andric let RowFields = ["Wasm32Name"]; 213*5ffd83dbSDimitry Andric let ColFields = ["IsWasm64"]; 214*5ffd83dbSDimitry Andric let KeyCol = ["false"]; 215*5ffd83dbSDimitry Andric let ValueCols = [["true"]]; 216*5ffd83dbSDimitry Andric} 217*5ffd83dbSDimitry Andric 218*5ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 2190b57cec5SDimitry Andric// WebAssembly Instruction Format Definitions. 2200b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 2210b57cec5SDimitry Andric 2220b57cec5SDimitry Andricinclude "WebAssemblyInstrFormats.td" 2230b57cec5SDimitry Andric 2240b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 2250b57cec5SDimitry Andric// Additional instructions. 2260b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 2270b57cec5SDimitry Andric 2280b57cec5SDimitry Andricmulticlass ARGUMENT<WebAssemblyRegClass reg, ValueType vt> { 2290b57cec5SDimitry Andric let hasSideEffects = 1, isCodeGenOnly = 1, Defs = []<Register>, 2300b57cec5SDimitry Andric Uses = [ARGUMENTS] in 2310b57cec5SDimitry Andric defm ARGUMENT_#vt : 2320b57cec5SDimitry Andric I<(outs reg:$res), (ins i32imm:$argno), (outs), (ins i32imm:$argno), 2330b57cec5SDimitry Andric [(set (vt reg:$res), (WebAssemblyargument timm:$argno))]>; 2340b57cec5SDimitry Andric} 2350b57cec5SDimitry Andricdefm "": ARGUMENT<I32, i32>; 2360b57cec5SDimitry Andricdefm "": ARGUMENT<I64, i64>; 2370b57cec5SDimitry Andricdefm "": ARGUMENT<F32, f32>; 2380b57cec5SDimitry Andricdefm "": ARGUMENT<F64, f64>; 2390b57cec5SDimitry Andricdefm "": ARGUMENT<EXNREF, exnref>; 2400b57cec5SDimitry Andric 2410b57cec5SDimitry Andric// local.get and local.set are not generated by instruction selection; they 2420b57cec5SDimitry Andric// are implied by virtual register uses and defs. 2430b57cec5SDimitry Andricmulticlass LOCAL<WebAssemblyRegClass vt> { 2440b57cec5SDimitry Andric let hasSideEffects = 0 in { 2450b57cec5SDimitry Andric // COPY is not an actual instruction in wasm, but since we allow local.get and 2460b57cec5SDimitry Andric // local.set to be implicit during most of codegen, we can have a COPY which 2470b57cec5SDimitry Andric // is actually a no-op because all the work is done in the implied local.get 2480b57cec5SDimitry Andric // and local.set. COPYs are eliminated (and replaced with 2490b57cec5SDimitry Andric // local.get/local.set) in the ExplicitLocals pass. 2500b57cec5SDimitry Andric let isAsCheapAsAMove = 1, isCodeGenOnly = 1 in 2510b57cec5SDimitry Andric defm COPY_#vt : I<(outs vt:$res), (ins vt:$src), (outs), (ins), [], 2520b57cec5SDimitry Andric "local.copy\t$res, $src", "local.copy">; 2530b57cec5SDimitry Andric 2540b57cec5SDimitry Andric // TEE is similar to COPY, but writes two copies of its result. Typically 2550b57cec5SDimitry Andric // this would be used to stackify one result and write the other result to a 2560b57cec5SDimitry Andric // local. 2570b57cec5SDimitry Andric let isAsCheapAsAMove = 1, isCodeGenOnly = 1 in 2580b57cec5SDimitry Andric defm TEE_#vt : I<(outs vt:$res, vt:$also), (ins vt:$src), (outs), (ins), [], 2590b57cec5SDimitry Andric "local.tee\t$res, $also, $src", "local.tee">; 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andric // This is the actual local.get instruction in wasm. These are made explicit 2620b57cec5SDimitry Andric // by the ExplicitLocals pass. It has mayLoad because it reads from a wasm 2630b57cec5SDimitry Andric // local, which is a side effect not otherwise modeled in LLVM. 2640b57cec5SDimitry Andric let mayLoad = 1, isAsCheapAsAMove = 1 in 2650b57cec5SDimitry Andric defm LOCAL_GET_#vt : I<(outs vt:$res), (ins local_op:$local), 2660b57cec5SDimitry Andric (outs), (ins local_op:$local), [], 2670b57cec5SDimitry Andric "local.get\t$res, $local", "local.get\t$local", 0x20>; 2680b57cec5SDimitry Andric 2690b57cec5SDimitry Andric // This is the actual local.set instruction in wasm. These are made explicit 2700b57cec5SDimitry Andric // by the ExplicitLocals pass. It has mayStore because it writes to a wasm 2710b57cec5SDimitry Andric // local, which is a side effect not otherwise modeled in LLVM. 2720b57cec5SDimitry Andric let mayStore = 1, isAsCheapAsAMove = 1 in 2730b57cec5SDimitry Andric defm LOCAL_SET_#vt : I<(outs), (ins local_op:$local, vt:$src), 2740b57cec5SDimitry Andric (outs), (ins local_op:$local), [], 2750b57cec5SDimitry Andric "local.set\t$local, $src", "local.set\t$local", 0x21>; 2760b57cec5SDimitry Andric 2770b57cec5SDimitry Andric // This is the actual local.tee instruction in wasm. TEEs are turned into 2780b57cec5SDimitry Andric // LOCAL_TEEs by the ExplicitLocals pass. It has mayStore for the same reason 2790b57cec5SDimitry Andric // as LOCAL_SET. 2800b57cec5SDimitry Andric let mayStore = 1, isAsCheapAsAMove = 1 in 2810b57cec5SDimitry Andric defm LOCAL_TEE_#vt : I<(outs vt:$res), (ins local_op:$local, vt:$src), 2820b57cec5SDimitry Andric (outs), (ins local_op:$local), [], 2830b57cec5SDimitry Andric "local.tee\t$res, $local, $src", "local.tee\t$local", 2840b57cec5SDimitry Andric 0x22>; 2850b57cec5SDimitry Andric 2860b57cec5SDimitry Andric // Unused values must be dropped in some contexts. 2870b57cec5SDimitry Andric defm DROP_#vt : I<(outs), (ins vt:$src), (outs), (ins), [], 2880b57cec5SDimitry Andric "drop\t$src", "drop", 0x1a>; 2890b57cec5SDimitry Andric 2900b57cec5SDimitry Andric let mayLoad = 1 in 2910b57cec5SDimitry Andric defm GLOBAL_GET_#vt : I<(outs vt:$res), (ins global_op:$local), 2920b57cec5SDimitry Andric (outs), (ins global_op:$local), [], 2930b57cec5SDimitry Andric "global.get\t$res, $local", "global.get\t$local", 2940b57cec5SDimitry Andric 0x23>; 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andric let mayStore = 1 in 2970b57cec5SDimitry Andric defm GLOBAL_SET_#vt : I<(outs), (ins global_op:$local, vt:$src), 2980b57cec5SDimitry Andric (outs), (ins global_op:$local), [], 2990b57cec5SDimitry Andric "global.set\t$local, $src", "global.set\t$local", 3000b57cec5SDimitry Andric 0x24>; 3010b57cec5SDimitry Andric 3020b57cec5SDimitry Andric} // hasSideEffects = 0 3030b57cec5SDimitry Andric} 3040b57cec5SDimitry Andricdefm "" : LOCAL<I32>; 3050b57cec5SDimitry Andricdefm "" : LOCAL<I64>; 3060b57cec5SDimitry Andricdefm "" : LOCAL<F32>; 3070b57cec5SDimitry Andricdefm "" : LOCAL<F64>; 3080b57cec5SDimitry Andricdefm "" : LOCAL<V128>, Requires<[HasSIMD128]>; 3090b57cec5SDimitry Andricdefm "" : LOCAL<EXNREF>, Requires<[HasExceptionHandling]>; 3100b57cec5SDimitry Andric 3110b57cec5SDimitry Andriclet isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1 in { 3120b57cec5SDimitry Andricdefm CONST_I32 : I<(outs I32:$res), (ins i32imm_op:$imm), 3130b57cec5SDimitry Andric (outs), (ins i32imm_op:$imm), 3140b57cec5SDimitry Andric [(set I32:$res, imm:$imm)], 3150b57cec5SDimitry Andric "i32.const\t$res, $imm", "i32.const\t$imm", 0x41>; 3160b57cec5SDimitry Andricdefm CONST_I64 : I<(outs I64:$res), (ins i64imm_op:$imm), 3170b57cec5SDimitry Andric (outs), (ins i64imm_op:$imm), 3180b57cec5SDimitry Andric [(set I64:$res, imm:$imm)], 3190b57cec5SDimitry Andric "i64.const\t$res, $imm", "i64.const\t$imm", 0x42>; 3200b57cec5SDimitry Andricdefm CONST_F32 : I<(outs F32:$res), (ins f32imm_op:$imm), 3210b57cec5SDimitry Andric (outs), (ins f32imm_op:$imm), 3220b57cec5SDimitry Andric [(set F32:$res, fpimm:$imm)], 3230b57cec5SDimitry Andric "f32.const\t$res, $imm", "f32.const\t$imm", 0x43>; 3240b57cec5SDimitry Andricdefm CONST_F64 : I<(outs F64:$res), (ins f64imm_op:$imm), 3250b57cec5SDimitry Andric (outs), (ins f64imm_op:$imm), 3260b57cec5SDimitry Andric [(set F64:$res, fpimm:$imm)], 3270b57cec5SDimitry Andric "f64.const\t$res, $imm", "f64.const\t$imm", 0x44>; 3280b57cec5SDimitry Andric} // isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1 3290b57cec5SDimitry Andric 3300b57cec5SDimitry Andricdef : Pat<(i32 (WebAssemblywrapper tglobaladdr:$addr)), 3310b57cec5SDimitry Andric (CONST_I32 tglobaladdr:$addr)>, Requires<[IsNotPIC]>; 3320b57cec5SDimitry Andric 3330b57cec5SDimitry Andricdef : Pat<(i32 (WebAssemblywrapper tglobaladdr:$addr)), 3340b57cec5SDimitry Andric (GLOBAL_GET_I32 tglobaladdr:$addr)>, Requires<[IsPIC]>; 3350b57cec5SDimitry Andric 3360b57cec5SDimitry Andricdef : Pat<(i32 (WebAssemblywrapperPIC tglobaladdr:$addr)), 3370b57cec5SDimitry Andric (CONST_I32 tglobaladdr:$addr)>, Requires<[IsPIC]>; 3380b57cec5SDimitry Andric 3390b57cec5SDimitry Andricdef : Pat<(i32 (WebAssemblywrapper texternalsym:$addr)), 3400b57cec5SDimitry Andric (GLOBAL_GET_I32 texternalsym:$addr)>, Requires<[IsPIC]>; 3410b57cec5SDimitry Andric 3420b57cec5SDimitry Andricdef : Pat<(i32 (WebAssemblywrapper texternalsym:$addr)), 3430b57cec5SDimitry Andric (CONST_I32 texternalsym:$addr)>, Requires<[IsNotPIC]>; 3440b57cec5SDimitry Andric 3450b57cec5SDimitry Andricdef : Pat<(i32 (WebAssemblywrapper mcsym:$sym)), (CONST_I32 mcsym:$sym)>; 3460b57cec5SDimitry Andricdef : Pat<(i64 (WebAssemblywrapper mcsym:$sym)), (CONST_I64 mcsym:$sym)>; 3470b57cec5SDimitry Andric 3480b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 3490b57cec5SDimitry Andric// Additional sets of instructions. 3500b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 3510b57cec5SDimitry Andric 3520b57cec5SDimitry Andricinclude "WebAssemblyInstrMemory.td" 3530b57cec5SDimitry Andricinclude "WebAssemblyInstrCall.td" 3540b57cec5SDimitry Andricinclude "WebAssemblyInstrControl.td" 3550b57cec5SDimitry Andricinclude "WebAssemblyInstrInteger.td" 3560b57cec5SDimitry Andricinclude "WebAssemblyInstrConv.td" 3570b57cec5SDimitry Andricinclude "WebAssemblyInstrFloat.td" 3580b57cec5SDimitry Andricinclude "WebAssemblyInstrAtomics.td" 3590b57cec5SDimitry Andricinclude "WebAssemblyInstrSIMD.td" 3600b57cec5SDimitry Andricinclude "WebAssemblyInstrRef.td" 3610b57cec5SDimitry Andricinclude "WebAssemblyInstrBulkMemory.td" 362