backend: Add interface to generate ret instruction
Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user