Skip to content

Commit d7dd5d2

Browse files
committed
Refine comments
1 parent 3bd86da commit d7dd5d2

File tree

10 files changed

+37
-28
lines changed

10 files changed

+37
-28
lines changed

src/arm-codegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
440440
emit(__and_i(__AL, rd, rn, rm));
441441
return;
442442
case OP_sign_ext:
443-
/* TODO: Allow to sign extends to other types */
443+
/* TODO: Support sign extension to types other than int */
444444
emit(__sxtb(__AL, rd, rn, 0));
445445
return;
446446
case OP_cast:

src/defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ typedef struct {
111111

112112
/* lexer tokens */
113113
typedef enum {
114-
T_start, /* FIXME: it was intended to start the state machine. */
114+
T_start, /* FIXME: Unused, intended for lexer state machine init */
115115
T_numeric,
116116
T_identifier,
117117
T_comma, /* , */

src/elf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ int elf_symbol_index;
1515

1616
void elf_write_str(strbuf_t *elf_array, const char *vals)
1717
{
18-
/*
19-
* Note that strbuf_puts() does not push the null character.
18+
/* Note that strbuf_puts() does not push the null character.
2019
*
2120
* If necessary, use elf_write_byte() to append the null character
2221
* after calling elf_write_str().

src/globals.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,16 @@ strbuf_t *SOURCE;
9191
hashmap_t *INCLUSION_MAP;
9292

9393
/* ELF sections */
94-
strbuf_t *elf_code;
95-
strbuf_t *elf_data;
94+
strbuf_t *elf_code, *elf_data;
9695
strbuf_t *elf_rodata;
9796
strbuf_t *elf_header;
9897
strbuf_t *elf_symtab;
9998
strbuf_t *elf_strtab;
10099
strbuf_t *elf_section;
101100
int elf_header_len = 0x54; /* ELF fixed: 0x34 + 1 * 0x20 */
102-
int elf_code_start;
103-
int elf_data_start;
101+
int elf_code_start, elf_data_start;
104102
int elf_rodata_start;
105-
int elf_bss_start;
106-
int elf_bss_size;
103+
int elf_bss_start, elf_bss_size;
107104

108105
/* Create a new arena block with given capacity.
109106
* @capacity: The capacity of the arena block. Must be positive.
@@ -1403,8 +1400,8 @@ void error(char *msg)
14031400

14041401
strcpy(diagnostic + i, "^ Error occurs here");
14051402

1406-
/* TODO: Enhanced error reporting with location tracking will be added
1407-
* once self-hosting is stable with new token management
1403+
/* TODO: Implement line/column tracking for precise error location
1404+
* reporting. Current implementation only shows source position offset.
14081405
*/
14091406
printf("[Error]: %s\nOccurs at source location %d.\n%s\n", msg,
14101407
SOURCE->size, diagnostic);

src/lexer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,9 @@ token_t lex_token_impl(bool aliasing)
839839
if (aliasing) {
840840
alias = find_alias(token_str);
841841
if (alias) {
842-
/* FIXME: comparison with string "bool" is a temporary hack */
842+
/* FIXME: Special-casing _Bool alias handling is a workaround.
843+
* Should integrate properly with type system.
844+
*/
843845
token_t t;
844846

845847
if (is_numeric(alias)) {

src/parser.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,9 @@ var_t *parse_global_constant_value(block_t *parent, basic_block_t **bb)
756756
add_insn(parent, *bb, OP_load_constant, val, NULL, NULL, 0, NULL);
757757
} else if (lex_peek(T_string, NULL)) {
758758
lex_accept(T_string);
759-
/* Strings not supported in struct fields */
759+
/* TODO: String fields in structs not yet supported - requires proper
760+
* handling of string literals as initializers
761+
*/
760762
} else {
761763
error("Global array initialization requires constant values");
762764
}
@@ -3657,8 +3659,9 @@ bool read_global_assignment(char *token)
36573659
if (lex_peek(T_string, NULL)) {
36583660
/* String literal global initialization:
36593661
* String literals are now stored in .rodata section.
3660-
* TODO: Full support for global pointer initialization with
3661-
* rodata addresses requires compile-time address resolution.
3662+
* TODO: Implement compile-time address resolution for global
3663+
* pointer initialization with rodata addresses
3664+
* (e.g., char *p = "str";)
36623665
*/
36633666
read_literal_param(parent, bb);
36643667
rs1 = opstack_pop();
@@ -4801,7 +4804,9 @@ void read_global_decl(block_t *block, bool is_const)
48014804
lex_expect(T_semicolon);
48024805
return;
48034806
} else if (lex_accept(T_comma)) {
4804-
/* TODO: Global variable continuation syntax not yet implemented */
4807+
/* TODO: Implement global variable continuation syntax for multiple
4808+
* declarations in single statement (e.g., int a = 1, b = 2;)
4809+
*/
48054810
error("Global continuation not supported");
48064811
} else if (lex_accept(T_semicolon)) {
48074812
opstack_pop();

src/peephole.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ bool redundant_move_elim(ph2_ir_t *ph2_ir)
350350
return false;
351351
}
352352

353-
354353
/* Load/store elimination for consecutive memory operations.
355354
* Removes redundant loads and dead stores that access the same memory location.
356355
* Conservative implementation to maintain bootstrap stability.
@@ -820,7 +819,7 @@ bool triple_pattern_optimization(ph2_ir_t *ph2_ir)
820819
return true;
821820
}
822821

823-
/* FIXME: Additional patterns for future implementation:
822+
/* FIXME: Additional optimization patterns to implement:
824823
*
825824
* Pattern 3: Load-op-store with same location
826825
* {load r1, [addr]; op r2, r1, ...; store r2, [addr]}

src/reg-alloc.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
/* Allocate registers from IR. The linear-scan algorithm now expects a minimum
99
* of 7 available registers (typical for RISC-style architectures).
1010
*
11-
* TODO: Implement the "-O level" option. This allocator now always drops the
12-
* dead variable and does NOT wrtie it back to the stack.
11+
* TODO: Implement "-O level" optimization control. Currently the allocator
12+
* always performs dead variable elimination without writing back to stack.
1313
*/
1414

1515
#include "defs.h"
@@ -390,7 +390,9 @@ void extend_liveness(basic_block_t *bb, insn_t *insn, var_t *var, int offset)
390390

391391
void reg_alloc(void)
392392
{
393-
/* TODO: .bss and .data section */
393+
/* TODO: Add proper .bss and .data section support for uninitialized /
394+
* initialized globals
395+
*/
394396
for (insn_t *global_insn = GLOBAL_FUNC->bbs->insn_list.head; global_insn;
395397
global_insn = global_insn->next) {
396398
ph2_ir_t *ir;
@@ -710,8 +712,10 @@ void reg_alloc(void)
710712
ir->src0 = src0;
711713
strcpy(ir->func_name, insn->rs2->var_name);
712714
} else {
713-
/* FIXME: Avoid outdated content in register after
714-
* storing, but causing some redundant spilling.
715+
/* FIXME: Register content becomes stale after store
716+
* operation. Current workaround causes redundant
717+
* spilling - need better register invalidation
718+
* strategy.
715719
*/
716720
spill_alive(bb, insn);
717721
src0 = prepare_operand(bb, insn->rs1, -1);

src/riscv-codegen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,11 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
425425
emit(__andi(rd, rs1, rs2));
426426
return;
427427
case OP_sign_ext:
428-
/* TODO: Allow to sign extends to other types */
428+
/* TODO: Support sign extension to types other than int */
429429
emit(__andi(rd, rs1, 0xFF));
430430
emit(__slli(rd, rd, 24));
431431
emit(__srai(rd, rd, 24));
432-
/* TODO: Allow user to switch to Zbb extension if needed */
432+
/* TODO: Consider Zbb extension for improved bit manipulation */
433433
/* emit(__sext_b(rd, rs1)); */
434434
return;
435435
case OP_cast:

src/ssa.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,9 @@ void solve_phi_params(void)
799799
{
800800
for (func_t *func = FUNC_LIST.head; func; func = func->next) {
801801
for (int i = 0; i < func->num_params; i++) {
802-
/* FIXME: Rename arguments directly, might be not good here. */
802+
/* FIXME: Direct argument renaming in SSA construction phase may
803+
* interfere with later optimization passes
804+
*/
803805
var_t *var = require_var(func->bbs->scope);
804806
var_t *base = &func->param_defs[i];
805807
memcpy(var, base, sizeof(var_t));
@@ -857,7 +859,8 @@ void bb_unwind_phi(func_t *func, basic_block_t *bb)
857859
for (phi_operand_t *operand = insn->phi_ops; operand;
858860
operand = operand->next)
859861
append_unwound_phi_insn(operand->from, insn->rd, operand->var);
860-
/* TODO: Release dangling phi instruction */
862+
/* TODO: Release memory allocated for phi instruction to prevent leaks
863+
*/
861864
}
862865

863866
bb->insn_list.head = insn;

0 commit comments

Comments
 (0)