Commit Graph

614 Commits (adc444ceeb91c06a6ee84dc4e4874294a41dee45)

Author SHA1 Message Date
Tadeo Kondrak 350b2adacd
std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
Andrew Kelley 5929e5ca0e
Merge pull request #5196 from tadeokondrak/@vector-to-@type-vector
`@Vector` -> `@Type(.Vector)`
2020-04-28 16:25:40 -04:00
Tadeo Kondrak f977155fdb
@Vector -> std.meta.Vector 2020-04-28 00:47:13 -06:00
Tadeo Kondrak 17e41f6cd3
@OpaqueType -> @Type(.Opaque) 2020-04-28 00:02:13 -06:00
Tadeo Kondrak 45f4a1124f implement @Type() for more types 2020-04-27 14:37:18 -04:00
Timon Kruiper c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
LemonBoy e6428f9401
stage1: Fix bitcast of immediate to ptr type (#5131)
Consider a (legal according to the `@bitCast` rules) conversion from u16
to [2]u8: since the former is a scalar and the latter is a pointer
(arrays are represented at pointers in the codegen phase) we have to
allocate a temporary slot on the stack and then bitcast the resulting
pointer to the desired destination type.

Beware that this means the lifetime of the resulting value is the same
of the function it's contained in and for all intents and purposes
should be regarded as a local (eg. it should not escape).

Closes #4395
Closes #5121
2020-04-23 12:44:16 -04:00
LemonBoy b5e72c0148 stage1: Prevent the creation of illegal pointer types
Changing the pointer length from Unknown to Single/C now resets the
sentinel value too.

Closes #5134
2020-04-22 14:40:57 -04:00
elucent 48dc3b6fe9 Added peer type resolution for [*]T and *[N]T. 2020-04-21 18:09:03 -04:00
Vexu 4f02cf32b4
fix typeInfo tests 2020-04-18 11:39:52 +03:00
LemonBoy 8e96922f31 stage1: Fix several bugs in constant generation
The codegen would sometimes change the LLVM type for some constants to
an unnamed structure in order to accomodate extra padding. This is fine
as long as the alignment of each field is still respected and it was not
the case for structure types, leading to ill-formed constants being
generated.

Optional types suffer from this to a lower extent as their layout is
quite lucky, the only missing piece was the tail padding.

Closes #4530
Closes #4594
Closes #4295
Closes my will to live
2020-04-17 13:42:23 -04:00
Vexu ca3bf6e6ad
translate-c cleanup and zig fmt 2020-04-15 15:15:32 +03:00
LemonBoy ce21a784a4 stage1: More fixes for BE targets
* Fix packed struct alignment
* Adjust some tests
2020-04-13 17:35:14 -04:00
xackus 66b2477ab6 fix lazy value in ir_analyze_instruction_elem_ptr 2020-04-07 18:22:17 -04:00
Vexu 95fefcd4c9
fix broken tests 2020-04-07 16:56:48 +03:00
LemonBoy a59d31bd28 ir: Support tuple multiplication 2020-04-06 14:03:43 -04:00
Andrew Kelley e84b9b70ff
annotate disabled tests with github issue links 2020-04-05 18:34:32 -04:00
LemonBoy 0f964e1910
I'm getting tired of this shit LLVM 2020-04-05 18:34:31 -04:00
LemonBoy 91a8e3b47b
tests: Chop away some flaky tests 2020-04-05 18:34:31 -04:00
LemonBoy d2d97e55cc
ir: Support shift left/right on vectors 2020-04-05 18:34:31 -04:00
LemonBoy 2485f30046
ir: Support bitwise not on vectors 2020-04-05 18:34:31 -04:00
LemonBoy 54ffcf95a8
ir: Support div/mod/rem on vector types
Closes #4050
2020-04-05 18:34:31 -04:00
Andrew Kelley e2dc63644a
type_has_one_possible_value takes comptime struct fields into account
Before, type_has_one_possible_value would return false for the value
`.{1}`. But actually, that type is a tuple with a single comptime field.
Such a type, in fact, has one possible value.

This plus the corresponding adjustment to get_the_one_possible_value
solves #3878.
2020-04-05 17:09:01 -04:00
Michael Dusan db4c06ce60 stage1: add compile errors for sentinel slicing
closes #3963
2020-04-03 19:05:30 -04:00
Andrew Kelley 47a0e3ec5e
Merge pull request #4871 from boothby/issue4769
Address bugs when //, /// or //! are immediately followed by EOF
2020-03-31 10:56:21 -04:00
Kelly Boothby 44aadaff59 added unit tests to demonstrate #4769 and related bugs 2020-03-30 18:29:48 -07:00
Andrew Kelley 9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
Andrew Kelley b980568c81
add peer type resolution for mixed-const []T and *[N]T
closes #4766

This commit also fixes the implementation of some utility functions for
adjusting properties of pointer types. Previously these functions would
incorrectly drop vector, sentinel, and inference metadata.
2020-03-30 13:02:50 -04:00
LemonBoy c1cc1ebc35 ir: Avoid constant-folding ptr to sentinels
Constant-folding the pointers to the expected sentinel value have some
big problems: it hides the real content of the array, makes the pointer
to the sentinel point to a completely different memory region and treats
it like a const value even when the underlying array is mutable.

Fixes #4840
2020-03-30 11:03:56 -04:00
Andrew Kelley c70471fae6
enable now-passing test cases
These can now be enabled thanks to bug fixes that landed in
LLVM 10.
2020-03-29 10:34:12 -04:00
Andrew Kelley ddd98a7f10
prevent ptr cast from forcing alignment resolution unnecessarily 2020-03-26 12:34:16 -04:00
Andrew Kelley 93c7fa105f
Merge remote-tracking branch 'origin/llvm10'
LLVM 10 was released today
2020-03-24 09:57:09 -04:00
LemonBoy 0cd953d40e ir: Prevent crash when slicing hardcoded pointer
Closes #4780
2020-03-23 09:13:52 -04:00
Andrew Kelley 13d04f9963
Merge pull request #4741 from momumi/master
allow `_` separators in number literals (stage 1)
2020-03-23 00:54:54 -04:00
Andrew Kelley e5e5196d8e
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-22 20:48:21 -04:00
LemonBoy 6a89751025 ir: Implement cast from anon struct to union 2020-03-22 19:06:22 -04:00
Andrew Kelley 23c263776c
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-22 15:09:29 -04:00
LemonBoy 28dbc58837 Address review comments 2020-03-21 09:54:49 +01:00
LemonBoy 128e70ff3a ir: Allow errdefer with payload
Closes #1265
2020-03-21 09:54:49 +01:00
LemonBoy 541e763010 ir: Peer type resolution between ?[]T and *[N]T
Closes #4767
2020-03-20 12:23:05 -04:00
Andrew Kelley 53b5aa812b
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-19 22:19:24 -04:00
Andrew Kelley 8ddf9d84ff
add behavior tests for slicing with comptime indexes 2020-03-19 11:17:46 -04:00
Andrew Kelley f824658e13
slicing sentinel-terminated slice without end
now results in a sentinel-terminated slice.
2020-03-19 10:54:20 -04:00
Andrew Kelley b5dba702ff
fixes to std.meta
behavior tests are passing now
2020-03-19 09:53:55 -04:00
Andrew Kelley 2164b511cc
partial revert of an improvement this branch made
because it uncovered a result location bug, and I need to get this
branch merged before going into a result location rabbit hole.

also fix the result type of slicing when the indexes are runtime known
and the result should be sentinel terminated.
2020-03-19 09:53:55 -04:00
Andrew Kelley 2b4134459d
fix alignment when slicing with comptime start and end index 2020-03-19 09:53:54 -04:00
Andrew Kelley 0707be8de8
fixes in semantic analysis needed to support this feature 2020-03-19 09:53:54 -04:00
LemonBoy e3c92d0532 ir: More changes to sentinel-terminated const arrays
* Don't add an extra slot for the sentinel. Most of the code keeps using
  the constant value from the type descriptor, let's harmonize all the
  code dealing with sentinels.

* Properly write out sentinel values when reinterpreting pointers at
  comptime.

* Allow the reading of the 0th element in a `[0:S]T` type.
2020-03-19 09:53:30 -04:00
LemonBoy 1479c28b49
ir: Correct ABI size calculation for arrays
Zero-length array with a sentinel may not have zero size.

Closes #4749
2020-03-18 11:10:45 -04:00
momumi 7aac21c6f5 allow `_` separators in number literals (stage 1)
* Underscores `_` may be placed between two digits in a int/float literal
* Consecutive underscores are not allowed
* Fixed parsing bug in exponents of hexadecimal float literals.
  Exponents should always be base 10, but hex characters would be parsed
  inside the exponent and everything after them would be ignored. eg:
  `0x1.0p1ab1` would be parsed as `0x1.0p1`.
2020-03-15 12:38:35 +10:00