aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86_64/CodeGen.zig
AgeCommit message (Collapse)Author
2022-01-30stage2: implement shl_exact and shr_exactAndrew Kelley
These produce an undefined value when one bits are shifted out. New AIR instruction: shr_exact.
2022-01-26stage2: add zero- and sign-extend moves to x86_64Jakub Konka
* remove `LoweringError` error set from `Emit.zig` - it actually was less than helpful; it's better to either not throw an error since there can be instructions with mismatching operand sizes such as `movsx` or assert on a by instruction-basis. Currently, let's just pass through and see how we fare. * when moving integers into registers, check for signedness and move with zero- or sign-extension if source operand is smaller than 8 bytes. The destination operand is always assumed to be full-width, i.e., 8 bytes. * clean up `airTrunc` a little to match the rest of CodeGen inst implementations.
2022-01-25stage2: x64: implement airTruncmparadinha
2022-01-25stage2: populate debug info for args passed on stackJakub Konka
* implement cond_br when MCValue is a stack offset * implement passing compare flags and immediate on stack
2022-01-24stage2: rework a lot of stuffAndrew Kelley
AstGen: * rename the known_has_bits flag to known_non_opv to make it better reflect what it actually means. * add a known_comptime_only flag. * make the flags take advantage of identifiers of primitives and the fact that zig has no shadowing. * correct the known_non_opv flag for function bodies. Sema: * Rename `hasCodeGenBits` to `hasRuntimeBits` to better reflect what it does. - This function got a bit more complicated in this commit because of the duality of function bodies: on one hand they have runtime bits, but on the other hand they require being comptime known. * WipAnonDecl now takes a LazySrcDecl parameter and performs the type resolutions that it needs during finish(). * Implement comptime `@ptrToInt`. Codegen: * Improved handling of lowering decl_ref; make it work for comptime-known ptr-to-int values. - This same change had to be made many different times; perhaps we should look into merging the implementations of `genTypedValue` across x86, arm, aarch64, and riscv.
2022-01-23stage2: remove asserts and comments which are Emit.zig responsibilityJakub Konka
2022-01-22stage2: do not copy args passed via stack into functions localsJakub Konka
2022-01-22stage2: clean up preserving callee regs on the stackJakub Konka
Instead of using `push` and `pop` combo, we now re-use our stack allocation mechanism which means we don't have to worry about 16-byte stack adjustments on macOS as it is handled automatically for us. Another benefit is that we don't have to backpatch stack offsets when pulling args from the stack.
2022-01-19stage2: add tweak to please Apple re stack alignmentJakub Konka
This is more like a temp hack than anything else - I think the mechanism we use for adjusting the stack when pushing args onto the stack could/should be reused - i.e., we should just calculate the stack alignment before each call and then reset the `rsp` rather than relying on the current hack in `gen()` logic.
2022-01-19stage2: fix passing arguments on the stackJakub Konka
* push the arguments in reverse order * add logic for pushing args of any abi size to stack - very similar to `genSetStack` however, uses `.rsp` as the base register * increment and decrement `.rsp` if we called a function with args on the stack in `airCall` * add logic for recovering args from the caller's stack in the callee
2022-01-18Merge pull request #10624 from ziglang/prefetchAndrew Kelley
stage2: implement `@prefetch`
2022-01-18Merge pull request #10625 from ziglang/stage2-x86_64-inline-memsetJakub Konka
stage2: add inline memset, partial intcast and more array goodness for x86_64
2022-01-18stage2: implement `@prefetch`Andrew Kelley
This reverts commit f423b5949b8722d4b290f57c3d06d015e39217b0, re-instating commit d48e4245b68bf25c7f41804a5012ac157a5ee546.
2022-01-18stage2: implement airArrayElemValJakub Konka
2022-01-18Revert "stage2: implement `@prefetch`"Andrew Kelley
This reverts commit d48e4245b68bf25c7f41804a5012ac157a5ee546. I have no idea why this is failing Drone CI, but in a branch, reverting this commit solved the problem.
2022-01-18stage2: partially implement intcast on x86_64Jakub Konka
* fix violating encoding invariant for memory encoding * enable some cast tests for x86_64 and arm
2022-01-18stage2: add inline memset for x86_64 backendJakub Konka
* introduce new Mir tag `mov_mem_index_imm` which selects instruction of the form `OP ptr [reg + rax*1 + imm32], imm32` where the encoded flags select the appropriate ptr width for memory store operation (note that scale is fixed and set at 1)
2022-01-17stage2: separate ptr and stack offset codepaths in genSetStackJakub Konka
2022-01-17stage2: implement airArrayToSlice for x86_64Jakub Konka
* implement `genSetStack` for `ptr_stack_offset` * handle `ptr_add` * implement storing from register into pointer in register * split alignment and array tests into those that pass on x86_64 and those that do not * pass more tests on x86_64
2022-01-17stage2: implement airCondBr for immediate MCValue in x86_64Jakub Konka
Pass more behavior tests.
2022-01-15stage2: implement `@prefetch`Andrew Kelley
2022-01-15stage2: implement signed compareJakub Konka
2022-01-15stage2: rename Isel to Emit for x86_64Jakub Konka
Clean up generated errors in Emit.
2022-01-15stage2: refactor handling of immediates in x86_64 backendJakub Konka
Fixes issues with incorrect operand sizes in a handful of cases and allows for usage of differently sized integers in Zig sources.
2022-01-13stage2: fix build on 32-bit ISAsAndrew Kelley
Fixes regression introduced in 93b854eb745ab3294054ae71150fe60f134f4d10.
2022-01-12stage2: implement `@ctz` and `@clz` including SIMDAndrew Kelley
AIR: * `array_elem_val` is now allowed to be used with a vector as the array type. * New instructions: splat, vector_init AstGen: * The splat ZIR instruction uses coerced_ty for the ResultLoc, avoiding an unnecessary `as` instruction, since the coercion will be performed in Sema. * Builtins that accept vectors now ignore the type parameter. Comment from this commit reproduced here: The accepted proposal #6835 tells us to remove the type parameter from these builtins. To stay source-compatible with stage1, we still observe the parameter here, but we do not encode it into the ZIR. To implement this proposal in stage2, only AstGen code will need to be changed. Sema: * `clz` and `ctz` ZIR instructions are now handled by the same function which accept AIR tag and comptime eval function pointer to differentiate. * `@typeInfo` for vectors is implemented. * `@splat` is implemented. It takes advantage of `Value.Tag.repeated` 😎 * `elemValue` is implemented for vectors, when the index is a scalar. Handling a vector index is still TODO. * Element-wise coercion is implemented for vectors. It could probably be optimized a bit, but it is at least complete & correct. * `Type.intInfo` supports vectors, returning int info for the element. * `Value.ctz` initial implementation. Needs work. * `Value.eql` is implemented for arrays and vectors. LLVM backend: * Implement vector support when lowering `array_elem_val`. * Implement vector support when lowering `ctz` and `clz`. * Implement `splat` and `vector_init`.
2022-01-09stage2 codegen: fix airBlock bug in 3 backendsjoachimschmidt557
2022-01-08stage2: @errorName sema+llvmRobin Voetter
2022-01-06stage2: implement basics of airWrapErrUnionErrJakub Konka
Enable more behavior tests for x86_64.
2022-01-06stage2: fix airStructFieldPtr and airStructFieldValJakub Konka
This finally fixes `zig test`.
2022-01-06stage2: fix airSliceElemValJakub Konka
Refactor codegen and fix a bug in Isel.
2022-01-06stage2: fix inline memcpyJakub Konka
2022-01-06stage2: implement slice_ptrJakub Konka
2022-01-06stage2: fix loading pointer value from registerJakub Konka
Fix accessing optional payload.
2022-01-06stage2: implement CMP stack value with immediateJakub Konka
2022-01-04stage2: turn several panics into codegen errorsJakub Konka
Add x86_64 backend to behavior.zig test suite.
2022-01-04stage2: pass empty zig testJakub Konka
2022-01-04stage2: implement struct_field_val and struct_field_val_ptrJakub Konka
Handle function pointers in airCall
2022-01-04stage2: implement inline memcpyJakub Konka
2022-01-04stage2: implement slice_elem_valJakub Konka
2022-01-04stage2: implement isErr/isNonErr and unwrap errorJakub Konka
2022-01-04stage2: implement setting stack from memory valueJakub Konka
2022-01-04stage2: clean up load functionJakub Konka
2022-01-04stage2: implement slice_len for slices on the stackJakub Konka
2022-01-04stage2: fix loading ptr into registerJakub Konka
2022-01-01stage2: remove safety check for optional payload in codegenJakub Konka
This will be enforced by Sema.
2021-12-31stage2: implement loading-storing via pointer (in register)Jakub Konka
* load address (pointer) to a stack variable in a register via `lea` instruction * store value on the stack via a pointer stored in a register via `mov [reg], imm` instruction * the lowerings naturally are handled automatically by Mir -> Isel layer * add initial (without safety) implementation of `.optional_payload` * add matching stage2 test cases
2021-12-31stage2: implement genSetReg for ptr_stack_offsetJakub Konka
2021-12-31stage2: implement isNull() and isNonNull()Jakub Konka
2021-12-31stage2: rename Emit to Isel for x86_64Jakub Konka