Description
Currently, the compiler parses string literals but does not lower them in the QBE backend. This prevents basic programs like:
from working correctly.
This issue focuses on adding basic string literal support in the QBE backend by emitting them into the .data section and referencing them in generated code.
Goal
Enable simple string output via console.log by supporting string literals in QBE code generation.
Tasks
Expected Behavior
Input:
QBE IR (simplified idea):
data $str0 = { b "hello", b 0 }
export function w $main() {
@start
call $puts(l $str0)
ret 0
}
Hints
- Look into:
src/qbe/qbe_codegen.c
- You may need:
- A small string pool (array or hashmap)
- A helper like:
get_string_label(const char* str)
- QBE uses null-terminated strings (
b 0)
Scope
- Only handle string literals
- No need for:
- String operations
- Concatenation
- Dynamic allocation
Why This Matters
- Unlocks basic I/O capability
- First step toward real JS support
- Clean, self-contained backend improvement
Difficulty
🟢 Good First Issue
Status
Open for contribution
Description
Currently, the compiler parses string literals but does not lower them in the QBE backend. This prevents basic programs like:
from working correctly.
This issue focuses on adding basic string literal support in the QBE backend by emitting them into the
.datasection and referencing them in generated code.Goal
Enable simple string output via
console.logby supporting string literals in QBE code generation.Tasks
.datasection entries in QBE IRstr0,str1)console.loglowering to handle string argumentsExpected Behavior
Input:
QBE IR (simplified idea):
Hints
src/qbe/qbe_codegen.cget_string_label(const char* str)b 0)Scope
Why This Matters
Difficulty
🟢 Good First Issue
Status
Open for contribution