Skip to content

Commit

Permalink
Remove precall
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfkda committed Dec 9, 2024
1 parent 088add6 commit 75028c7
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 35 deletions.
3 changes: 1 addition & 2 deletions src/_debug/dump_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void dump_ir(FILE *fp, IR *ir) {
"BOFS", "IOFS", "SOFS", "LOAD", "LOAD_S", "STORE", "STORE_S",
"ADD", "SUB", "MUL", "DIV", "MOD", "BITAND", "BITOR", "BITXOR", "LSHIFT", "RSHIFT", "COND",
"NEG", "BITNOT", "CAST", "MOV", "RESULT",
"JMP", "TJMP", "PRECALL", "PUSHARG", "CALL", "SUBSP", "KEEP", "ASM",
"JMP", "TJMP", "PUSHARG", "CALL", "SUBSP", "KEEP", "ASM",
};
static char *kCond[] = {NULL, "MP", "EQ", "NE", "LT", "LE", "GE", "GT", NULL, "MP", "EQ", "NE", "ULT", "ULE", "UGE", "UGT"};
static char *kCond2[] = {NULL, "MP", "==", "!=", "<", "<=", ">=", ">", NULL, "MP", "==", "!=", "<", "<=", ">=", ">"};
Expand Down Expand Up @@ -131,7 +131,6 @@ static void dump_ir(FILE *fp, IR *ir) {
if (ir->opr2 != NULL) {fprintf(fp, " (tmp="); dump_vreg(fp, ir->opr2); fprintf(fp, ")");}
fprintf(fp, "\n");
break;
case IR_PRECALL: fprintf(fp, "\n"); break;
case IR_PUSHARG: fprintf(fp, "%d, ", ir->pusharg.index); dump_vreg(fp, ir->opr1); fprintf(fp, "\n"); break;
case IR_CALL:
if (ir->dst != NULL) { dump_vreg(fp, ir->dst); fprintf(fp, " = "); }
Expand Down
6 changes: 1 addition & 5 deletions src/cc/arch/aarch64/ir_aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,10 +863,6 @@ static void ei_tjmp(IR *ir) {
_TEXT();
}

static void ei_precall(IR *ir) {
UNUSED(ir);
}

static void ei_pusharg(IR *ir) {
int pow = ir->opr1->vsize;
if (ir->opr1->flag & VRF_FLONUM) {
Expand Down Expand Up @@ -971,7 +967,7 @@ void emit_bb_irs(BBContainer *bbcon) {
[IR_MOV] = ei_mov, [IR_RESULT] = ei_result,

[IR_JMP] = ei_jmp, [IR_TJMP] = ei_tjmp,
[IR_PRECALL] = ei_precall, [IR_PUSHARG] = ei_pusharg, [IR_CALL] = ei_call,
[IR_PUSHARG] = ei_pusharg, [IR_CALL] = ei_call,
[IR_SUBSP] = ei_subsp, [IR_KEEP] = ei_keep, [IR_ASM] = ei_asm,
};

Expand Down
6 changes: 1 addition & 5 deletions src/cc/arch/riscv64/ir_riscv64.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,6 @@ static void ei_tjmp(IR *ir) {
_TEXT();
}

static void ei_precall(IR *ir) {
UNUSED(ir);
}

static void ei_pusharg(IR *ir) {
if (ir->opr1->flag & VRF_FLONUM) {
#if VAARG_FP_AS_GP
Expand Down Expand Up @@ -949,7 +945,7 @@ void emit_bb_irs(BBContainer *bbcon) {
[IR_MOV] = ei_mov, [IR_RESULT] = ei_result,

[IR_JMP] = ei_jmp, [IR_TJMP] = ei_tjmp,
[IR_PRECALL] = ei_precall, [IR_PUSHARG] = ei_pusharg, [IR_CALL] = ei_call,
[IR_PUSHARG] = ei_pusharg, [IR_CALL] = ei_call,
[IR_SUBSP] = ei_subsp, [IR_KEEP] = ei_keep, [IR_ASM] = ei_asm,
};

Expand Down
6 changes: 1 addition & 5 deletions src/cc/arch/x64/ir_x64.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,10 +956,6 @@ static void ei_tjmp(IR *ir) {
_TEXT();
}

static void ei_precall(IR *ir) {
UNUSED(ir);
}

static void ei_pusharg(IR *ir) {
if (ir->opr1->flag & VRF_FLONUM) {
// Assume parameter registers are arranged from index 0.
Expand Down Expand Up @@ -1080,7 +1076,7 @@ void emit_bb_irs(BBContainer *bbcon) {
[IR_MOV] = ei_mov, [IR_RESULT] = ei_result,

[IR_JMP] = ei_jmp, [IR_TJMP] = ei_tjmp,
[IR_PRECALL] = ei_precall, [IR_PUSHARG] = ei_pusharg, [IR_CALL] = ei_call,
[IR_PUSHARG] = ei_pusharg, [IR_CALL] = ei_call,
[IR_SUBSP] = ei_subsp, [IR_KEEP] = ei_keep, [IR_ASM] = ei_asm,
};

Expand Down
15 changes: 7 additions & 8 deletions src/cc/backend/codegen_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,6 @@ static VReg *gen_funcall(Expr *expr) {
}
}

IrCallInfo *callinfo = calloc_or_die(sizeof(*callinfo));
callinfo->arg_count = arg_count - stack_arg_count;
callinfo->stack_args_size = offset;
callinfo->stack_aligned = 0;
callinfo->living_pregs = 0;
callinfo->caller_saves = NULL;
/*IR *precall =*/ new_ir_precall(callinfo);

int total_arg_count = arg_count + (ret_varinfo != NULL ? 1 : 0);
VReg **arg_vregs = total_arg_count == 0 ? NULL : calloc_or_die(total_arg_count * sizeof(*arg_vregs));

Expand Down Expand Up @@ -468,6 +460,13 @@ static VReg *gen_funcall(Expr *expr) {
global = !(varinfo->storage & VS_STATIC);
}

IrCallInfo *callinfo = calloc_or_die(sizeof(*callinfo));
callinfo->arg_count = arg_count - stack_arg_count;
callinfo->stack_args_size = offset;
callinfo->stack_aligned = 0;
callinfo->living_pregs = 0;
callinfo->caller_saves = NULL;

VReg *dst = NULL;
IR *call;
{
Expand Down
6 changes: 0 additions & 6 deletions src/cc/backend/ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,6 @@ IR *new_ir_pusharg(VReg *vreg, int index) {
return ir;
}

IR *new_ir_precall(IrCallInfo *call) {
IR *ir = new_ir(IR_PRECALL);
ir->call = call;
return ir;
}

IR *new_ir_call(IrCallInfo *info, VReg *dst, VReg *freg) {
IR *ir = new_ir(IR_CALL);
ir->call = info;
Expand Down
2 changes: 0 additions & 2 deletions src/cc/backend/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ enum IrKind {

IR_JMP, // Non conditional jump, or conditional jmp (opr1 @@ opr2)
IR_TJMP, // Table jump (opr1). opr2 is NULL, but it might be used to keep temporary vreg.
IR_PRECALL, // Prepare for call
IR_PUSHARG,
IR_CALL, // Call label or opr1
IR_SUBSP, // RSP -= value
Expand Down Expand Up @@ -199,7 +198,6 @@ IR *new_ir_cond(VReg *opr1, VReg *opr2, enum ConditionKind cond);
IR *new_ir_jmp(BB *bb); // Non-conditional jump
void new_ir_cjmp(VReg *opr1, VReg *opr2, enum ConditionKind cond, BB *bb); // Conditional jump
void new_ir_tjmp(VReg *val, BB **bbs, size_t len);
IR *new_ir_precall(IrCallInfo *call);
IR *new_ir_pusharg(VReg *vreg, int index);
IR *new_ir_call(IrCallInfo *info, VReg *dst, VReg *freg);
void new_ir_result(VReg *dst, VReg *vreg, int flag);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/backend/regalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ static int insert_load_store_spilled_irs(RegAlloc *ra, BBContainer *bbcon) {
[IR_NEG] = D12, [IR_BITNOT] = D12, [IR_CAST] = D12, [IR_MOV] = D12,
[IR_RESULT] = D12,

[IR_JMP] = D12, [IR_TJMP] = D12, [IR_PRECALL] = D12, [IR_PUSHARG] = D12,
[IR_CALL] = D12, [IR_SUBSP] = D12, [IR_KEEP] = D12, [IR_ASM] = D12,
[IR_JMP] = D12, [IR_TJMP] = D12, [IR_PUSHARG] = D12, [IR_CALL] = D12,
[IR_SUBSP] = D12, [IR_KEEP] = D12, [IR_ASM] = D12,

[IR_BOFS] = D__, [IR_IOFS] = D__, [IR_SOFS] = D__,

Expand Down

0 comments on commit 75028c7

Please sign in to comment.