Support constant CALL_INDIRECT.
This commit is contained in:
@@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
#include <alloy/compiler/passes/constant_propagation_pass.h>
|
#include <alloy/compiler/passes/constant_propagation_pass.h>
|
||||||
|
|
||||||
|
#include <alloy/runtime/function.h>
|
||||||
|
#include <alloy/runtime/runtime.h>
|
||||||
|
|
||||||
using namespace alloy;
|
using namespace alloy;
|
||||||
using namespace alloy::compiler;
|
using namespace alloy::compiler;
|
||||||
using namespace alloy::compiler::passes;
|
using namespace alloy::compiler::passes;
|
||||||
@@ -89,6 +92,17 @@ int ConstantPropagationPass::Run(HIRBuilder* builder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case OPCODE_CALL_INDIRECT:
|
||||||
|
if (i->src1.value->IsConstant()) {
|
||||||
|
runtime::FunctionInfo* symbol_info;
|
||||||
|
if (runtime_->LookupFunctionInfo(
|
||||||
|
(uint32_t)i->src1.value->constant.i32, &symbol_info)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i->Replace(&OPCODE_CALL_info, i->flags);
|
||||||
|
i->src1.symbol_info = symbol_info;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case OPCODE_CALL_INDIRECT_TRUE:
|
case OPCODE_CALL_INDIRECT_TRUE:
|
||||||
if (i->src1.value->IsConstant()) {
|
if (i->src1.value->IsConstant()) {
|
||||||
if (i->src1.value->IsConstantTrue()) {
|
if (i->src1.value->IsConstantTrue()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user