174 Commits

Author SHA1 Message Date
r00ster91
ceff03f3e9 std.builtin: remove layout field from Type.Enum 2022-12-18 13:31:38 +01:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
r00ster91
7350ea3e2d std.builtin: rename Type.Fn's args to params
This was a poor naming choice; these are parameters, not arguments.
Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.
2022-12-17 14:11:33 +01:00
r00ster91
20d3fd901e std.builtin: rename Type.Fn.Param's arg_type to type
It's the type of a parameter, not an argument, but the prefix is redundant either way.
2022-12-17 14:11:33 +01:00
Meghan
1704971666
std: make builtin.Type.{Int,Float}.bits a u16 instead of comptime_int 2022-12-15 23:08:51 +02:00
Ryan Liptak
88d927a511 std.debug.TTY: Fix colors not resetting on Windows
This fixes a regression introduced in #12298 where colors would never reset in a Windows console because the attributes would be queried on every `setColor` call, and then try to 'reset' the attributes to what it just queried (i.e. it was essentially doing a complicated no-op on .Reset).

This fixes the problem while (I think) keeping with the spirit of the changes in #12298--that is, `TTY.Config` is not specifically tied to stderr like it was before #12298. To that end, detectTTYConfig now takes a `File` and that's what gets used to query the initial attributes to reset to.

(for context, before #12298, the first `setColor` call is where the reset attributes would get queried and it would always use stderr to do it)
2022-12-15 03:49:26 -05:00
Veikka Tuominen
7b2a936173 remove stack option from @call 2022-12-13 12:52:21 +02:00
Veikka Tuominen
9d93b2ccf1 Eliminate BoundFn type from the language
Closes #9484
2022-12-09 20:37:18 -07:00
Andrew Kelley
50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Veikka Tuominen
e60db701d1 Sema: add option to disable formatted panics
Closes #13174
2022-11-29 21:44:08 +02:00
Veikka Tuominen
17ff002bc0 Sema: improve safety panic for access of inactive union field 2022-11-29 21:44:08 +02:00
Veikka Tuominen
6337c04244 Sema: improve panic for slice start index being greater than end index
Closes #13689
2022-11-29 15:47:02 +02:00
Andrew Kelley
972c040241
Merge pull request #13611 from Snektron/spirv-assembler
spirv: assembler
2022-11-24 17:48:39 -05:00
Jimmi Holst Christensen
258bee41bf Get panic messages from builtin instead of creating anon decls
The TODO comment in safetyPanic mentions introducing the concept of
reference-counted decls. That sounds like Zig current semantics for
normal declarations. By placing the panic messages in builtin there is
no need for another concept in the compiler.
2022-11-23 14:57:39 -05:00
Robin Voetter
074ba69ba6
spirv: assembler
spirv: introduce SpvModule.Fn to generate function code into

spirv: assembler error message setup

spirv: runtime spec info

spirv: inline assembly tokenizer

spirv: inline assembly lhs result/opcode parsing

spirv: forgot to fmt

spirv: tokenize opcodes and assigned result-ids

spirv: operand parsing setup

spirv: assembler string literals

spirv: assembler integer literals

spirv: assembler value enums

spirv: assembler bit masks

spirv: update assembler to new asm air format

spirv: target 1.5 for now

Current vulkan sdk version (1.3.204) ships spirv tools targetting 1.5,
and so these do not work with binaries targetting 1.6 yet. In the
future, this version number should be decided by the target.

spirv: store operands in flat arraylist.

Instead of having dedicated Operand variants for variadic operands,
just flatten them and store them in the normal inst.operands list.
This is a little simpler, but is not easily decodable in the operand
data representation.

spirv: parse variadic assembly operands

spirv: improve assembler result-id tokenization

spirv: begin instruction processing

spirv: only remove decl if it was actually allocated

spirv: work around weird miscompilation

Seems like there are problems with switch in anonymous struct literals.

spirv: begin resolving some types in assembler

spirv: improve instruction processing

spirv: rename some types + process OpTypeInt

spirv: process OpTypeVector

spirv: process OpTypeMatrix and OpTypeSampler

spirv: add opcode class to spec, remove @exclude'd instructions

spirv: process more type instructions

spirv: OpTypeFunction

spirv: OpTypeOpaque

spirv: parse LiteralContextDependentNumber operands

spirv: emit assembly instruction into right section

spirv: parse OpPhi parameters

spirv: inline assembly inputs

spirv: also copy air types

spirv: inline assembly outputs

spirv: spir-v address spaces

spirv: basic vector constants/types and shuffle

spirv: assembler OpTypeImage

spirv: some stuff

spirv: remove spirv address spaces for now
2022-11-23 19:17:58 +01:00
Nick Cernis
8a5818535b
Make invalidFmtError public and use in place of compileErrors for bad format strings (#13526)
* Export invalidFmtErr

To allow consistent use of "invalid format string" compile error
response for badly formatted format strings.

See https://github.com/ziglang/zig/pull/13489#issuecomment-1311759340.

* Replace format compile errors with invalidFmtErr

- Provides more consistent compile errors.
- Gives user info about the type of the badly formated value.

* Rename invalidFmtErr as invalidFmtError

For consistency. Zig seems to use “Error” more often than “Err”.

* std: add invalid format string checks to remaining custom formatters

* pass reference-trace to comp when building build file; fix checkobjectstep
2022-11-12 21:03:24 +02:00
Cody Tapscott
a4523a2d4a builtin.zig: Do not overwrite error frames when trace full
Previously, we'd overwrite the errors in a circular buffer. Now that
error return traces are intended to follow a stack discipline, we no
longer have to support the index rolling over. By treating the trace
like a saturating stack, any pop/restore code still behaves correctly
past-the-end of the trace.

As a bonus, this adds a small blurb to let the user know when the trace
saturated and x number of frames were dropped.
2022-10-21 12:40:33 -07:00
Guillaume Wenzek
24c749473a implement os.abort and panic for cuda 2022-10-15 10:39:19 -07:00
Robin Voetter
6b69dcfdd2
amdgpu: add AmdgpuKernel calling convention 2022-10-12 20:34:41 +02:00
ominitay
295451dfe5
std: Replace use of stage1 function pointers 2022-09-29 21:45:30 +03:00
zooster
12896d36cb std.builtin: un-pub testVersionParse() 2022-09-29 14:47:41 +03:00
Veikka Tuominen
694fab4848 std: add return address parameter to panic fn 2022-09-20 19:05:00 -07:00
Andrew Kelley
d3d24874c9 std: remove deprecated API for the upcoming release
See #3811
2022-09-16 14:46:53 -04:00
Andrew Kelley
507aae4a1a make self-hosted the default compiler
stage1 is available behind the -fstage1 flag.

closes #89
2022-08-19 16:45:15 -07:00
Isaac Freund
0d32b73078
stage2: Implement explicit backing integers for packed structs
Now the backing integer of a packed struct type may be explicitly
specified with e.g. `packed struct(u32) { ... }`.
2022-08-10 19:54:45 +02:00
Andrew Kelley
1a500b9699 Sema: avoid error return traces when possible
stage2 was adding bogus error return trace frames when an error was not
being returned. This commit makes several improvements:

 * Make a runtime check if necessary to only emit a frame into the error
   return trace when an actual error is returned.
 * Use the `analyzeIsNonErrComptimeOnly` machinery to avoid runtime
   checks when it is compile-time-known that the value is an error, or a
   non-error.
 * Make std.builtin.returnError take a non-optional stack trace pointer.

closes #12174
2022-08-08 19:16:21 -07:00
Veikka Tuominen
14f0b70570 Sema: add safety for sentinel slice 2022-08-02 18:34:30 +03:00
r00ster
cff5d9c805
std.mem: add first method to SplitIterator and SplitBackwardsIterator 2022-07-25 22:04:30 +03:00
Andrew Kelley
e5e9e5a7aa std.builtin.returnError: disable runtime safety 2022-07-07 18:24:34 -07:00
Veikka Tuominen
0a7f3be42e Sema: improve index out of bounds panic message 2022-05-16 17:42:51 -07:00
Veikka Tuominen
ab4ec35b8b stage2: add runtime safety for unwrapping error 2022-05-16 17:42:51 -07:00
Veikka Tuominen
eee8fffec7 stage2: implement error return traces 2022-05-16 17:42:51 -07:00
Andrew Kelley
03ed0f0d28 C backend: implement overflow arithmetic
Most of the work here was additions to zig.h. The lowering code is
mainly responsible for calling the correct function name depending on
the operand type.

Some of the compiler-rt calls here are not implemented yet and are
non-standard symbols due to the C programming language not needing them.

After this commit, the behavior tests with -ofmt=c are passing again.
2022-05-16 13:55:26 -07:00
Koakuma
fb0692334e target: Rename sparcv9 -> sparc64
Rename all references of sparcv9 to sparc64, to make Zig align more with
other projects. Also, added new function to convert glibc arch name to Zig
arch name, since it refers to the architecture as sparcv9.

This is based on the suggestion by @kubkon in PR 11847.
(https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-05-13 16:43:59 -04:00
Andrew Kelley
c4c5020f02 fixups to the previous commit
* Rename std.builtin.GlobalVisibility to std.builtin.SymbolVisibility
 * Add missing compile error. From the LLVM language reference: "A
   symbol with internal or private linkage must have default
   visibility."
2022-05-10 15:44:40 -07:00
Takeshi Yoneda
9654a54d4a Add Visibility field to ExportOptions.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-05-10 15:21:48 -07:00
Hannes Bredberg
ea3f5905f0 Add Win64 calling convention
Closes ziglang/zig#11585
2022-05-08 16:28:10 -04:00
Koakuma
1f63afa7c9 stage2: sparcv9: Register the backend in stdlib & driver 2022-04-14 22:18:06 +07:00
Andrew Kelley
6d73f89bf1 stage2: disable default panic handler when linking -lc
It's failing to compile std.os.dl_iterate_phdr correctly.
2022-03-20 00:36:44 -07:00
Veikka Tuominen
12f3c461a4 Sema: implement zirSwitchCaptureElse for error sets 2022-03-19 15:49:27 +02:00
Veikka Tuominen
c9b6f1bf90 std: enable default panic handler for stage2 LLVM on Linux 2022-03-19 14:05:57 +02:00
Jonathan Marler
d805adddd6 deprecated TypeInfo in favor of Type
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-03-08 20:38:12 +02:00
Andrew Kelley
6249a24e81 stage2: integer-backed packed structs
This implements #10113 for the self-hosted compiler only. It removes the
ability to override alignment of packed struct fields, and removes the
ability to put pointers and arrays inside packed structs.

After this commit, nearly all the behavior tests pass for the stage2 llvm
backend that involve packed structs.

I didn't implement the compile errors or compile error tests yet. I'm
waiting until we have stage2 building itself and then I want to rework
the compile error test harness with inspiration from Vexu's arocc test
harness. At that point it should be a much nicer dev experience to work
on compile errors.
2022-02-23 23:59:25 -07:00
Veikka Tuominen
f8154905e7 stage1: rename TypeInfo.FnArg to Fn.Param 2022-02-23 09:44:36 +02:00
gwenzek
628e9e6d04
enable Gpu address spaces (#10884) 2022-02-21 14:05:27 -05:00
Andrew Kelley
2c24bf2f79
Merge pull request #10604 from fifty-six/master
std/os/uefi: additional improvements/fixes
2022-02-18 14:16:30 -05:00
gwenzek
0e1afb4d98
stage2: add support for Nvptx target
sample command:

/home/guw/github/zig/stage2/bin/zig build-obj cuda_kernel.zig -target nvptx64-cuda -O ReleaseSafe
this will create a kernel.ptx

expose PtxKernel call convention from LLVM
kernels are `export fn f() callconv(.PtxKernel)`
2022-02-05 16:33:00 +02:00
Andrew Kelley
f4a249325e stage1: avoid anytype fields for type info
prerequisite for #10705
2022-02-01 18:10:19 -07:00
Andrew Kelley
3e99495ed8
Merge pull request #10742 from ziglang/ArrayHashMapEql
std: make ArrayHashMap eql function accept an additional param
2022-02-01 13:20:28 -05:00
Andrew Kelley
aa326328d0 stage1: remove the data field from TypeInfo.Declaration
Partially implements #10706
2022-01-31 22:09:41 -07:00