* Move branch-local register and stack allocation metadata to the
function-local struct. Conditional branches clone this data in order
to restore it after generating machine code for a branch.
Branch-local data is now only the instruction table mapping *ir.Inst
to MCValue.
* Implement conditional branching
- Process operand deaths
- Handle register and stack allocation metadata
* Avoid storing unreferenced or void typed instructions into
the branch-local instruction table.
* Fix integer types reporting the wrong value for hasCodeGenBits.
* Remove the codegen optimization for eliding length-0 jumps. I need to
reexamine how this works because it was causing invalid jumps to be
emitted.
These changes enable a Hello World example. However, all implemented
codegen is not yet feature-complete.
- asm only supports 'svc #0' at the moment
- call only supports leaf functions at the moment
- setReg uses a naive method at the moment
I forgot to do -Denable-qemu -Denable-wasmtime when testing yesterday,
sorry about that.
In reuseOperand, the code assumed a re-used register would be tracked in
the register table but that is not always the case.
See #6113 for an alternate way of doing this that we didn't end up
following.
Closes#6079.
I also took the opportunity here to extract C.zig and Elf.zig from
link.zig.
* Implemented all R-type arithmetic/logical instructions
* Implemented all I-type arithmetic/logical instructions
* Implemented all load and store instructions
* Implemented all of RV64I except FENCE
* introduce a dump() function on Module.Fn which helpfully prints to
stderr the ZIR representation of a function (can be called before
attempting to codegen it). This is a debugging tool.
* implement x86 codegen for loops
* liveness: fix analysis of conditional branches. The logic was buggy
in a couple ways:
- it never actually saved the results into the IR instruction (fixed now)
- it incorrectly labeled operands as dying when their true death was
after the conditional branch ended (fixed now)
* zir rendering is enhanced to show liveness analysis results. this
helps when debugging liveness analysis.
* fix bug in zir rendering not numbering instructions correctly
closes#6021
* the .debug_line header is written properly
* link.File.Elf gains:
- SrcFn, which is now a field in Module.Fn
- SrcFile, which is now a field in Module.Scope.File
* link.File.Elf gets a whole *Package field rather than only
root_src_dir_path.
* the fields first_dbg_line_file and last_dbg_line_file tell where the
Line Number Program begins and ends, which alows moving files when
the header gets too big, and allows appending files to the end.
* codegen is passed a buffer for emitting .debug_line
Line Number Program opcodes for functions.
See #5963
There is some work-in-progress code here, but I need to go make some
experimental changes to changing how to represent source locations and I
want to do that in a separate commit.