34 lines
930 B
C
34 lines
930 B
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_value frame_index;
|
||
|
|
enum mie_status status = mie_select_graph_get_node(
|
||
|
|
graph, MIE_SELECT_OP_FRAME_INDEX, NULL, 0, &ptr_type, 1,
|
||
|
|
&frame_index);
|
||
|
|
|
||
|
|
if (status != MIE_SUCCESS) {
|
||
|
|
return status;
|
||
|
|
}
|
||
|
|
|
||
|
|
frame_index.v_node->n_flags = MIE_SELECT_NODE_F_IVALUE;
|
||
|
|
frame_index.v_node->n_value_i = graph->g_frame_index++;
|
||
|
|
|
||
|
|
return select_builder_set_value(builder, MIE_VALUE(instr), &frame_index);
|
||
|
|
}
|
||
|
|
|
||
|
|
struct select_instr_type select_alloca = {
|
||
|
|
.i_push = push,
|
||
|
|
};
|