aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
AgeCommit message (Collapse)Author
2019-11-08introduce `@as` builtin for type coercionAndrew Kelley
This commit also hooks up type coercion (previously called implicit casting) into the result location mechanism, and additionally hooks up variable declarations, maintaining the property that: var a: T = b; is semantically equivalent to: var a = @as(T, b); See #1757
2019-11-07correctly use llvm undef in release modesShawn Landden
2019-11-07Fix ptrCast of array references to fnLemonBoy
Closes #3607
2019-11-05implement storing vector elements via runtime indexAndrew Kelley
2019-11-05implement loading vector elements via runtime indexAndrew Kelley
2019-11-05implement store of vector element with comptime indexAndrew Kelley
2019-11-05runtime load vector element with comptime indexAndrew Kelley
2019-10-28detect async fn recursion and emit compile errorAndrew Kelley
2019-10-28synchronize the target features for compiling C codeAndrew Kelley
d91fc0fdd8f42dc8c38347e1a0ec87fd583c1d3d changed zig's behavior to disable the SSE feature when cross compiling for i386-freestanding. This commit does the same when compiling C Code.
2019-10-26Don't use SSE on freestandingNoam Preil
2019-10-26Don't save/restore stack on newStackCall to noreturn functionNoam Preil
2019-10-26Translate-c: Fix a segfault when to many errors are emittedTimon Kruiper
This was already fixed when doing `@cImport`, but not yet when running `zig translate-c`.
2019-10-25stage1: fix compile error on macOS Xcode 11.2Michael Dusan
src/codegen.cpp:7713:33: error: unused variable 'global_linkage_values' [-Werror,-Wunused-const-variable] static const GlobalLinkageValue global_linkage_values[] = {
2019-10-24avoid passing -march=native when not supportedAndrew Kelley
Clang does not support -march=native for all targets. Arguably it should always work, but in reality it gives: error: the clang compiler does not support '-march=native' If we move CPU detection logic into Zig itelf, we will not need this, instead we will always pass target features and CPU configuration explicitly. For now, we simply avoid passing the flag when it is known to not be supported.
2019-10-24implement partial C ABI support for aarch64Andrew Kelley
2019-10-23move types from builtin to stdAndrew Kelley
* All the data types from `@import("builtin")` are moved to `@import("std").builtin`. The target-related types are moved to `std.Target`. This allows the data types to have methods, such as `std.Target.current.isDarwin()`. * `std.os.windows.subsystem` is moved to `std.Target.current.subsystem`. * Remove the concept of the panic package from the compiler implementation. Instead, `std.builtin.panic` is always the panic function. It checks for `@hasDecl(@import("root"), "panic")`, or else provides a default implementation. This is an important step for multibuilds (#3028). Without this change, the types inside the builtin namespace look like different types, when trying to merge builds with different target settings. With this change, Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one compilation and `std.builtin.Os` from another compilation are the same type, even if the target OS value differs.
2019-10-22implement safety for resuming non-suspended functionAndrew Kelley
closes #3469
2019-10-22integrate stage1 progress display with semantic analysisAndrew Kelley
2019-10-19Fix crash when generating constant unions with single fieldLemonBoy
2019-10-17improve progress reportingAndrew Kelley
* use erase rest of line escape code. * use `stderr.supportsAnsiEscapeCodes` rather than `isTty`. * respect `--color off` * avoid unnecessary recursion * add `Progress.log` * disable the progress std lib test since it's noisy and uses `time.sleep()`. * enable/integrate progress printing with the default test runner
2019-10-17rework the progress module and integrate with stage1Andrew Kelley
2019-10-15fix non-byte-aligned packed struct field...Andrew Kelley
...passed as generic fn parameter causing invalid LLVM IR. closes #3460
2019-10-11merge dumps tool: merging ast nodesAndrew Kelley
-fgenerate-docs is replaced ith -femit-docs -fno-emit-bin is added to prevent outputting binary
2019-10-10codegen.cpp: remove unused variableAndrew Kelley
2019-10-09Remove x86/Windows name mangling hackLemonBoy
Let's fix this properly by generating the correct lib files from the mingw sources.
2019-10-09add comments about why we choose pentium4 for i386 targetAndrew Kelley
See #3389
2019-10-09improve names of error sets when using merge error sets operatorAndrew Kelley
2019-10-09Merge pull request #3389 from LemonBoy/win32Andrew Kelley
Win32
2019-10-06generated docs: docs/ instead of doc/Andrew Kelley
This appears to be more of a standard directory name. See #21
2019-10-06Initial support for i386-windows-msvc targetLemonBoy
2019-10-04proof of concept of stage1 doc generationAndrew Kelley
This commit adds `-fgenerate-docs` CLI option, and it outputs: * doc/index.html * doc/data.js * doc/main.js In this strategy, we have 1 static html page and 1 static javascript file, which loads the semantic analysis dump directly and renders it using dom manipulation. Currently, all it does is list the declarations. But there is a lot more data available to work with. The next step would be making the declarations hyperlinks, and handling page navigation. Another strategy would be to generate a static site with no javascript, based on the semantic analysis dump that zig now provides. I invite the Zig community to take on such a project. However this version which heavily relies on javascript will also be a direction explored. I also welcome contributors to improve the html, css, and javascript of what this commit started, as well as whatever improvements are necessary to the static analysis dumping code to provide more information. See #21.
2019-10-03fix noreturn attribute for msvcAndrew Kelley
2019-10-03add -fdump-analysis to dump type information to jsonAndrew Kelley
This commit adds -fdump-analysis which creates a `$NAME-analysis.json` file with all of the finished semantic analysis that the stage1 compiler produced. It contains types, packages, declarations, and files. This is an initial implementation; some data will be missing. However it's easy to improve the implementation, which is in `src/dump_analysis.cpp`. The next step for #21 will be to create Zig code which parses this json file and creates user-facing HTML documentation. This feature has other uses, however; for example, it could be used for IDE integration features until the self-hosted compiler is available.
2019-10-01fix tripping LLVM assertion in const unionsAndrew Kelley
2019-09-29detect the shared windows include dir as wellAndrew Kelley
2019-09-29detect the windows um include directoryAndrew Kelley
2019-09-25remove --override-std-dir. fix issues caused by moving std libAndrew Kelley
2019-09-24better default enabled features for riscvAndrew Kelley
Until ability to specify target CPU features (#2883) is done, this commit gives riscv target better default features. This side-steps #3275 which is a deficiency in compiler-rt when features do not include 32 bit integer division. With this commit, RISC-V compiler-rt tests pass and Hello World works both pure-zig and with musl libc.
2019-09-24Create user-specified `output-dir`Jay Weisskopf
Fixes #2637
2019-09-21Merge pull request #3278 from LemonBoy/struct-genAndrew Kelley
A few steps towards AArch64 & ARM passing the behavior tests
2019-09-21Correct stack alignment for new stackLemonBoy
2019-09-21Fix generation of tail fields for packed structLemonBoy
2019-09-20avoid setting `tail` for `@panic`Andrew Kelley
Currently, slices are passed via reference, even though it would be better to pass the ptr and len as separate arguments (#561). This means that any function call with a slice parameter cannot be a tail call, because according to LLVM spec: > Both [tail,musttail] markers imply that the callee does not access > allocas from the caller There was one other place we were setting `tail` and I made that conditional on whether or not the argument referenced allocas in the caller. This was causing undefined behavior in the compiler when it hit asserts, causing it to print garbage memory to the terminal. See #3262 for example.
2019-09-19Merge remote-tracking branch 'origin/master' into llvm9Andrew Kelley
2019-09-19src: use zig_panic rather than having LLVM abortdaurnimator
2019-09-19fixups for `@splat`Andrew Kelley
* Fix codegen for splat - instead of giving vectors of length N to shufflevector for both of the operands, it gives vectors of length 1. The mask vector is the only one that needs N elements. * Separate Splat into SplatSrc and SplatGen; the `len` is not needed once it gets to codegen since it is redundant with the result type. * Refactor compile error for wrong vector element type so that the compile error message is not duplicated in zig source code * Improve implementation to correctly handle comptime values such as undefined and lazy values. * Improve compile error for bad vector element type to point to the correct place. * Delete dead code. * Modify behavior test to use an array cast instead of vector element indexing since I'm merging this splat commit out-of-order from Shawn's patch set.
2019-09-19`@splat`Shawn Landden
2019-09-19implement runtime `@byteSwap` and other fixupsAndrew Kelley
* update docs for `@byteSwap`. * fix hash & eql functions for ZigLLVMFnIdBswap not updated to include vector len. this was causing incorrect bswap function being called in unrelated code * fix `@byteSwap` behavior tests only testing comptime and not runtime operations * implement runtime `@byteSwap` * fix incorrect logic in ir_render_vector_to_array and ir_render_array_to_vector with regards to whether or not to bitcast * `@byteSwap` accepts an array operand which it will cast to vector * simplify `@byteSwap` semantic analysis code and various fixes
2019-09-18@byteSwap on vectorsShawn Landden
2019-09-18rework the implementationAndrew Kelley
* update documentation - move `@shuffle` to be sorted alphabetically - remove mention of LLVM - minor clarifications & rewording * introduce ir_resolve_vector_elem_type to avoid duplicate compile error message and duplicate vector element checking logic * rework ir_analyze_shuffle_vector to solve various issues * improve `@shuffle` to allow implicit cast of arrays * the shuffle tests weren't being run