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 |
| 11 | /// \brief WebAssembly Instruction definitions. |
| 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">; |
| 23 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 24 | //===----------------------------------------------------------------------===// |
| 25 | // WebAssembly-specific DAG Node Types. |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 28 | def SDT_WebAssemblyCallSeqStart : SDCallSeqStart<[SDTCisVT<0, iPTR>]>; |
| 29 | def SDT_WebAssemblyCallSeqEnd : |
| 30 | SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>; |
| 31 | def SDT_WebAssemblyCall : SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 32 | def SDT_WebAssemblyArgument : SDTypeProfile<1, 1, [SDTCisVT<1, i32>]>; |
JF Bastien | 4a2d560 | 2015-07-31 21:04:18 +0000 | [diff] [blame] | 33 | def SDT_WebAssemblyReturn : SDTypeProfile<0, -1, []>; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 34 | def SDT_WebAssemblyWrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, |
| 35 | SDTCisPtrTy<0>]>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 36 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 37 | //===----------------------------------------------------------------------===// |
| 38 | // WebAssembly-specific DAG Nodes. |
| 39 | //===----------------------------------------------------------------------===// |
| 40 | |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 41 | def WebAssemblycallseq_start : |
| 42 | SDNode<"ISD::CALLSEQ_START", SDT_WebAssemblyCallSeqStart, |
| 43 | [SDNPHasChain, SDNPOutGlue]>; |
| 44 | def WebAssemblycallseq_end : |
| 45 | SDNode<"ISD::CALLSEQ_END", SDT_WebAssemblyCallSeqEnd, |
| 46 | [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; |
| 47 | def WebAssemblycall : SDNode<"WebAssemblyISD::CALL", |
| 48 | SDT_WebAssemblyCall, |
| 49 | [SDNPHasChain, SDNPVariadic]>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 50 | def WebAssemblyargument : SDNode<"WebAssemblyISD::ARGUMENT", |
| 51 | SDT_WebAssemblyArgument>; |
| 52 | def WebAssemblyreturn : SDNode<"WebAssemblyISD::RETURN", |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 53 | SDT_WebAssemblyReturn, [SDNPHasChain]>; |
| 54 | def WebAssemblywrapper : SDNode<"WebAssemblyISD::Wrapper", |
| 55 | SDT_WebAssemblyWrapper>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 56 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 57 | //===----------------------------------------------------------------------===// |
| 58 | // WebAssembly-specific Operands. |
| 59 | //===----------------------------------------------------------------------===// |
| 60 | |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 61 | /* |
| 62 | * TODO(jfb): Add the following. |
| 63 | * |
| 64 | * get_local: read the current value of a local variable |
| 65 | * set_local: set the current value of a local variable |
| 66 | */ |
| 67 | |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 68 | def global : Operand<iPTR>; |
| 69 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 70 | //===----------------------------------------------------------------------===// |
| 71 | // WebAssembly Instruction Format Definitions. |
| 72 | //===----------------------------------------------------------------------===// |
| 73 | |
| 74 | include "WebAssemblyInstrFormats.td" |
| 75 | |
JF Bastien | 8f9aea0 | 2015-08-01 04:48:44 +0000 | [diff] [blame] | 76 | multiclass ARGUMENT<WebAssemblyRegClass vt> { |
| 77 | def ARGUMENT_#vt : I<(outs vt:$res), (ins i32imm:$argno), |
| 78 | [(set vt:$res, (WebAssemblyargument timm:$argno))]>; |
| 79 | } |
| 80 | defm : ARGUMENT<Int32>; |
| 81 | defm : ARGUMENT<Int64>; |
| 82 | defm : ARGUMENT<Float32>; |
| 83 | defm : ARGUMENT<Float64>; |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 84 | |
JF Bastien | 4a64225 | 2015-08-10 22:36:48 +0000 | [diff] [blame] | 85 | |
| 86 | def Immediate_I32 : I<(outs Int32:$res), (ins i32imm:$imm), |
| 87 | [(set Int32:$res, imm:$imm)]>; |
| 88 | def Immediate_I64 : I<(outs Int64:$res), (ins i64imm:$imm), |
| 89 | [(set Int64:$res, imm:$imm)]>; |
| 90 | def Immediate_F32 : I<(outs Float32:$res), (ins f32imm:$imm), |
| 91 | [(set Float32:$res, fpimm:$imm)]>; |
| 92 | def Immediate_F64 : I<(outs Float64:$res), (ins f64imm:$imm), |
| 93 | [(set Float64:$res, fpimm:$imm)]>; |
| 94 | |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 95 | // Special types of immediates. |
| 96 | def GLOBAL : I<(outs Int32:$dst), (ins global:$addr), |
| 97 | [(set Int32:$dst, (WebAssemblywrapper tglobaladdr:$addr))]>; |
| 98 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 99 | //===----------------------------------------------------------------------===// |
| 100 | // Additional sets of instructions. |
| 101 | //===----------------------------------------------------------------------===// |
| 102 | |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 103 | include "WebAssemblyInstrMemory.td" |
| 104 | include "WebAssemblyInstrCall.td" |
JF Bastien | 600aee9 | 2015-07-31 17:53:38 +0000 | [diff] [blame] | 105 | include "WebAssemblyInstrControl.td" |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 106 | include "WebAssemblyInstrInteger.td" |
| 107 | include "WebAssemblyInstrFloat.td" |
| 108 | include "WebAssemblyInstrConv.td" |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 109 | include "WebAssemblyInstrAtomics.td" |
| 110 | include "WebAssemblyInstrSIMD.td" |