Skip to content

Commit

Permalink
Refine comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vacantron committed Nov 20, 2023
1 parent 4c9c88e commit e771c22
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/arm-codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void code_generate()
emit(__mov_i(__EQ, rd, 1));
break;
case OP_log_and:
/* FIXME: bad-logical instruction */
/* FIXME: bad logical-and instruction */
emit(__and_r(__AL, rd, rn, rm));
break;
case OP_log_or:
Expand Down
5 changes: 4 additions & 1 deletion src/cfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,10 @@ void read_func_parameters(block_t *parent, basic_block_t **bb)
for (i = 0; i < param_num; i++) {
ph1_ir_t *ph1_ir = add_ph1_ir(OP_push);
ph1_ir->src0 = params[i];
/* Liveness extension in allocation uses `param_num - i` */
/**
* The operand should keep alive before calling function. Pass the
* number of remained parameters to allocator to extend their liveness.
*/
add_inst(parent, *bb, OP_push, NULL, ph1_ir->src0, NULL, param_num - i,
NULL);
}
Expand Down
12 changes: 7 additions & 5 deletions src/reg-alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ void spill_live_out(basic_block_t *bb)
}
}

/**
* The operand of `OP_push` should not been killed until function called.
*/
void extend_liveness(basic_block_t *bb, Inst_t *inst, var_t *var, int offset)
{
if (check_live_out(bb, var))
Expand Down Expand Up @@ -351,7 +354,7 @@ void reg_alloc()
ir->dest = dest;
break;
case OP_address_of:
/* FIXME: indirect assignment of pointer */
/* make sure variable is on stack */
if (!inst->rs1->offset) {
inst->rs1->offset = bb->belong_to->func->stack_size;
bb->belong_to->func->stack_size += 4;
Expand All @@ -377,7 +380,7 @@ void reg_alloc()
ir->src0 = src0;
ir->dest = dest;

/* store global variable after assignment immediately */
/* store global variable immediately after assignment */
if (inst->rd->is_global) {
ir = bb_add_ph2_ir(bb, OP_global_store);
ir->src0 = dest;
Expand All @@ -386,7 +389,6 @@ void reg_alloc()
}
break;
case OP_read:
/* FIXME: indirect assignment of pointer */
src0 = prepare_operand(bb, inst->rs1, -1);
dest = prepare_dest(bb, inst->rd, src0, -1);
ir = bb_add_ph2_ir(bb, OP_read);
Expand All @@ -401,7 +403,8 @@ void reg_alloc()
ir->src0 = src0;
strcpy(ir->func_name, inst->rs2->var_name);
} else {
/* FIXME: indirect assignment of pointer */
/* FIXME: Avoid outdated content in register after
* storing, but causing some redundant spilling. */
spill_alive(bb, inst);
src0 = prepare_operand(bb, inst->rs1, -1);
src1 = prepare_operand(bb, inst->rs2, src0);
Expand Down Expand Up @@ -561,7 +564,6 @@ void reg_alloc()
}
}

/* not support "%c" in printf() yet */
void dump_ph2_ir()
{
ph2_ir_t *ph2_ir;
Expand Down
4 changes: 2 additions & 2 deletions src/ssa.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ void solve_phi_params()
for (fn = FUNC_LIST.head; fn; fn = fn->next) {
int i;
for (i = 0; i < fn->func->num_params; i++) {
/* FIXME: Directly rename parameters, might be not good here. */
/* FIXME: Rename arguments directly, might be not good here. */
var_t *var = require_var(fn->bbs->scope);
var_t *base = &fn->func->param_defs[i];
memcpy(var, base, sizeof(var_t));
Expand Down Expand Up @@ -583,7 +583,7 @@ void bb_unwind_phi(fn_t *fn, basic_block_t *bb)
for (operand = inst->phi_ops; operand; operand = operand->next) {
append_unwound_phi_inst(operand->from, inst->rd, operand->var);
}
/* TODO: Should release phi instructions */
/* TODO: Release dangling phi instruction */
}

bb->inst_list.head = inst;
Expand Down

0 comments on commit e771c22

Please sign in to comment.