aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
AgeCommit message (Collapse)Author
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
2019-09-18stage1: add @shuffle() shufflevector supportShawn Landden
I change the semantics of the mask operand, to make it a little more flexible. There is no real danger in this because it is a compile-error if you do it the LLVM way (and there is an appropiate error to tell you this). v2: avoid problems with double-free
2019-09-18adjust codegen of casting between arrays and vectorsAndrew Kelley
* bitcasting is still better when the size_in_bits aligns with the ABI size of the element type. Logic is reworked to do bitcasting when possible * rather than using insertelement/extractelement to work with arrays, store/load elements directly. This matches codegen for arrays elsewhere.
2019-09-18Fix array->vector and vector->array for many types. Allow vector of bool.Shawn Landden
Vectors do not have the same packing as arrays, and just bitcasting is not the correct way to convert them.
2019-09-15Merge remote-tracking branch 'origin/master' into llvm9Andrew Kelley
2019-09-13no-stack-arg-probe only for UEFIAndrew Kelley
2019-09-13fix regression from incorrect conflict resolution in prev commitAndrew Kelley
thanks for catching this LemonBoy
2019-09-13Merge branch 'uefi' of https://github.com/nrdmn/zig into nrdmn-uefiAndrew Kelley
2019-09-12improvements targeted at improving async functionsAndrew Kelley
* Reuse bytes of async function frames when non-async functions make `noasync` calls. This prevents explosive stack growth. * Zig now passes a stack size argument to the linker when linking ELF binaries. Linux ignores this value, but it is available as a program header called GNU_STACK. I prototyped some code that memory maps extra space to the stack using this program header, but there was still a problem when accessing stack memory very far down. Stack probing is needed or not working or something. I also prototyped using `@newStackCall` to call main and that does work around the issue but it also brings its own issues. That code is commented out for now in std/special/start.zig. I'm on a plane with no Internet, but I plan to consult with the musl community for advice when I get a chance. * Added `noasync` to a bunch of function calls in std.debug. It's very messy but it's a workaround that makes stack traces functional with evented I/O enabled. Eventually these will be cleaned up as the root bugs are found and fixed. Programs built in blocking mode are unaffected. * Lowered the default stack size of std.io.InStream (for the async version) to 1 MiB instead of 4. Until we figure out how to get choosing a stack size working (see 2nd bullet point above), 4 MiB tends to cause segfaults due to stack size running out, or usage of stack memory too far apart, or something like that. * Default thread stack size is bumped from 8 MiB to 16 to match the size we give for the main thread. It's planned to eventually remove this hard coded value and have Zig able to determine this value during semantic analysis, with call graph analysis and function pointer annotations and extern function annotations.
2019-09-10async function calls re-use frame buffersAndrew Kelley
See #3069
2019-09-10Merge remote-tracking branch 'origin/master' into llvm9Andrew Kelley
2019-09-09fix bad LLVM IR when for target expr needs to be spilledAndrew Kelley
Also reduce the size of ZigVar in memory by making the name a `const char *` rather than a `Buf`.
2019-09-09implement spilling when returning error union async function callAndrew Kelley
closes #3190
2019-09-09release builds of stage1 have llvm ir verificationAndrew Kelley
the stage2 zig code however gets compiled in release mode, and stripped.
2019-09-08move logic for propagating framework dirs to zig ccAndrew Kelley
2019-09-07implement spills when expressions used across suspend pointsAndrew Kelley
closes #3077
2019-09-07fix await used in an expression generating bad LLVMAndrew Kelley
2019-09-06runtime safety for noasync function callsAndrew Kelley
See #3157
2019-09-05implement `noasync` function callsAndrew Kelley
See #3157
2019-09-05Resolve lazy values when checking for definednessLemonBoy
Fixes #3154
2019-09-04fixups and add documentation for `@Type`Andrew Kelley
2019-09-03Add @Type builtinJonathan Marler
2019-09-03emit a compile error if a test becomes asyncAndrew Kelley
See #3117
2019-09-03fix compiler crash in struct field pointersAndrew Kelley
when the llvm type has not been fully analyzed. This is a regression from lazy values.
2019-09-03fix stack traces on macos when passing absolute path to root source fileAndrew Kelley
The comment added by this commit is copied here: For macOS stack traces, we want to avoid having to parse the compilation unit debug info. As long as each debug info file has a path independent of the compilation unit directory (DW_AT_comp_dir), then we never have to look at the compilation unit debug info. If we provide an absolute path to LLVM here for the compilation unit debug info, LLVM will emit DWARF info that depends on DW_AT_comp_dir. To avoid this, we pass "." for the compilation unit directory. This forces each debug file to have a directory rather than be relative to DW_AT_comp_dir. According to DWARF 5, debug files will no longer reference DW_AT_comp_dir, for the purpose of being able to support the common practice of stripping all but the line number sections from an executable. closes #2700