1 //===- WebAssemblyInstrControl.td-WebAssembly control-flow ------*- tablegen -*-
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief WebAssembly control-flow code-gen constructs.
13 //===----------------------------------------------------------------------===//
15 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in {
16 def BR_IF : I<(outs), (ins I32:$a, bb_op:$dst),
17 [(brcond I32:$a, bb:$dst)],
19 let isBarrier = 1 in {
20 def BR : I<(outs), (ins bb_op:$dst),
24 } // isBranch = 1, isTerminator = 1, hasCtrlDep = 1
26 // TODO: SelectionDAG's lowering insists on using a pointer as the index for
27 // jump tables, so in practice we don't ever use TABLESWITCH_I64 in wasm32 mode
29 let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
30 def TABLESWITCH_I32 : I<(outs), (ins I32:$index, variable_ops),
31 [(WebAssemblytableswitch I32:$index)],
32 "tableswitch\t$index">;
33 def TABLESWITCH_I64 : I<(outs), (ins I64:$index, variable_ops),
34 [(WebAssemblytableswitch I64:$index)],
35 "tableswitch\t$index">;
36 } // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
38 // Placemarkers to indicate the start of a block or loop scope.
39 def BLOCK : I<(outs), (ins bb_op:$dst), [], "block \t$dst">;
40 def LOOP : I<(outs), (ins bb_op:$dst), [], "loop \t$dst">;
42 // No-op to indicate to the AsmPrinter that a loop ends here, so a
43 // basic block label is needed even if it wouldn't otherwise appear so.
44 let isTerminator = 1, hasCtrlDep = 1 in
45 def LOOP_END : I<(outs), (ins), []>;
47 multiclass RETURN<WebAssemblyRegClass vt> {
48 def RETURN_#vt : I<(outs), (ins vt:$val), [(WebAssemblyreturn vt:$val)],
52 let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
58 def RETURN_VOID : I<(outs), (ins), [(WebAssemblyreturn)], "return">;
60 def UNREACHABLE : I<(outs), (ins), [(trap)], "unreachable">;
61 } // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1