diff --git a/backend/x86_64.c b/backend/x86_64.c index 9b597e3..83ed5da 100644 --- a/backend/x86_64.c +++ b/backend/x86_64.c @@ -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; +} diff --git a/inc/rifle/mu.h b/inc/rifle/mu.h index 831ee13..aaca0e7 100644 --- a/inc/rifle/mu.h +++ b/inc/rifle/mu.h @@ -6,6 +6,9 @@ #include #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 */