Files
ivy/mie/select/alloca.c

38 lines
1.0 KiB
C

#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);
struct mie_select_node *frame_index;
enum mie_status status = mie_select_graph_get_node(
graph, mie_target_builtin(), MIE_SELECT_OP_FRAME_INDEX, NULL, 0,
&ptr_type, 1, &frame_index);
if (status != MIE_SUCCESS) {
return status;
}
frame_index->n_flags = MIE_SELECT_NODE_F_IVALUE;
frame_index->n_value.i = graph->g_frame_index++;
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);
}
struct select_instr_type select_alloca = {
.i_push = push,
};