aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
AgeCommit message (Collapse)Author
2021-05-12Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * lib/std/os/linux.zig * lib/std/os/windows/bits.zig * src/Module.zig * src/Sema.zig * test/stage2/test.zig Mainly I wanted Jakub's new macOS code for respecting stack size, since we now depend on it for debug builds able to pass one of the test cases for recursive comptime function calls with `@setEvalBranchQuota`. The conflicts were all trivial.
2021-05-11C backend: fix emitting '$' in identifier namesAndrew Kelley
This causes warnings from clang when compiled.
2021-05-11stage2: add `owns_tv` flag to `Module.Decl`Andrew Kelley
Decl objects need to know whether they are the owner of the Type/Value associated with them, in order to decide whether to destroy the associated Namespace, Fn, or Var when cleaning up.
2021-05-08fix merge conflicts from previous commitAndrew Kelley
Any PRs merged after the one that made testing functions return errors needs to get rebased!
2021-05-09Merge pull request #8474 from gracefuu/grace/encode-instructionAndrew Kelley
stage2 x86_64: encoding helpers, fix bugs
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-05-08update usage of std.testing in stage2Veikka Tuominen
2021-04-28stage2: semaDecl properly analyzes the decl blockAndrew Kelley
Also flattened out Decl TypedValue fields into ty, val, has_tv and add relevant fields to Decl for alignment and link section.
2021-04-28Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
In particular I wanted to take advantage of the new hex float parsing code.
2021-04-28stage2 riscv64: cleanup code and add testsjoachimschmidt557
2021-04-19AstGen: implement inline asm outputAndrew Kelley
2021-04-16stage2 x86_64: simplify inst encoder to a set of dumb helper fnsgracefu
2021-04-16stage2 x86_64: add instruction encoder helper fngracefu
2021-04-15stage2: improvements aimed at std lib integrationAndrew Kelley
* AstGen: emit decl lookup ZIR instructions rather than directly looking up decls in AstGen. This is necessary because we want to reuse the same immutable ZIR code for multiple generic instantiations (and comptime function calls). * AstGen: fix using members_len instead of fields_len for struct decls. * structs: the struct_decl ZIR instruction is now also a block. This is so that the type expressions, default field value expressions, and alignment expressions can be evaluated in a scope that contains the decls from the struct namespace itself. * Add "std" and "builtin" packages to the builtin package. * Don't try to build glibc, musl, or mingw-w64 when using `-ofmt=c`. * builtin.zig is generated without `usingnamespace`. * builtin.zig takes advantage of `std.zig.fmtId` for CPU features. * A first pass at implementing `usingnamespace`. It's problematic and should either be deleted, or polished, before merging this branch. * Sema: allow explicitly specifying the namespace in which to look up Decls. This is used by `struct_decl` in order to put the decls from the struct namespace itself in scope when evaluating the type expressions, default value expressions, and alignment expressions. * Module: fix `analyzeNamespace` assuming that it is the top-level root declaration node. * Sema: implement comptime and runtime cmp operator. * Sema: implement peer type resolution for enums and enum literals. * Pull in the changes from master branch: 262e09c482d98a78531c049a18b7f24146fe157f. * ZIR: complete out simple_ptr_type debug printing
2021-04-11Merge remote-tracking branch 'origin/master' into llvm12Michael Dusan
2021-04-08Refactor link/wasm.zig to use offset tableLuuk de Gram
This refactor inserts an offset table into wasm's data section where each offset points to the actual data region. This means we can keep offset indexes consistant and do not have to perform any computer to determine where in the data section something like a static string exists. Instead during runtime it will load the data offset onto the stack.
2021-04-08CleanupLuuk de Gram
2021-04-08Calculate data length to ensure correct pointer offsetsLuuk de Gram
2021-04-08Basic "Hello world" workingLuuk de Gram
2021-04-08Merge pull request #8464 from gracefuu/grace/wasm-opsAndrew Kelley
stage2 wasm: Add division and bitwise/boolean ops &, |, ^, and, or
2021-04-08stage2 AArch64: Add conditional branch instructionsjoachimschmidt557
2021-04-08stage2 wasm: Add bitwise/boolean ops &, |, ^, and, orgracefu
2021-04-08stage2: Add .div to ir.ziggracefu
2021-04-07C backend: enumerate all the types in renderTypeAndrew Kelley
Now that we're close to supporting all the types, get rid of the `else` prong and explicitly list out those types that are not yet implemented. Thanks @g-w1
2021-04-06C backend: implement Enum types and valuesAndrew Kelley
They are lowered directly as the integer tag type, with no typedef.
2021-04-05stage2 wasm codegen: refactor to use wasm.buildOpcodegracefu
2021-04-05std/wasm: add buildOpcode to help construction of `Opcode`sgracefu
2021-04-05stage2 wasm: codegen `mul` opgracefu
2021-04-05stage2 wasm: codegen `sub` opgracefu
2021-04-04LLVM sub-arch triple: remove TODO commentAndrew Kelley
See #6542 for more details. Upon investigation, this change is not needed.
2021-04-02stage2: progress towards basic structsAndrew Kelley
Introduce `ResultLoc.none_or_ref` which is used by field access expressions to avoid unnecessary loads when the field access itself will do the load. This turns: ```zig p.y - p.x - p.x ``` from ```zir %14 = load(%4) node_offset:8:12 %15 = field_val(%14, "y") node_offset:8:13 %16 = load(%4) node_offset:8:18 %17 = field_val(%16, "x") node_offset:8:19 %18 = sub(%15, %17) node_offset:8:16 %19 = load(%4) node_offset:8:24 %20 = field_val(%19, "x") node_offset:8:25 ``` to ```zir %14 = field_val(%4, "y") node_offset:8:13 %15 = field_val(%4, "x") node_offset:8:19 %16 = sub(%14, %15) node_offset:8:16 %17 = field_val(%4, "x") node_offset:8:25 ``` Much more compact. This requires `Sema.zirFieldVal` to support both pointers and non-pointers. C backend: Implement typedefs for struct types, as well as the following TZIR instructions: * mul * mulwrap * addwrap * subwrap * ref * struct_field_ptr Note that add, addwrap, sub, subwrap, mul, mulwrap instructions are all incorrect currently and need to be updated to properly handle wrapping and non wrapping for signed and unsigned. C backend: change indentation delta to 1, to make the output smaller and to process fewer bytes. I promise I will add a test case as soon as I fix those warnings that are being printed for my test case.
2021-04-02stage2 AArch64: Add ldrh and ldrb instructionsjoachimschmidt557
2021-04-02Merge remote-tracking branch 'origin/master' into llvm12Andrew Kelley
2021-03-31Merge pull request #8266 from ziglang/zir-memory-layoutAndrew Kelley
rework ZIR memory layout; overhaul source locations
2021-03-31stage2 AArch64: implement strb and strhjoachimschmidt557
2021-03-28Merge remote-tracking branch 'origin/master' into llvm12Andrew Kelley
2021-03-28Merge remote-tracking branch 'origin/master' into zir-memory-layoutAndrew Kelley
Wanted to make sure those new test cases still pass. Also grab that CI fix so we can get those green check marks.
2021-03-28stage2: implement sema for @errorToInt and @intToErrorjacob gw
2021-03-23stage2: handle void value in genRet in LLVM backendTimon Kruiper
2021-03-23stage2: rename fail to todo in LLVM backendTimon Kruiper
This way we don't have to pass src to every function and we can simply use the first node as the lazy source location for all the todo errors.
2021-03-22Fix getNot and add test casesLuuk de Gram
2021-03-22Implement more instructions for more control flow supportLuuk de Gram
2021-03-20stage2: restructure LLVM backendTimon Kruiper
The LLVM backend is now structured into 3 different structs, namely Object, DeclGen and FuncGen. Object represents an object that is generated by the LLVM backend. DeclGen is responsible for generating a decl and FuncGen is responsible for generating llvm instructions from tzir in a function.
2021-03-19llvm backend: use new srclocjacob gw
this allows to compile with ninja
2021-03-18stage2: the code is compiling againAndrew Kelley
(with a lot of things commented out)
2021-03-18stage2: get Module and Sema compiling againAndrew Kelley
There are some `@panic("TODO")` in there but I'm trying to get the branch to the point where collaborators can jump in. Next is to repair the seam between LazySrcLoc and codegen's expected absolute file offsets.
2021-03-17zld: use aarch64 for opcodesJakub Konka
2021-03-16stage2 llvm bindings: use correct type for LLVMBool for ABI compatTadeo Kondrak
2021-03-14stage2 llvm bindings: rename LLVMBool to BoolTadeo Kondrak
2021-03-12Merge remote-tracking branch 'origin/master' into llvm12Andrew Kelley