OSDN Git Service

[WebAssembly] Make rethrow instruction take a target BB argument
authorHeejin Ahn <aheejin@gmail.com>
Mon, 18 Jun 2018 23:54:29 +0000 (23:54 +0000)
committerHeejin Ahn <aheejin@gmail.com>
Mon, 18 Jun 2018 23:54:29 +0000 (23:54 +0000)
Summary:
This patch changes the rethrow instruction to take a BB argument in LLVM
backend, like `br` and `br_if`s. This BB is a target catch BB the
rethrow instruction unwinds to. This BB argument will be converted to an
relative depth immediate at the end of CFGStackify pass, as in the same
way of branches.

RETHROW_TO_CALLER is a codegen-only instruction that should be used when
a rethrow instruction does not have an unwind destination BB, i.e., it
should rethrow to its caller function.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D48260

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334998 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/WebAssembly/WebAssemblyInstrControl.td

index 93cc319..09e148f 100644 (file)
@@ -152,8 +152,11 @@ defm THROW_I64 : I<(outs), (ins i32imm:$tag, I64:$val),
                    [(int_wasm_throw imm:$tag, I64:$val)],
                    "throw   \t$tag, $val", "throw   \t$tag",
                    0x08>;
-defm RETHROW : NRI<(outs), (ins i32imm:$rel_depth), [], "rethrow \t$rel_depth",
-                   0x09>;
+defm RETHROW : NRI<(outs), (ins bb_op:$dst), [], "rethrow \t$dst", 0x09>;
+let isCodeGenOnly = 1 in
+// This is used when the destination for rethrow is the caller function. This
+// will be converted to a rethrow in CFGStackify.
+defm RETHROW_TO_CALLER : NRI<(outs), (ins), [], "rethrow">;
 } // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
 
 // Region within which an exception is caught: try / end_try