aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
AgeCommit message (Collapse)Author
2019-02-14omit nonnull attribute for C pointersAndrew Kelley
See #1059
2019-02-14runtime safety check for casting null to pointerAndrew Kelley
see #1059
2019-02-11add C pointer type to @typeInfoAndrew Kelley
See #1059
2019-02-11C pointer comparison and arithmeticAndrew Kelley
See #1059
2019-02-10avoid needlessly creating global constantsAndrew Kelley
This deletes some legacy cruft, and produces leaner object files. Example: ``` var x: i32 = 1234; export fn entry() i32 { return x; } ``` This produces: ``` @x = internal unnamed_addr global i32 1234, align 4 @0 = internal unnamed_addr constant i32* @x, align 8 ``` and @0 is never even used. After this commit, @0 is not produced. This fixes a bug: Zig was creating invalid LLVM IR when one of these globals that shouldn't exist takes the address of a thread local variable. In LLVM 8.0.0rc2, it would produce a linker error. But probably after my bug report is solved it will be caught by the IR verifier. https://bugs.llvm.org/show_bug.cgi?id=40652
2019-02-10avoid needlessly creating global constantsAndrew Kelley
This deletes some legacy cruft, and produces leaner object files. Example: ``` var x: i32 = 1234; export fn entry() i32 { return x; } ``` This produces: ``` @x = internal unnamed_addr global i32 1234, align 4 @0 = internal unnamed_addr constant i32* @x, align 8 ``` and @0 is never even used. After this commit, @0 is not produced. This fixes a bug: Zig was creating invalid LLVM IR when one of these globals that shouldn't exist takes the address of a thread local variable. In LLVM 8.0.0rc2, it would produce a linker error. But probably after my bug report is solved it will be caught by the IR verifier. https://bugs.llvm.org/show_bug.cgi?id=40652
2019-02-09Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2019-02-09implement vector math safety with ext and truncAndrew Kelley
2019-02-09implement vector addition with safety checkingAndrew Kelley
this would work if @llvm.sadd.with.overflow supported vectors, which it does in trunk. but it does not support them in llvm 7 or even in llvm 8 release branch. so the next commit after this will have to do a different strategy, but when llvm 9 comes out it may be worth coming back to this one.
2019-02-07fix using the result of @intCast to u0Andrew Kelley
closes #1817
2019-02-07Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2019-02-07better error message when LLVM does not understand a tripleAndrew Kelley
2019-02-06Merge pull request #1924 from ziglang/tlsAndrew Kelley
Implement Thread Local Variables
2019-02-06implement Thread Local Storage on WindowsAndrew Kelley
2019-02-06require running std lib tests coherentlyAndrew Kelley
this should actually improve CI times a bit too See the description at the top of std/os/startup.zig (deleted in this commit) for a more detailed understanding of what this commit does.
2019-02-06thread local storage working for linux x86_64Andrew Kelley
2019-02-05Added support for vector wrapping mult and subJimmi Holst Christensen
* I also merged the code that generates ir for add, sub, and mult
2019-02-04Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2019-02-04SIMD: array to vector, vector to array, wrapping int addAndrew Kelley
also vectors and arrays now use the same ConstExprVal representation See #903
2019-02-01introduce --single-threaded build optionAndrew Kelley
closes #1764 This adds another boolean to the test matrix; hopefully it does not inflate the time too much. std.event.Loop does not work with this option yet. See #1908
2019-01-30introduce vector type for SIMDAndrew Kelley
See #903 * create with `@Vector(len, ElemType)` * only wrapping addition is implemented This feature is far from complete; this is only the beginning.
2019-01-29backport copy elision changesAndrew Kelley
This commit contains everything from the copy-elision-2 branch that does not have to do with copy elision directly, but is generally useful for master branch. * All const values know their parents, when applicable, not just structs and unions. * Null pointers in const values are represented explicitly, rather than as a HardCodedAddr value of 0. * Rename "maybe" to "optional" in various code locations. * Separate DeclVarSrc and DeclVarGen * Separate PtrCastSrc and PtrCastGen * Separate CmpxchgSrc and CmpxchgGen * Represent optional error set as an integer, using the 0 value. In a const value, it uses nullptr. * Introduce type_has_one_possible_value and use it where applicable. * Fix debug builds not setting memory to 0xaa when storing undefined. * Separate the type of a variable from the const value of a variable. * Use copy_const_val where appropriate. * Rearrange structs to pack data more efficiently. * Move test/cases/* to test/behavior/* * Use `std.debug.assertOrPanic` in behavior tests instead of `std.debug.assert`. * Fix outdated slice syntax in docs.
2019-01-09Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2019-01-09when rendering llvm const values, ensure the types alignAndrew Kelley
the representation of the const expr val in zig, and the type that we tell LLVM it is.
2019-01-08Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2019-01-08fix debug info for function pointersAndrew Kelley
found when testing against LLVM 8 see https://bugs.llvm.org/show_bug.cgi?id=40198
2019-01-02@bitreverse intrinsic, part of #767 (#1865)vegecode
* bitreverse - give bswap behavior * bitreverse, comptime_ints, negative values still not working? * bitreverse working for negative comptime ints * Finished bitreverse test cases * Undo exporting a bigint function. @bitreverse test name includes ampersand * added docs entry for @bitreverse
2019-01-01Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2018-12-29Merge pull request #1859 from mgxm/fbsd2Andrew Kelley
Progress towards tier 1 support for FreeBSD x86_64
2018-12-26fixupsAndrew Kelley
2018-12-23git user error fixnebulaeonline
2018-12-23msvc subsystem option handling; added uefi os typenebulaeonline
2018-12-23llvm8: fix ZigLLVMCreateFunctionAndrew Kelley
2018-12-23llvm8: fix build errorsAndrew Kelley
2018-12-19freebsd: link against libcMarcio Giaxa
Since the stable kernel ABI is through libc #1759
2018-12-18ir: delete dead codeAndrew Kelley
2018-12-12breaking API changes to all readInt/writeInt functions & moreAndrew Kelley
* add `@bswap` builtin function. See #767 * comptime evaluation facilities are improved to be able to handle a `@ptrCast` with a backing array. * `@truncate` allows "truncating" a u0 value to any integer type, and the result is always comptime known to be `0`. * when specifying pointer alignment in a type expression, the alignment value of pointers which do not have addresses at runtime is ignored, and always has the default/ABI alignment * threw in a fix to freebsd/x86_64.zig to update syntax from language changes * some improvements are pending #863 closes #638 closes #1733 std lib API changes * io.InStream().readIntNe renamed to readIntNative * io.InStream().readIntLe renamed to readIntLittle * io.InStream().readIntBe renamed to readIntBig * introduced io.InStream().readIntForeign * io.InStream().readInt has parameter order changed * io.InStream().readVarInt has parameter order changed * io.InStream().writeIntNe renamed to writeIntNative * introduced io.InStream().writeIntForeign * io.InStream().writeIntLe renamed to writeIntLittle * io.InStream().writeIntBe renamed to writeIntBig * io.InStream().writeInt has parameter order changed * mem.readInt has different parameters and semantics * introduced mem.readIntNative * introduced mem.readIntForeign * mem.readIntBE renamed to mem.readIntBig and different API * mem.readIntLE renamed to mem.readIntLittle and different API * introduced mem.readIntSliceNative * introduced mem.readIntSliceForeign * introduced mem.readIntSliceLittle * introduced mem.readIntSliceBig * introduced mem.readIntSlice * mem.writeInt has different parameters and semantics * introduced mem.writeIntNative * introduced mem.writeIntForeign * mem.writeIntBE renamed to mem.readIntBig and different semantics * mem.writeIntLE renamed to mem.readIntLittle and different semantics * introduced mem.writeIntSliceForeign * introduced mem.writeIntSliceNative * introduced mem.writeIntSliceBig * introduced mem.writeIntSliceLittle * introduced mem.writeIntSlice * removed mem.endianSwapIfLe * removed mem.endianSwapIfBe * removed mem.endianSwapIf * added mem.littleToNative * added mem.bigToNative * added mem.toNative * added mem.nativeTo * added mem.nativeToLittle * added mem.nativeToBig
2018-11-26stage1: better file path handlingAndrew Kelley
* better message printed when cache hash fails * better handling of '/' as root source file * os_path_split parses '/' and '/a' correctly closes #1693 closes #1746
2018-11-24refactor type_requires_comptime to have possible errorAndrew Kelley
fixes a compiler crash when building https://github.com/AndreaOrru/zen
2018-11-24fix @intCast not catching negative numbers to unsignedAndrew Kelley
2018-11-19Crash fixes and small improvements to inline asm. (#1756)Sahnvour
* codegen: LLVMConstInlineAsm is deprecated. * codegen: replace commas in asm constraint strings by pipes as required by LLVM. * ir: enforce usage of '=' constraint modifier for inline assembly outputs. Others are not currently supported and this was just asserted alter in `ir_render_asm`. * asm: forbid comptime_int/floats as inputs in favor of explicitely sized constants. Fixes a crash due to comptime_int/floats having no type_ref. * asm: handle inputs with integers of <8 or non power of 2 bitsize. We widen them to the next highest power of two.
2018-11-16Fixed #1663 and removed IrInstructionArrayLenJimmi Holst Christensen
2018-11-13New Zig formal grammar (#1685)Jimmi Holst Christensen
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-06limit integer types to maximum bit width of 65535Andrew Kelley
closes #1541
2018-10-26remove @minValue,@maxValue; add std.math.minInt,maxIntAndrew Kelley
closes #1466 closes #1476
2018-10-15Solve the return type ambiguity (#1628)Jimmi Holst Christensen
Changed container and initializer syntax * <container> { ... } -> <container> . { ... } * <exrp> { ... } -> <expr> . { ...}
2018-10-09more efficient builtin library code generationAndrew Kelley
* introduce --disable-pic option which can generally be allowed to be the default. compiler_rt.a and builtin.a get this option when you build a static executable. * compiler_rt and builtin libraries are not built for build-lib --static * posix_spawn instead of fork/execv * disable the error limit on LLD. Fixes the blank lines printed
2018-10-09support building static librariesAndrew Kelley
closes #1493 closes #54
2018-10-04refactor ir.cppAndrew Kelley
Analysis functions no longer return `ZigType *`. Instead they return `IrInstruction *`.
2018-09-30Fixes --emit asm on windows and makes C header file generation explicit. (#1612)Sahnvour
* build: only do codegen_link when emitting an actual binary. Fixes #1371 * build: only output C header file when explicitely asked to