static arch_env_t *TEMPLATE_init(FILE *outfile)
{
TEMPLATE_isa_t *isa = XMALLOC(TEMPLATE_isa_t);
- memcpy(isa, &TEMPLATE_isa_template, sizeof(*isa));
+ *isa = TEMPLATE_isa_template;
be_emit_init(outfile);
(void) self;
/* set abi flags for calls */
- call_flags.bits.left_to_right = 0;
call_flags.bits.store_args_sequential = 1;
call_flags.bits.try_omit_fp = 1;
call_flags.bits.fp_free = 0;
0, /* 0: little-endian, 1: big-endian */
NULL, /* architecture dependent settings, will be set later */
TEMPLATE_is_mux_allowed, /* parameter for if conversion */
+ 32, /* machine size - a 32bit CPU */
NULL, /* float arithmetic mode */
+ 0, /* size of long double */
0, /* no trampoline support: size 0 */
0, /* no trampoline support: align 0 */
NULL, /* no trampoline support: no trampoline builder */
return 0;
}
+/**
+ * Check if the given register is callee or caller save.
+ */
+static int TEMPLATE_register_saved_by(const arch_register_t *reg, int callee)
+{
+ if (callee) {
+ /* check for callee saved */
+ if (reg->reg_class == &TEMPLATE_reg_classes[CLASS_TEMPLATE_gp]) {
+ switch (reg->index) {
+ case REG_GP_R7:
+ case REG_GP_R8:
+ case REG_GP_R9:
+ case REG_GP_R10:
+ case REG_GP_R11:
+ case REG_GP_R12:
+ case REG_GP_R13:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+ } else {
+ /* check for caller saved */
+ if (reg->reg_class == &TEMPLATE_reg_classes[CLASS_TEMPLATE_gp]) {
+ switch (reg->index) {
+ case REG_GP_R0:
+ case REG_GP_R1:
+ case REG_GP_R2:
+ case REG_GP_R3:
+ case REG_GP_R4:
+ case REG_GP_R5:
+ case REG_GP_R6:
+ return 1;
+ default:
+ return 0;
+ }
+ } else if (reg->reg_class == &TEMPLATE_reg_classes[CLASS_TEMPLATE_fp]) {
+ /* all FP registers are caller save */
+ return 1;
+ }
+ }
+ return 0;
+}
+
const arch_isa_if_t TEMPLATE_isa_if = {
TEMPLATE_init,
TEMPLATE_lower_for_target,
TEMPLATE_after_ra,
TEMPLATE_finish_irg,
TEMPLATE_emit_routine,
+ TEMPLATE_register_saved_by,
};
-BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_TEMPLATE);
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_TEMPLATE)
void be_init_arch_TEMPLATE(void)
{
be_register_isa_if("TEMPLATE", &TEMPLATE_isa_if);