mie: implement instruction selection graph generation for binary ops and load/store

This commit is contained in:
2025-08-29 15:46:52 +01:00
parent 7fdae9f1e0
commit 9c1e0958b0
19 changed files with 1343 additions and 13 deletions

33
mie/select/alloca.c Normal file
View File

@@ -0,0 +1,33 @@
#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,
};