48 Commits

Author SHA1 Message Date
antlilja
eb7fad28f8 Improve f128 standard library support
* Add functions: floor128, ceil128, trunc128 and round128
* Add corresponding tests
2020-06-17 18:18:45 +02:00
Jonathan Marler
12051b02f1 fix memory errors 2020-06-09 00:17:22 -04:00
Andrew Kelley
ec6ef86219 fix off-by-one error in sizeInBaseUpperBound 2020-05-01 13:33:46 -04:00
Andrew Kelley
4044a77621 update std.meta.IntType => std.meta.Int 2020-05-01 06:49:30 -04:00
Andrew Kelley
8766821157 rework std.math.big.Int
Now there are 3 types:
 * std.math.big.int.Const
   - the memory is immutable, only stores limbs and is_positive
   - all methods operating on constant data go here
 * std.math.big.int.Mutable
   - the memory is mutable, stores capacity in addition to limbs and
     is_positive
   - methods here have some Mutable parameters and some Const
     parameters. These methods expect callers to pre-calculate the
     amount of resources required, and asserts that the resources are
     available.
 * std.math.big.int.Managed
   - the memory is mutable and additionally stores an allocator.
   - methods here perform the resource calculations for the programmer.
   - this is the high level abstraction from before

Each of these 3 types can be converted to the other ones.

You can see the use case for this in the self-hosted compiler, where we
only store limbs, and construct the big ints as needed.

This gets rid of the hack where the allocator was optional and the
notion of "fixed" versions of the struct. Such things are now modeled
with the `big.int.Const` type.
2020-05-01 06:47:56 -04:00
Andrew Kelley
28729efe29 ZIR: implement return instruction 2020-05-01 06:47:20 -04:00
Andrew Kelley
6b0f7de247 ZIR: add cmp and condbr instructions 2020-05-01 06:47:20 -04:00
Tadeo Kondrak
350b2adacd
std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
Nick Appleton
28c31a8429
Fix f64 variants of math.cosh and math.sinh to accept negative inputs. (#5172)
* add tests for negative inputs to cosh32 and cosh64. fix bug in cosh64 for negative inputs.

* fix problem with negative input with f64 sinh and add tests
2020-04-26 14:03:19 -04:00
Andrew Kelley
1eda2ada9a std.math.big.Int: don't rely on the allocator when printing 2020-04-22 03:49:50 -04:00
Andrew Kelley
2cdbb5f472 ir: analyze int casting 2020-04-21 19:48:59 -04:00
joachimschmidt557
3fd38429e4 Enable formatting in std.big.Int.format 2020-04-15 12:51:43 -04:00
Vexu
ca3bf6e6ad
translate-c cleanup and zig fmt 2020-04-15 15:15:32 +03:00
joachimschmidt557
1ee59c5c31 move big.rational.gcd to big.int.gcd 2020-04-07 13:43:15 -04:00
xackus
7a28c644aa new ArrayList API: fix everything else 2020-04-02 16:12:08 +02:00
Andrew Kelley
93c7fa105f
Merge remote-tracking branch 'origin/llvm10'
LLVM 10 was released today
2020-03-24 09:57:09 -04:00
Joachim Schmidt
5acc8afb5f
Use math.Order for comparing bigints instead of i8 (#4791) 2020-03-23 23:16:57 -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
momumi
8de45e5143 update parsing of int literals in self-hosted
* update std.math.big.Int.setString() to ignore underscores and make it
  case insensitive
* fix issue in ir.zig with leading zeroes in integer literals
2020-03-22 13:59:14 +10:00
Andrew Kelley
53b5aa812b
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-19 22:19:24 -04:00
Andrew Kelley
dbde5df568
clean up some self-hosted bitrot + don't assume libstdc++
closes #4682

The self-hosted compiler is still bit rotted and still not compiling
successfully yet. I have a more serious rework of the code in a
different branch.
2020-03-17 23:03:45 -04:00
Andrew Kelley
656ba530d8
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-13 15:17:53 -04:00
Benjamin Feng
4aae55b4cc Replace fmt with new fmtstream 2020-03-12 10:41:09 -05:00
Benjamin Feng
c11d1055b8 Integrated outstreams with new formatter 2020-03-12 10:26:28 -05:00
Andrew Kelley
d1cb16aace
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-03 09:44:13 -05:00
xackus
00be934569 short std.builtin enum literals in std lib 2020-03-01 13:57:41 -05:00
Andrew Kelley
87b9e744dd
update std lib to new Target API 2020-02-28 14:51:54 -05:00
Andrew Kelley
f33bf48af7
Merge remote-tracking branch 'origin/master' into llvm10 2020-02-25 16:30:40 -05:00
Vexu
538d9a5dd8
remove uses of @ArgType and @IntType 2020-02-24 23:39:03 +02:00
Vexu
45da72c5b6
remove usages of @typeId, @memberCount, @memberName and @memberType 2020-02-24 23:09:01 +02:00
Andrew Kelley
a8b36fbe34
Merge remote-tracking branch 'origin/master' into llvm10 2020-02-14 10:27:44 -05:00
daurnimator
6ea6d5a4bd
std: use testing.allocator in tests 2020-02-14 19:15:09 +11:00
daurnimator
ca41567924
std: use testing.allocator in big int tests 2020-02-14 18:59:40 +11:00
daurnimator
b61e53cc40
std: bigint.deinit() shouldn't need a mutable pointer 2020-02-14 18:59:07 +11:00
Andrew Kelley
9e5b248991
remove workarounds for Windows native CPU features
bug fixed in LLVM 10

closes #508
2020-02-07 12:41:46 -05:00
Andrew Kelley
830e0ba2d2 enable native CPU feature for windows; disable failing tests
See #508. These can be re-enabled when we upgrade to LLVM 10.
2020-01-21 21:46:06 -05:00
LemonBoy
e81b505960 Use the correct calling convention for AEABI intrinsics 2020-01-07 13:42:47 -05:00
Andrew Kelley
53913acaf7
zig fmt and update extern fn to callconv(.C) 2020-01-06 15:34:50 -05:00
Haze Booth
2e5342512f remove @TypeOf() hacks for comptime_int/comptime_float 2020-01-05 02:33:23 -05:00
Andrew Kelley
cb56b26900
fix float ops with respect to vectors
also remove the redundant type parameter
2020-01-01 23:27:43 -05:00
ForLoveOfCats
b28824ef66 Add missing deferred deinits to math.big.Int.toString (mem leak fix) 2019-12-28 15:31:32 -05:00
Robin Voetter
4b4fbe3887
Replace @typeOf with @TypeOf in all zig source
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-10 11:09:41 -05:00
Andrew Kelley
8b2622cdd5
std.fmt.format: tuple parameter instead of var args 2019-12-08 22:53:51 -05:00
Andrew Kelley
343987cd05
remove @inlineCall from zig 2019-12-06 14:12:01 -05:00
Andrew Kelley
aa0daea541
update more of the std lib to use @as 2019-11-08 15:57:25 -05:00
Andrew Kelley
e0db54e89d
update the codebase to use @as 2019-11-08 15:57:24 -05:00
Brendan Hansknecht
52207f22de Add karatsuba to big ints 2019-11-04 13:20:03 -05:00
Andrew Kelley
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00