backend: Add interface to generate ret instruction

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-02-15 23:11:37 -05:00
parent ae1a50e78b
commit 87f0cfcdb0
2 changed files with 26 additions and 0 deletions

View File

@@ -25,3 +25,17 @@ mu_gen_label(struct rifle_state *state, const char *name, bool global)
return 0;
}
int
mu_gen_ret(struct rifle_state *state)
{
if (state == NULL) {
return -1;
}
fprintf(
state->out_fp,
INST("ret")
);
return 0;
}

View File

@@ -6,6 +6,9 @@
#include <stdbool.h>
#include "rifle/state.h"
#define INST(inst) \
" " inst "\n"
/*
* Generate a named label
*
@@ -17,4 +20,13 @@
*/
int mu_gen_label(struct rifle_state *state, const char *name, bool global);
/*
* Generate a return instruction
*
* @state: Compiler state
*
* Returns zero on success
*/
int mu_gen_ret(struct rifle_state *state);
#endif /* !RIFLE_MU_H */