aboutsummaryrefslogtreecommitdiff
path: root/src-self-hosted/link.zig
AgeCommit message (Collapse)Author
2020-08-05Stage2: minor File.ELF refactorNoam Preil
2020-08-04stage2: fix ZIR support and C back endAndrew Kelley
2020-08-04stage2: link: fix not freeing debug line free listAndrew Kelley
2020-08-04stage2: fix updating debug line info not resizing properlyAndrew Kelley
2020-08-04stage2 .debug_line: handle Decl line numbers changingAndrew Kelley
2020-08-03stage2: stop needlessly re-analyzing unchanged functionsAndrew Kelley
2020-08-03stage2 .debug_line: handle Decl deletes and updatesAndrew Kelley
2020-08-03stage2: move link.File.ELF.SrcFn field from Module.Fn to Module.DeclAndrew Kelley
SrcFn represents the function in the linked output file, if the `Decl` is a function. This is stored here and not in `Fn` because `Decl` survives across updates but `Fn` does not. TODO Look into making `Fn` a longer lived structure and moving this field there to save on memory usage.
2020-08-03stage2 .debug_line stepping with gdb is workingAndrew Kelley
2020-08-03stage2 .debug_line: simpler strategy for incremental compilationAndrew Kelley
See #5963
2020-08-03stage2: dwarf: fix standard opcode length of LNS_fixed_advance_pcAndrew Kelley
2020-08-03downgrade .debug_info to DWARFv4Andrew Kelley
gdb, notice me senpai
2020-08-03downgrade .debug_line to DWARFv4Andrew Kelley
apparently gdb 8.3.1 which is still a commonly distributed version of gdb, does not support v5.
2020-08-02codegen: emit .debug_line ops for IR instructionsAndrew Kelley
2020-08-02.debug_line: avoid DW_FORM_strp to work around readelf/gdbAndrew Kelley
These tools do not support DWARFv5 yet apparently.
2020-08-02.debug_line: don't rely on header_length fieldAndrew Kelley
Empirically, debug info consumers do not respect this field, or otherwise consider it to be an error when it does not point exactly to the end of the header. Therefore we rely on the NOP jump at the beginning of the Line Number Program for padding rather than this field. llvm-dwarfdump says the line number data is fine; gdb and binutils-readelf crap out.
2020-08-02.debug_line incremental compilation initial supportAndrew Kelley
Supports writing the first function. Still TODO is: * handling the .debug_line header growing too large * adding a new file to an existing compilation * adding an additional function to an existing file * handling incremental updates * adding the main IR debug ops for IR instructions There are also issues to work out: * readelf --debug-dump=rawline is saying there is no .debug_str section even though there is * readelf --debug-dump=decodedline is saying the file index 0 is bad and reporting some other kind of corruption.
2020-08-02stage2: add the .debug_line header and associated data typesAndrew Kelley
* 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.
2020-08-02stage2: move format-specific code to link.File.XIsaac Freund
This makes the code outside of link.File.Elf less elf-specific and will allow for easier implementation of other formats such as wasm.
2020-07-31stage2: implement .debug_aranges DWARFAndrew Kelley
2020-07-30stage2: add some tracy calls to link.zig functionsAndrew Kelley
2020-07-31stage2: add DWARF info for the main compilation unitAndrew Kelley
2020-07-29stage2: codegen handles undefined valuesAndrew Kelley
* `optimize_mode` is passed to `link.File` and stored there * improve the debugging function `Module.dumpInst` * get rid of `Value.the_one_possible_value` in favor of a few more specific values for different types. This is less buggy, one less footgun. * `Type.onePossibleValue` now returns a `?Value` instead of `bool`. * codegen handles undefined values. `undef` is a new `MCValue` tag. It uses 0xaa values depending on optimization mode. However optimization mode does not yet support scope overrides. * link.zig: move the `Options` field from `File.Elf` and `File.C` to the base struct. - fix the Tag enum to adhere to style conventions * ZIR now supports emitting undefined values. * Fix the logic of comptime math to properly compare against zero using the `compareWithZero` function.
2020-07-25stage2: remove superfluous else => unreachableAndrew Kelley
2020-07-23self-hosted: AST flattening, astgen improvements, result locations, and moreAndrew Kelley
* AST: flatten ControlFlowExpression into Continue, Break, and Return. * AST: unify identifiers and literals into the same AST type: OneToken * AST: ControlFlowExpression uses TrailerFlags to optimize storage space. * astgen: support `var` as well as `const` locals, and support explicitly typed locals. Corresponding Module and codegen code is not implemented yet. * astgen: support result locations. * ZIR: add the following instructions (see the corresponding doc comments for explanations of semantics): - alloc - alloc_inferred - bitcast_result_ptr - coerce_result_block_ptr - coerce_result_ptr - coerce_to_ptr_elem - ensure_result_used - ensure_result_non_error - ret_ptr - ret_type - store - param_type * the skeleton structure for result locations is set up. It's looking pretty clean so far. * add compile error for unused result and compile error for discarding errors. * astgen: split builtin calls up to implemented manually, and implement `@as`, `@bitCast` (and others) with respect to result locations. * add CLI support for hex and raw object formats. They are not supported by the self-hosted compiler yet, and emit errors. * rename `--c` CLI to `-ofmt=[objectformat]` which can be any of the object formats. Only ELF and C are supported so far. Also added missing help to the help text. * Remove hard tabs from C backend test cases. Shame on you Noam, you are grounded, you should know better, etc. Bad boy. * Delete C backend code and test case that relied on comptime_int incorrectly making it all the way to codegen.
2020-07-13stage2: add retvoid support to CBEAndrew Kelley
2020-07-12CBE: Make C an ObjectFormat instead of a special bool (#5849)pixelherodev
2020-07-11run zig fmt on std lib and self hostedVexu
2020-07-08Merge remote-tracking branch 'origin/master' into register-allocationAndrew Kelley
2020-07-08CBE: Don't expose openCFile, always close file after an updateNoam Preil
2020-07-08CBE: Emit asm decls for now, but rename to make them validNoam Preil
2020-07-07CBE: Cleanup unimplementedsNoam Preil
2020-07-07CBE: Improve resource cleanupNoam Preil
2020-07-07CBE: truncate output fileNoam Preil
2020-07-07CBE: Some cleanupNoam Preil
2020-07-07CBE: Move standards determination to generated codeNoam Preil
2020-07-07CBE: working asm Inputs and Outputs; std{int,def}.h auto-inclusionNoam Preil
2020-07-07CBE: Working function call w/ no args or return valueNoam Preil
2020-07-07CBE: Get test more usefulNoam Preil
2020-07-07CBE skeletonNoam Preil
2020-07-07Stage2: Refactor in preparation for C backendNoam Preil
2020-07-07fix liveness analysis and not correctly propagating link errorsAndrew Kelley
We still flush the ELF file even when there are compile errors.
2020-07-06stage2: skeleton codegen for x64 ADDAndrew Kelley
also rework Module to take advantage of the new hash map implementation.
2020-07-05update more HashMap API usageAndrew Kelley
2020-06-24self-hosted: fix test regressionsAndrew Kelley
I'm allowing incremental compilation of ZIR modules to be broken. This is not a real use case of ZIR, and the feature requires a lot of code duplication with incremental compilation of Zig AST (which works great).
2020-06-18remove std.debug.warn debugging logsAndrew Kelley
2020-06-18self-hosted: implement Decl lookupAndrew Kelley
* Take advantage of coercing anonymous struct literals to struct types. * Reworks Module to favor Zig source as the primary use case. Breaks ZIR compilation, which will have to be restored in a future commit. * Decl uses src_index rather then src, pointing to an AST Decl node index, or ZIR Module Decl index, rather than a byte offset. * ZIR instructions have an `analyzed_inst` field instead of Module having a hash table. * Module.Fn loses the `fn_type` field since it is redundant with its `owner_decl` `TypedValue` type. * Implement Type and Value copying. A ZIR Const instruction's TypedValue is copied to the Decl arena during analysis, which allows freeing the ZIR text instructions post-analysis. * Don't flush the ELF file if there are compilation errors. * Function return types allow arbitrarily complex expressions. * AST->ZIR for function calls and return statements.
2020-05-28remove debug log statementsAndrew Kelley
2020-05-28stage2: handle deletions and better dependency resolutionAndrew Kelley
* Deleted decls are deleted; unused decls are also detected as deleted. Cycles are not yet detected. * Re-analysis is smarter and will not cause a re-analysis of dependants when only a function body is changed.
2020-05-28stage2: first pass at recursive dependency resolutionAndrew Kelley