18758 Commits

Author SHA1 Message Date
Veikka Tuominen
2b93546b39 Sema: fix initialization of array with comptime only elem type 2022-06-03 20:21:20 +03:00
Veikka Tuominen
4e1aa5d543 Sema: handle the_only_possible_value in beginComptimePtrMutation 2022-06-03 15:25:53 +03:00
Veikka Tuominen
019537cb2a Sema: @sizeOf function should give an error 2022-06-03 15:24:58 +03:00
Veikka Tuominen
8f45e81c84 stage2: ignore asm inputs named _
This is a hacky solution but the entire asm syntax is supposed to be
reworked anyways.
2022-06-03 15:10:37 +03:00
Veikka Tuominen
5c65b086d6 Value: implement {read,write}Value for more types 2022-06-03 14:29:24 +03:00
Veikka Tuominen
3db4513b33 Sema: fix type of alloc 2022-06-03 14:28:56 +03:00
Veikka Tuominen
1258b5f7d6 Type: implement elemType2 for anyframe 2022-06-03 14:28:10 +03:00
Veikka Tuominen
9aae4d57cb compiler_rt: fix infinite loop 2022-06-03 14:27:45 +03:00
joachimschmidt557
4fdacca512
stage2 ARM: rework cmp in preparation for switch 2022-06-02 20:19:18 +02:00
Jakub Konka
e498fb1550 tapi: sync with upstream
gitrev kubkon/zig-yaml 8cf8dc3bb901fac8189f441392fc0989ad14cf71

Calculate line and col info indexed by token index. We can then
re-use this info to track current column number (aka indentation
level) of each "key:value" pair (map) or "- element" (list).
This significantly cleans up the code, and leads naturally to
handling of unindented lists in tbd files.
2022-06-02 10:41:13 +02:00
Andrew Kelley
288e89b606 Sema: fix compiler crash with comptime arithmetic involving @ptrToInt 2022-06-01 16:45:28 -07:00
Andrew Kelley
a4cdb49a58
Merge pull request #11763 from Vexu/stage2-alloc-const
Stage2: detect when initializer of const variable is comptime known
2022-06-01 18:59:13 -04:00
Andrew Kelley
b82cccc9e9 Sema: fix alignment of element ptr result type 2022-06-01 15:43:21 -07:00
Andrew Kelley
b095aa6986 CI: skip single-threaded tests on Drone
sure would be nice if they would just give us another hour of CI run time.
2022-06-01 14:05:58 -07:00
Andrew Kelley
de14fba247 LLVM: convert two ArrayLists into a MultiArrayList 2022-06-01 11:53:47 -07:00
Andrew Kelley
69323fc143 CI: skip non native ReleaseFast and ReleaseSafe tests on drone
Because we're hitting the 2 hour time limit.
2022-06-01 11:19:19 -07:00
Veikka Tuominen
94624893d8 disable failing test 2022-06-01 13:06:31 +03:00
Veikka Tuominen
9431100736 Sema: apply previous changes to validateUnionInit 2022-06-01 13:01:39 +03:00
Andrew Kelley
cbb806da6e stage2: -fbuild-id causes default linker to be LLD
until zig's self-hosted linker gains this functionality.
2022-05-31 22:56:39 -07:00
Andrew Kelley
8c0f4e6f54 LLVM: add target-cpu and target-features fn attributes 2022-05-31 22:13:24 -07:00
Andrew Kelley
2f9533f639 LLVM: pass slices as ptr/len combo
LLVM optimization passes handle this better, and it allows Zig to
specify pointer parameter attributes such as readonly, nonnull, noalias,
and alignment.

closes #561
2022-05-31 18:25:57 -07:00
Andrew Kelley
356a865b87 stage2: introduce support for noalias
Not implemented yet is enhancements to coerceInMemory to account for
noalias parameters.

Related to #11498.
2022-05-31 17:38:42 -07:00
Andrew Kelley
602af1b88f
Merge pull request #11765 from ziglang/llvm-param-attrs
LLVM: add readonly, nonnull, align attributes to pointer params
2022-05-31 20:25:13 -04:00
Veikka Tuominen
3c4e7abfbf Sema: handle dbg_smtts when deleting runtime instructions in validateStructInit 2022-06-01 02:18:45 +03:00
Veikka Tuominen
a73895339a Sema: handle bitcasts produced by coerce_result_ptr in validate{Array,Struct}Init 2022-06-01 02:10:18 +03:00
Andrew Kelley
ec919c3c9b LLVM: integrate param attrs with iterateParamTypes
This moves some logic from resolveLlvmFunction to updateFunc and takes
advantage of the iteration we already do that takes into account C ABI
lowering, making LLVM parameter attributes accurate for C ABI functions
as well as our own unspecified calling convention.

Related to #11498.
2022-05-31 15:32:15 -07:00
Veikka Tuominen
f2626a3d8e Sema: validate{Array,Struct}Init shortcut only valid if base ptr is comptime known 2022-06-01 01:24:11 +03:00
Veikka Tuominen
e49fd39463 Sema: detect comptime values in zirMakePtrConst 2022-06-01 01:23:52 +03:00
Andrew Kelley
43311e19f4 LLVM: add readonly, nonnull, align attributes to pointer params 2022-05-31 15:16:38 -07:00
Andrew Kelley
6d691d3540 build: include a build-id note only if explicitly requested 2022-05-31 13:51:59 -07:00
Andrew Kelley
59219e7e91 stage2: add support for -fbuild-id,-fno-build-id
closes #3047
2022-05-31 13:36:33 -07:00
Andrew Kelley
d09d61be97
Merge pull request #11762 from Vexu/stage2
Stage2 fixes
2022-05-31 15:19:25 -04:00
Andrew Kelley
282437c753 stage2: fix hash/eql on function types
to account for generic callconv and generic alignment.
2022-05-31 12:17:48 -07:00
Andrew Kelley
d410693dad LLVM: elide some loads when lowering
Generally, the load instruction may need to make a copy of an
isByRef=true value, such as in the case of the following code:

```zig
pub fn swap(comptime T: type, a: *T, b: *T) void {
    const tmp = a.*;
    a.* = b.*;
    b.* = tmp;
}
```

However, it only needs to do so if there are any instructions which can
possibly write to memory. When calling functions with isByRef=true
parameters, the AIR code that is generated looks like loads followed
directly by call.

This allows for a peephole optimization when lowering loads: if the load
instruction operates on an isByRef=true type and dies before any side effects
occur, then we can safely lower the load as a no-op that returns its
operand.

This is one out of three changes I intend to make to address #11498.
However I will put these changes in separate branches and merge them
separately so that we can have three independent points on the perf
charts.
2022-05-31 14:17:54 -04:00
Frank Denis
26aea8cfa1
crypto: add support for the NIST P-384 curve (#11735)
After P-256, here comes P-384, also known as secp384r1.

Like P-256, it is required for TLS, and is the current NIST recommendation for key exchange and signatures, for better or for worse.

Like P-256, all the finite field arithmetic has been computed and verified to be correct by fiat-crypto.
2022-05-31 17:29:38 +02:00
Veikka Tuominen
56608cbb3d Sema: do not add calls to returnError for comptime known non-error values 2022-05-31 17:14:49 +03:00
Veikka Tuominen
36df79cd37 stage2: ignore generic return type when hashing function type
Generic parameter types are already ignored.
2022-05-31 16:43:58 +03:00
Veikka Tuominen
febc7d3cd6 Sema: take dbg_stmt into account in zirResolveInferredAlloc 2022-05-31 16:22:00 +03:00
Andrew Kelley
83beed09e1 LLVM: omit memset of 0xaa bytes in unsafe optimization modes
This is one out of three changes I intend to make to address #11498.
However I will put these changes in separate branches and merge them
separately so that we can have three independent points on the perf
charts.
2022-05-31 00:39:14 -07:00
Andrew Kelley
c3ef4ac15f
Merge pull request #11752 from ziglang/zir-fancy-fns
stage2: add missing data to ZIR encoding of functions
2022-05-30 21:18:10 -04:00
Andrew Kelley
c84f5a5f91
Merge pull request #11749 from Vexu/stage2
Stage2: improve AstGen for array init expressions
2022-05-30 17:35:18 -04:00
Andrew Kelley
bd89a73d52 Sema: implement functions generic across callconv() or align() 2022-05-30 14:16:28 -07:00
Andrew Kelley
7e98b047dd AstGen: simplify function return type expressions
This check for primitives is already handled by the generic logic that
checks if the body ends up being empty. I kept this commit in the git
history in case we ever want that nodePrimitive function again in the
future, it might be useful.
2022-05-30 12:03:53 -07:00
Andrew Kelley
9da3a058d8 stage2: add missing data to ZIR encoding of functions
The main purpose of this commit is to prepare to implement support for
callconv(), align(), linksection(), and addrspace() annotations on
generic functions where the provided expression depends on comptime
parameters (making the function generic).

It's a rather involved change, so this commit only makes the necessary
changes to AstGen without regressing any behavior, and a follow-up
commit can finish the task by making the enhancements to Sema.

By my quick estimation, the new encoding for functions is a negligible
improvement - along the lines of 0.005% fewer total ZIR bytes on
average. Still, it's nice that this commit, while adding more
data into ZIR, actually ends up reducing the storage size thanks to a
slightly more sophisticated encoding.

Zir.Inst.ExtendedFunc is renamed to Zir.Inst.FuncFancy to eliminate
confusion about it being an extended instruction (it used to be but is
no longer). The encoding for this instruction is completely reworked.

The encoding for Zir.Inst.Func is also changed slightly - when the
return type body length is 1, then only a Zir.Inst.Ref is provided; not
a full body.

linksection() and addrspace() are now communicated via func_fancy ZIR
instruction rather than as part of the corresponding decl. This allows
their expressions to observe comptime parameters.
2022-05-30 12:03:53 -07:00
Veikka Tuominen
f846dc420f
Merge pull request #10474 from TwoClocks/master
translate-c: fix for #10461. Check child records for opaque types
2022-05-30 16:01:05 +03:00
Veikka Tuominen
0e8307789a AstGen: add tuple aware elem_type_index 2022-05-29 13:19:03 +03:00
Veikka Tuominen
c7b778992e AstGen: improve generated Zir for array init exprs 2022-05-29 13:19:03 +03:00
Veikka Tuominen
0274e2f1fd translate-c: check variable types being demoted to opaque 2022-05-29 12:07:29 +03:00
TwoClocks
36b4658752 translate-c: check record fields for opaque demotions 2022-05-29 12:06:37 +03:00
Veikka Tuominen
ee651c3cd3 Revert "reserve correct space for bitfields"
This reverts commit 22cb6938891c73d64b749a2516c8eaf79aa25b03.
2022-05-29 12:04:50 +03:00