From f1cccfd0f3dc9737da7db0e716a7d2da2400651b Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 29 Mar 2021 16:10:15 -0300 Subject: [PATCH] Add OpUnreachable --- include/sirit/sirit.h | 3 +++ src/instructions/flow.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index c26304b..f3925bb 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -292,6 +292,9 @@ public: /// Returns with no value from a function with void return type. void OpReturn(); + /// Behavior is undefined if this instruction is executed. + void OpUnreachable(); + /// Return a value from a function. Id OpReturnValue(Id value); diff --git a/src/instructions/flow.cpp b/src/instructions/flow.cpp index 31c2ed1..e13caa9 100644 --- a/src/instructions/flow.cpp +++ b/src/instructions/flow.cpp @@ -67,6 +67,11 @@ void Module::OpReturn() { *code << spv::Op::OpReturn << EndOp{}; } +void Module::OpUnreachable() { + code->Reserve(1); + *code << spv::Op::OpUnreachable << EndOp{}; +} + Id Module::OpReturnValue(Id value) { code->Reserve(2); return *code << spv::Op::OpReturnValue << value << EndOp{};