diff --git a/src/arm-codegen.c b/src/arm-codegen.c index 1290c091..fd1303b9 100644 --- a/src/arm-codegen.c +++ b/src/arm-codegen.c @@ -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: diff --git a/src/cfront.c b/src/cfront.c index b7523d6c..8ce74aae 100644 --- a/src/cfront.c +++ b/src/cfront.c @@ -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); } diff --git a/src/reg-alloc.c b/src/reg-alloc.c index 489172a3..720ad0f8 100644 --- a/src/reg-alloc.c +++ b/src/reg-alloc.c @@ -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)) @@ -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; @@ -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; @@ -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); @@ -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); @@ -561,7 +564,6 @@ void reg_alloc() } } -/* not support "%c" in printf() yet */ void dump_ph2_ir() { ph2_ir_t *ph2_ir; diff --git a/src/ssa.c b/src/ssa.c index 5f82375c..57698700 100644 --- a/src/ssa.c +++ b/src/ssa.c @@ -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)); @@ -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;