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