Commit Graph

15774 Commits

Author SHA1 Message Date
joachimschmidt557
96e715d5a3
stage2 AArch64: add new load/store from/to stack MIR instructions 2021-11-12 22:23:31 +01:00
joachimschmidt557
8ab90a0b32
stage2 AArch64: split Instruction.ldr into ldr and ldrLiteral 2021-11-12 22:23:29 +01:00
Jakub Konka
71388b980b macho,snapshots: fix how relocs are split
Fixes how relocs are split for symbols contained within the atoms
that represent entire sections extracted from relocatable object
files.
2021-11-11 21:36:40 -08:00
Jacob G-W
08d6876d20 c codegen: fix airIsNull with pointers 2021-11-11 11:36:26 -08:00
Jakub Konka
19e5663869
Merge pull request #9935 from g-w1/plan9-std
add plan9 support to std
2021-11-11 10:45:00 -08:00
Jakub Konka
53523ef5d0
Merge pull request #10129 from joachimschmidt557/stage2-aarch64
stage2 AArch64: Implement conditional branches
2021-11-10 22:19:22 -08:00
Jacob G-W
f3ba72cf5a x86_64/Emit: don't misisel push/pop for extended regs 2021-11-10 21:56:03 -08:00
joachimschmidt557
4168b01e7a
stage2 AArch64: implement airCondBr 2021-11-10 20:05:35 +01:00
joachimschmidt557
a5a012e859
stage2 AArch64: implement genSetReg for condition flags 2021-11-10 19:48:16 +01:00
joachimschmidt557
8cb00519cd
stage2 AArch64: implement airCmp 2021-11-10 19:48:16 +01:00
Andrew Kelley
e5bc092408
Merge pull request #10058 from marler8997/builderPathJoin
add pathJoin to builder
2021-11-10 12:40:15 -05:00
Thomas Ives
51efd553ae C backend: Improve lowering of Zig types to C types
1. Changed Zig pointers to functions to be typedef'd so then we can
   treat them the same as other types.

2. Distinguished between const slices (zig_L prefix) and mut slices
   (zig_M prefix).

3. Changed lowering of Zig "const pointers" (e.g. *const u8) to to C
   "pointers to const" (e.g. const char *) rather than C "const
   pointers" (e.g.  char * const)

4. Ensured that all typedefs are "linked" even if the decl doesn't
   require any forward declarations

5. Added test that exercises function pointer type rendering

6. Changed .slice_ptr instruction to allocate pointer local rather than
   a uintptr_t local
2021-11-10 12:39:47 -05:00
Jakub Konka
91c3206b45 macho: use start.zig for macOS entrypoint
This effectively allows us to compile

```zig
pub fn main() void {}
```

which then calls into `std.start`.

Changes required to make this happen:
* handle signed int to immediate in x86_64 and aarch64 codegen
* ensure that on arm64 macOS, `.x19` is a caller-preserved register -
  I'm not sure about that one at all and would like to brainstorm it
  with anyone interested and especially Joachim.
* finally, fix a bug in the linker - mark new got entry as dirty upon
  atom growth.
2021-11-10 11:33:24 -05:00
Andrew Kelley
b521510cd4
Merge pull request #9853 from koachan/sparc64-unittests
SPARCv9: make more tests pass
2021-11-10 11:32:10 -05:00
Andrew Kelley
e89e3735f3 wasm: respect stack_size_override for build-obj and build-lib
Related: #8633
2021-11-10 09:20:35 -07:00
Andrew Kelley
cb785b9c6b Sema: implement coerce_result_ptr for optionals
New AIR instruction: `optional_payload_ptr_set`
It's like `optional_payload_ptr` except it sets the non-null bit.

When storing to the payload via a result location that is an optional,
`optional_payload_ptr_set` is now emitted. There is a new algorithm in
`zirCoerceResultPtr` which stores a dummy value through the result
pointer into a temporary block, and then pops off the AIR instructions
from the temporary block in order to determine how to transform the
result location pointer in case any in-between coercions need to happen.

Fixes a couple of behavior tests regarding optionals.
2021-11-09 23:01:35 -07:00
Andrew Kelley
008b0ec5e5 std.Thread.Mutex: change API to lock() and unlock()
This is a breaking change. Before, usage looked like this:

```zig
const held = mutex.acquire();
defer held.release();
```

Now it looks like this:

```zig
mutex.lock();
defer mutex.unlock();
```

The `Held` type was an idea to make mutexes slightly safer by making it
more difficult to forget to release an aquired lock. However, this
ultimately caused more problems than it solved, when any data structures
needed to store a held mutex. Simplify everything by reducing the API
down to the primitives: lock() and unlock().

Closes #8051
Closes #8246
Closes #10105
2021-11-09 18:31:03 -07:00
Andrew Kelley
65e518e8e8 io_uring: skip statx test failure on older kernels 2021-11-09 18:31:03 -07:00
Zen1th
6869bc9ff8
stage2: Add support for floats in the C backend (#10059)
* Implement float type
* Fix int and float undefined value
* Handle NaN constants, preserving bit pattern
2021-11-09 18:56:01 -05:00
Zen1th
0d7359ca9b
stage2: Implement Sema.floatToInt (#10097) 2021-11-09 18:52:30 -05:00
Andrew Kelley
c77698d69e remove 2 duplicated behavior tests from struct_llvm.zig 2021-11-09 16:32:39 -07:00
Andrew Kelley
7afa220f92
Merge pull request #10102 from rainbowbismuth/c-while-tests
C backend: while, struct tests, better undefined global handling
2021-11-09 18:24:38 -05:00
Andrew Kelley
c715d512cb CI: additionally run stage2 behavior tests with -ofmt=c 2021-11-09 16:12:57 -07:00
Žiga Željko
b24e475717 stage1: fix type mapping for integers and c_longdouble on nvptx 2021-11-09 16:43:03 -05:00
Andrew Kelley
d2cdfb9490 stage2: add 4 new linker flags for WebAssembly
--import-memory          import memory from the environment
--initial-memory=[bytes] initial size of the linear memory
--max-memory=[bytes]     maximum size of the linear memory
--global-base=[addr]     where to start to place global data

See #8633
2021-11-09 14:29:20 -07:00
Jonathan Marler
c13166ee85 Omit array type for pathJoin calls 2021-11-09 14:20:28 -07:00
Jonathan Marler
cebac8c662 add pathJoin to builder 2021-11-09 14:20:28 -07:00
Silver
9bb7ff68cc std: Publicize Allocator.reallocBytes
This is useful when dealing with runtime-known alignments, eg. interfacing
with C code that accepts custom allocation callbacks.

Closes #9394
2021-11-09 13:41:38 -05:00
Martin Hafskjold Thoresen
e04ab39036 Cmake: Specify LLVM versions
Systems with multiple LLVM toolchains installed (e.g. one globally and one
in $HOME/local) would get confused and fail to compile.  Being explicit
about the version required will force CMake to find the right version of LLVM.
2021-11-09 13:39:32 -05:00
Gregory Anders
3534f8a3ed std: ppoll: cast number of fds to nfds_t
On some systems, the type of the length of a slice is different from the
nfds_t type, so cast the slice length to nfds_t. This is already done in
poll, so just copy that implementation for ppoll.
2021-11-09 13:36:36 -05:00
Vincent Rischmann
082072bd4f os/linux/io_uring: implement statx 2021-11-09 13:35:17 -05:00
Jacob G-W
bfb88b2d0d plan9: add test for std 2021-11-09 07:08:27 -05:00
Jacob G-W
73be14027d plan9: more syscalls 2021-11-09 07:08:27 -05:00
Jacob G-W
fe314e60bb fix outputs in inline assembly 2021-11-09 07:08:27 -05:00
Jacob G-W
09992f8acc add initial plan9 support to std 2021-11-09 07:08:23 -05:00
Andrew Kelley
4d75382452 tools/gen_stubs.zig: better error message on invalid input 2021-11-08 15:31:14 -07:00
Emily Bellows
684d9532c5 C backend: restore handling of .NoReturn in function signature 2021-11-08 14:23:55 -05:00
Emily Bellows
e3d638a49e C backend: while, struct tests, better undefined global handling
1. Function signatures that return a no member struct return void
2. Undefined var decls don't get a value generated for them
3. Don't generate bitcast code if the result isn't used, since
   bitcast is a pure function. Right now struct handling code
   generates some weird unused bitcast AIR, and this optimization
   side steps that issue.
2021-11-08 14:23:55 -05:00
Michael Dusan
a7d215759e ci: fully activate ci.ziglang.org linux
- disable azure/linux
- split probe/build/test steps for log clarity
- add package step; enabled only when master/pull
- add on-master-success pipeline; enabled only when master/pull
2021-11-08 13:45:03 -05:00
Jakub Konka
3c7310f8cc stage2 x86_64: add MIR->Isel lowering step for x86_64
* incorporate Andrew's MIR draft as Mir.zig
* add skeleton for Emit.zig module - Emit will lower MIR into
  machine code or textual ASM.
* implement push
* implement ret
* implement mov r/m, r
* implement sub r/m imm and sub r/m, r
* put encoding common ops together - some ops share impl such as
  MOV and cmp so put them together and vary the actual opcode
  with modRM ext only.
* implement pop
* implement movabs - movabs being a special-case of mov not
  handled by general mov MIR instruction due to requirement to
  handle 64bit immediates.
* store imm64 as a struct `Imm64{ msb: u32, lsb: u32 }` in extra data
  for use with for instance movabs inst
* implement more mov variations
* implement adc
* implement add
* implement sub
* implement xor
* implement and
* implement or
* implement sbb
* implement cmp
* implement lea - lea doesn't follow the scheme as other inst above. Similarly, I
  think bit shifts and rotates should be put in a separate basket too.
* implement adc_scale_src
* implement add_scale_src
* implement sub_scale_src
* implement xor_scale_src
* implement and_scale_src
* implement or_scale_src
* implement sbb_scale_src
* implement cmp_scale_src
* implement adc_scale_dst
* implement add_scale_dst
* implement sub_scale_dst
* implement xor_scale_dst
* implement and_scale_dst
* implement or_scale_dst
* implement sbb_scale_dst
* implement cmp_scale_dst
* implement mov_scale_src
* implement mov_scale_dst
* implement adc_scale_imm
* implement add_scale_imm
* implement sub_scale_imm
* implement xor_scale_imm
* implement and_scale_imm
* implement or_scale_imm
* implement sbb_scale_imm
* implement cmp_scale_imm
* port bin math to MIR
* backpatch stack size into prev MIR inst
* implement Function.gen() (minus dbg info)
* implement jmp/call [imm] - we can now call functions using indirect absolute
  addressing, or via registers.
* port airRet to use MIR
* port airLoop to use MIR
* patch up performReloc to use inst indices
* implement conditional jumps (without relocs)
* implement set byte on condition
* implement basic lea r64, [rip + imm]
* implement calling externs
* implement callq in PIE
* implement lea RIP in PIE context
* remove all refs to Encoder from CodeGen
* implement basic imul ops
* pass all Linux tests!
* enable most of dbg info gen
* generate arg dbg info in Emit
2021-11-08 13:27:49 -05:00
Andrew Kelley
4acd8920d8 ci: don't print env because there will be secrets there 2021-11-08 11:27:02 -07:00
Frank Denis
bd8b94bd0e crypto/edwards25519: correctly flip the Y sign in the H2C operation
No security implications, but the current hash-to-curve standard
defines the sign of the Y coordinate to be negative if `gx1`
is a square, positive otherwise.

We were doing it the other way round.
2021-11-08 14:55:27 +01:00
joachimschmidt557
6b5e403e5d stage2 ARM: move codegen to separate file
This also removes i386 codegen code, which was unused and untested
2021-11-07 21:20:58 +01:00
joachimschmidt557
0fb26b0369 stage2 RISCV64: introduce MIR 2021-11-05 15:30:28 -04:00
LemonBoy
2551946a51 std: Fix path resolution on Windows
GetCurrentDirectory returns a path with a trailing slash iff the cwd is
a root directory, making the code in `resolveWindows` return an invalid
path with two consecutive slashes.

Closes #10093
2021-11-04 21:05:14 -04:00
Ryan Liptak
e97feb96e4 Replace ArrayList.init/ensureTotalCapacity pairs with initCapacity
Because ArrayList.initCapacity uses 'precise' capacity allocation, this should save memory on average, and definitely will save memory in cases where ArrayList is used where a regular allocated slice could have also be used.
2021-11-04 14:54:25 -04:00
LemonBoy
d03e9d0b83 compiler-rt: Fix f16 API declarations to be consistent
LLVM and compiler-rt must agree on how the parameters are passed, it
turns out that in LLVM13 something changed and broke the test case for
AArch64 systems.

It has nothing to do with fma at all.

Closes #9900
2021-11-04 14:30:35 -04:00
Daniele Cocca
77ffffc7cc
Add more entries to the list of stage1+stage2+CBE passing tests (#10094)
* CBE: mark call.zig tests as passing

* CBE: mark enum.zig tests as passing

* CBE: mark defer.zig tests as passing

* CBE: mark hasdecl.zig tests as passing

* CBE: mark hasfield.zig tests as passing

* CBE: mark ptrcast.zig tests as passing

* CBE: mark bitcast.zig tests as passing

* CBE: mark pub_enum.zig tests as passing

* CBE: mark underscore.zig tests as passing

* CBE: mark usingnamespace.zig tests as passing

* CBE: mark bugs/655.zig tests as passing

* CBE: mark bugs/679.zig tests as passing

* CBE: mark bugs/704.zig tests as passing

* CBE: mark bugs/1486.zig tests as passing

* CBE: mark bugs/2346.zig tests as passing

* CBE: mark bugs/2889.zig tests as passing

* CBE: mark bugs/4560.zig tests as passing

* CBE: mark bugs/4769_a.zig tests as passing

* CBE: mark bugs/4769_b.zig tests as passing

* CBE: mark bugs/6850.zig tests as passing
2021-11-04 14:24:46 -04:00
Andrew Kelley
a55dc4a3bc
Merge pull request #10079 from mattbork/astgen-temp-allocs
stage2: Reduce temporary allocations in AstGen
2021-11-03 18:30:08 -04:00
Andrew Kelley
08dc840247
Merge pull request #10088 from ziglang/std-os-perf
std: add Linux perf syscall bits
2021-11-02 14:52:54 -04:00