2025-08-29 15:46:52 +01:00
|
|
|
#include "builder.h"
|
|
|
|
|
|
|
|
|
|
#include <mie/ctx.h>
|
|
|
|
|
#include <mie/ir/alloca.h>
|
|
|
|
|
#include <mie/select/graph.h>
|
|
|
|
|
#include <mie/select/node.h>
|
|
|
|
|
|
|
|
|
|
static enum mie_status push(
|
|
|
|
|
struct mie_select_builder *builder, struct mie_instr *instr)
|
|
|
|
|
{
|
|
|
|
|
struct mie_alloca *alloca = (struct mie_alloca *)instr;
|
|
|
|
|
struct mie_select_graph *graph = mie_select_builder_get_graph(builder);
|
|
|
|
|
|
|
|
|
|
struct mie_type *ptr_type = mie_ctx_get_type(
|
|
|
|
|
mie_select_builder_get_ctx(builder), MIE_TYPE_PTR);
|
2025-09-08 15:42:22 +01:00
|
|
|
struct mie_select_node *frame_index;
|
2025-08-29 15:46:52 +01:00
|
|
|
enum mie_status status = mie_select_graph_get_node(
|
2025-09-08 15:42:22 +01:00
|
|
|
graph, mie_target_builtin(), MIE_SELECT_OP_FRAME_INDEX, NULL, 0,
|
|
|
|
|
&ptr_type, 1, &frame_index);
|
2025-08-29 15:46:52 +01:00
|
|
|
|
|
|
|
|
if (status != MIE_SUCCESS) {
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-08 15:42:22 +01:00
|
|
|
frame_index->n_flags = MIE_SELECT_NODE_F_IVALUE;
|
|
|
|
|
frame_index->n_value.i = graph->g_frame_index++;
|
2025-08-29 15:46:52 +01:00
|
|
|
|
2025-09-08 15:42:22 +01:00
|
|
|
struct mie_select_value frame_index_value;
|
|
|
|
|
mie_select_node_get_value(frame_index, ptr_type, 0, &frame_index_value);
|
|
|
|
|
|
|
|
|
|
return mie_select_builder_set_value(
|
|
|
|
|
builder, MIE_VALUE(instr), &frame_index_value);
|
2025-08-29 15:46:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct select_instr_type select_alloca = {
|
|
|
|
|
.i_push = push,
|
|
|
|
|
};
|