aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86_64/CodeGen.zig
AgeCommit message (Collapse)Author
2022-02-19x64: add unsigned div and move logic into a helper fnJakub Konka
2022-02-19x64: implement div_exact for ints (signed+unsigned)Jakub Konka
2022-02-19Merge pull request #10924 from ziglang/air-independence-dayAndrew Kelley
AIR independence day
2022-02-18stage2: make AIR not reference ZIR for inline assemblyAndrew Kelley
Instead it stores all the information it needs to into AIR. closes #10784
2022-02-18stage2: Implement `@bitReverse` and `@byteSwap`Cody Tapscott
This change implements the above built-ins for Sema and the LLVM backend. Other backends have had placeholders added for lowering.
2022-02-18x64: ensure 16byte stack alignment across callsJakub Konka
2022-02-18x64: rename copyToNewRegister to copyToRegisterWithInstTracking for impr clarityJakub Konka
2022-02-18x64: fix wrong regalloc with inst tracking in airCmpJakub Konka
We return compare flags rather than a register which than wrongly cheats the regalloc into thinking we carry the instruction in the register which we do not.
2022-02-18x64: implement array_elem_val when array is stored in memoryJakub Konka
2022-02-18x64: implement array_elem_val when array fits in registerJakub Konka
2022-02-18x64: implement slice_elem_ptrJakub Konka
2022-02-18x64: pass all args on stack in debug and if not extern fnJakub Konka
If the function call is not extern and we are compiling in debug, pass function params always on stack. This will improve debugging capabilities since the params will not be volatile and possibly clobbered by the procedure code. Finish implementation of `imul_complex`.
2022-02-17x64: fix ptr_add and ptr_subJakub Konka
Add standalone implementation of operand reuse for ptr related arithmetic operations of add and sub.
2022-02-17x64: handle storing non-pow2 values to stack from registerJakub Konka
This actually requires storing and shifting mechanics so that we don't accidentally clobber anything else on the stack.
2022-02-16x64: refactor use of inline memcpyJakub Konka
2022-02-16x64: overhaul stack handling mechanicsJakub Konka
Now, the abstracted stack offsets grow in the same direction as the real stack values in hardware, and allocating stack memory is done by the taking the last stack offset, adding required abi size and aligning to the required abi align. Stack handling is now more natural as it aligns itself with how it works in hardware; hence stepping through the debugger and printing out different stack values is intuitive. Finally, the stack pointers are now correctly aligned to the required (and not necessarily natural) alignment.
2022-02-16x64: fix signed truncateJakub Konka
2022-02-16x64: separate ptr_add and ptr_sub from normal bin opsJakub Konka
2022-02-16x64: implement airSliceJakub Konka
2022-02-16x64: fix ptr_addJakub Konka
However, still missing is taking into account pointer alignment when performing arithmetic.
2022-02-16x64: impl genBinMathOpMir for ptr_stack_off and PIE memoryJakub Konka
2022-02-11macho: correctly lower slices incl reloc and rebase trackingJakub Konka
Match changes required to `Elf` linker, which enable lowering of const slices on `MachO` targets. Expand `Mir` instructions requiring the knowledge of the containing atom - pass the symbol index into the linker's table from codegen via mir to emitter, to then utilise it in the linker.
2022-02-11codegen: handle lowering of const slice pointersJakub Konka
2022-02-10stage2: handle truncate to signed non-pow-two integersJakub Konka
2022-02-09stage2: implement all builtin floatops for f{16,32,64}John Schmidt
- Merge `floatop.zig` and `floatop_stage1.zig` since most tests now pass on stage2. - Add more behavior tests for a bunch of functions.
2022-02-08stage2: handle direct and got load for stack argsJakub Konka
2022-02-08stage2: tiny improvements all over the placeJakub Konka
* pass more x64 behavior tests * return with a TODO error when lowering a decl with no runtime bits * insert some debug logs for tracing recursive descent down the type-value tree when lowering types * print `Decl`'s name when print debugging `decl_ref` value
2022-02-08Merge pull request #10832 from ziglang/x64-more-structsJakub Konka
stage2,x64: pass more tests with structs
2022-02-07stage2: implement @sqrt for f{16,32,64}John Schmidt
Support for f128, comptime_float, and c_longdouble require improvements to compiler_rt and will implemented in a later PR. Some of the code in this commit could be made more generic, for instance `llvm.airSqrt` could probably be `llvm.airUnaryMath`, but let's cross that bridge when we get to it.
2022-02-07stage2,x64: impl lowering of shift ops in EmitJakub Konka
2022-02-07stage2,x64: impl masking reg for struct_field_valJakub Konka
2022-02-07stage2,x64: fix registerAlias helper functionJakub Konka
2022-02-07stage2,x64: implement genSetStack for memory operandJakub Konka
2022-02-07Merge pull request #10803 from ziglang/decl-has-lib-nameAndrew Kelley
stage2: store externs lib name as part of decl
2022-02-07stage2: lower unnamed constants in Elf and MachOJakub Konka
* link: add a virtual function `lowerUnnamedConsts`, similar to `updateFunc` or `updateDecl` which needs to be implemented by the linker backend in order to be used with the `CodeGen` code * elf: implement `lowerUnnamedConsts` specialization where we lower unnamed constants to `.rodata` section. We keep track of the atoms encompassing the lowered unnamed consts in a global table indexed by parent `Decl`. When the `Decl` is updated or destroyed, we clear the unnamed consts referenced within the `Decl`. * macho: implement `lowerUnnamedConsts` specialization where we lower unnamed constants to `__TEXT,__const` section. We keep track of the atoms encompassing the lowered unnamed consts in a global table indexed by parent `Decl`. When the `Decl` is updated or destroyed, we clear the unnamed consts referenced within the `Decl`. * x64: change `MCValue.linker_sym_index` into two `MCValue`s: `.got_load` and `.direct_load`. The former signifies to the emitter that it should emit a GOT load relocation, while the latter that it should emit a direct load (`SIGNED`) relocation. * x64: lower `struct` instantiations
2022-02-06stage2: add new Decl subtype, ExternFnJakub Konka
`ExternFn` will contain a maybe-lib-name if it was defined with the `extern` keyword like so ```zig extern "c" fn write(usize, usize, usize) usize; ``` `lib_name` will live as long as `ExternFn` decl does.
2022-02-06x86_64: add distinct MCValue representing symbol index in the linkerJakub Konka
For PIE targets, we defer getting an address of value until the linker has allocated all atoms and performed the relocations. In codegen, we represent this via `MCValue.linker_sym_index` value.
2022-02-06stage2 regalloc: Introduce error.OutOfRegistersjoachimschmidt557
2022-02-04x64: implement storing to MCValue.memory for PIE targetsJakub Konka
2022-02-03stage2: remove the concept of register exceptionsJakub Konka
2022-02-03x64: swap out register exceptions for freeze/unfreeze apiJakub Konka
2022-02-03x64: use freeze/unfreeze api; TODO for PIEJakub Konka
2022-02-03Merge branch 'test-1486' of git://github.com/mparadinha/zig into ↵Jakub Konka
mparadinha-test-1486
2022-02-02stage2: pad out (non-packed) struct fields when lowering to bytesJakub Konka
* pad out (non-packed) struct fields when lowering to bytes to be saved in the binary - prior to this change, fields would be saved at non-aligned addresses leading to wrong accesses * add a matching test case to `behavior/struct.zig` tests * fix offset to field calculation in `struct_field_ptr` on `x86_64`
2022-02-02x86_64: handle struct_field_ptr for stack_offset mcvJakub Konka
2022-02-02x86_64: handle struct_field_ptr for register mcvJakub Konka
2022-02-02x86_64: start moving to new regalloc freeze APIJakub Konka
2022-02-02need to go through the GOT, and use a temporary registermparadinha
2022-02-02implement store for 8 byte immediatesmparadinha
2022-02-02implement storing to MCValue.memorymparadinha