Andrew Kelley
0d117bb0a9
fix wrong value for clz, ctz at compile time
...
closes #418
also make clz, ctz return smaller integer bit widths
and use smaller integer bit widths for enum tag types
2017-08-17 17:14:35 -04:00
Andrew Kelley
6a98bf3dba
compiler_rt implementations for __fixuns* functions
...
* add u128 and i128 integer types
* add f128 floating point type
* implement big integer multiplication (See #405 )
2017-08-16 19:07:35 -04:00
Andrew Kelley
35d3444e27
more intuitive left shift and right shift operators
...
Before:
* << is left shift, not allowed to shift 1 bits out
* <<% is left shift, allowed to shift 1 bits out
* >> is right shift, allowed to shift 1 bits out
After:
* << is left shift, allowed to shift 1 bits out
* >> is right shift, allowed to shift 1 bits out
* @shlExact is left shift, not allowed to shift 1 bits out
* @shrExact is right shift, not allowed to shift 1 bits out
Closes #413
2017-08-09 10:09:38 -04:00
Andrew Kelley
54675b060a
add ptrToInt builtin, remove usize(ptr) cast
...
closes #415
2017-08-08 17:38:25 -04:00
Andrew Kelley
d8227c79a2
limit generated C preprocessor tokens to alphabet
...
closes #407
The mangling strategy replaces bytes outside the alphabet
with "_xx_" where xx is the hex code of the byte.
2017-08-06 19:31:05 -04:00
Andrew Kelley
d83e4092bf
fix constant debug info when number literal is 0
2017-08-06 18:15:11 -04:00
Andrew Kelley
d1e68c3ca8
better bigint/bigfloat implementation
2017-07-08 17:59:10 -04:00
Andrew Kelley
c9fc8bd802
workaround for llvm bug
...
See #393 for details
2017-06-19 14:36:33 -04:00
Andrew Kelley
ae61e26680
fix compiler segfault on null ?? x
...
closes #390
2017-06-14 19:32:52 -04:00
Andrew Kelley
7f0620a20f
partial implementation of printing floating point numbers with errol3
...
also add bitCast builtin function. closes #387
2017-06-14 00:24:25 -04:00
Andrew Kelley
6a93dda3e1
progress toward windows hello world working
2017-06-14 00:04:34 -04:00
Andrew Kelley
2dfb1ebee2
const global values can reference each other
...
Before, if you did something like:
```
const hi1 = "hi";
const hi2 = hi1;
```
This would create the "hi" data twice in the built object.
But since the value is const we don't have to duplicate the
data, now we take advantage of this fact.
closes #336
2017-05-27 00:54:14 -04:00
Andrew Kelley
d8d45908fa
building with mingw for windows
2017-05-23 00:26:12 -04:00
Andrew Kelley
565ac3e27a
flip the enum order of FloatMode
2017-05-20 23:26:39 -04:00
Andrew Kelley
29b488245d
add setFloatMode builtin and std.math.floor
...
* skip installing std/rand_test.zig as it's not needed beyond running
the std lib tests
* add std.math.floor function
* add setFloatMode builtin function to choose between
builtin.FloatMode.Optimized (default) and builtin.FloatMode.Strict
(Optimized is equivalent to -ffast-math in gcc)
2017-05-20 23:06:32 -04:00
Andrew Kelley
b483db4868
typeId builtin instead of isInteger, isFloat, etc
...
closes #373
2017-05-17 12:26:35 -04:00
Andrew Kelley
6237411716
inline function call with builtin function instead...
...
...of special syntax.
partially reverts 41144a8566a6fbd779403f6b69424bb640c94a7f
closes #306
2017-05-09 22:54:23 -04:00
Andrew Kelley
2f20fe6ecd
delete @generatedCode builtin function
...
good riddance
2017-05-07 23:25:36 -04:00
Andrew Kelley
5774b48ceb
rename c_long_double to c_longdouble
...
to be consistent with other c primitive type names
2017-05-07 19:51:44 -04:00
Andrew Kelley
157af4332a
builtin functions for division and remainder division
...
* add `@divTrunc` and `@divFloor` functions
* add `@rem` and `@mod` functions
* add compile error for `/` and `%` with signed integers
* add `.bit_count` for float primitive types
closes #217
2017-05-06 23:13:12 -04:00
Andrew Kelley
866c841dd8
add compile error when unable to inline a function
...
See #38
2017-05-04 15:11:24 -04:00
Andrew Kelley
24a9a42966
add safe release build mode
...
closes #288
2017-05-02 17:34:21 -04:00
Andrew Kelley
cff5358f60
make debug safety stuff lazy
2017-05-01 19:16:48 -04:00
Andrew Kelley
17b935325e
@import("builtin")
instead of @compileVar
...
See #226
Closes #220
2017-05-01 13:12:38 -04:00
Andrew Kelley
363d9038c9
zig build: organize build artifacts
...
closes #328
2017-04-30 18:56:24 -04:00
Andrew Kelley
29defd705d
back to AT&T syntax for assembly
...
this reverts 5c04730534ea7933855429c5fc5dc7b22eba7bc2.
sadly the quality of the intel dialect in llvm's assembly
parser has many frustrating bugs, and generally has unfortunate
syntax.
the plan is to use AT&T for now since it at least works,
and eventually zig will have its own assembly parser for
x86 and it will be as close to NASM as possible.
2017-04-30 11:28:11 -04:00
Andrew Kelley
a147f06585
zig puts temporary object files in zig-cache folder
...
See #298
2017-04-28 02:22:12 -04:00
Andrew Kelley
1691074b4b
add no-elim-base-pointer to __zig_fail function
...
fixes missing frame for unwrapping an error
closes #345
2017-04-27 18:40:17 -04:00
Andrew Kelley
7e11ef79d6
zig test no longer requires a separate test_runner.o file
...
See #298
2017-04-27 16:19:20 -04:00
Andrew Kelley
7b0542d08b
build system: consolidate duplicate code and more
...
* add ability to add assembly files when building an exe, obj, or lib
* add implicit cast from `[N]T` to `?[]const T` (closes #343 )
* remove link_exe and link_lib in favor of allowing build_exe and
build_lib support no root zig source file
2017-04-26 19:17:05 -04:00
Andrew Kelley
afa80da857
revert the last 3 compile time improvements
...
they introduced complexity into the compiler and didn't
really help.
This reverts commit efa771af754281cd76a77ef22af107eb0a9aaf9a.
This reverts commit 8614397110595e267b7e4e1f558bfce619e60c02.
This reverts commit 13c6a58a61817ae6aae66dd1843385452fe65bd1.
2017-04-25 17:14:22 -04:00
Andrew Kelley
13c6a58a61
compile time improvement - move bounds checking to function calls
...
once again this barely had an effect:
Before:
./build size: 1.3 MB
hello.zig size: 301 KB
full test: 1m31.253s
debug test: 19.607s
hello.zig timing:
Name Start End Duration Percent
Initialize 0.0000 0.0000 0.0000 0.0002
Semantic Analysis 0.0000 0.0431 0.0431 0.2262
Code Generation 0.0431 0.0660 0.0229 0.1201
LLVM Emit Object 0.0660 0.1765 0.1105 0.5795
Build Dependencies 0.1765 0.1890 0.0125 0.0655
LLVM Link 0.1890 0.1906 0.0016 0.0086
Generate .h 0.1906 0.1906 0.0000 0.0000
Total 0.0000 0.1906 0.1906 1.0000
After:
./build size: 1.3 MB
hello.zig size: 300 KB
full test: 1m31.882s
debug test: 19.569s
hello.zig timing:
Name Start End Duration Percent
Initialize 0.0000 0.0000 0.0000 0.0002
Semantic Analysis 0.0000 0.0425 0.0424 0.2228
Code Generation 0.0425 0.0661 0.0236 0.1239
LLVM Emit Object 0.0661 0.1762 0.1101 0.5782
Build Dependencies 0.1762 0.1888 0.0126 0.0664
LLVM Link 0.1888 0.1905 0.0016 0.0085
Generate .h 0.1905 0.1905 0.0000 0.0000
Total 0.0000 0.1905 0.1905 1.0000
2017-04-25 16:53:22 -04:00
Andrew Kelley
8614397110
compile time improvement - move overflow math safety to fns
...
move some boilerplate code having to do with overflow math safety
to functions.
Again the timing difference is not much:
Before:
./build size: 1.3 MB
hello.zig size: 308 KB
full test: 1m33.588s
debug test: 20.303s
hello.zig timing:
Name Start End Duration Percent
Initialize 0.0000 0.0000 0.0000 0.0002
Semantic Analysis 0.0000 0.0425 0.0425 0.2202
Code Generation 0.0425 0.0675 0.0250 0.1293
LLVM Emit Object 0.0675 0.1789 0.1114 0.5773
Build Dependencies 0.1789 0.1913 0.0124 0.0640
LLVM Link 0.1913 0.1931 0.0018 0.0091
Generate .h 0.1931 0.1931 0.0000 0.0000
Total 0.0000 0.1931 0.1931 1.0000
After:
./build size: 1.3 MB
hello.zig size: 301 KB
full test: 1m31.253s
debug test: 19.607s
hello.zig timing:
Name Start End Duration Percent
Initialize 0.0000 0.0000 0.0000 0.0002
Semantic Analysis 0.0000 0.0431 0.0431 0.2262
Code Generation 0.0431 0.0660 0.0229 0.1201
LLVM Emit Object 0.0660 0.1765 0.1105 0.5795
Build Dependencies 0.1765 0.1890 0.0125 0.0655
LLVM Link 0.1890 0.1906 0.0016 0.0086
Generate .h 0.1906 0.1906 0.0000 0.0000
Total 0.0000 0.1906 0.1906 1.0000
2017-04-25 15:37:56 -04:00
Andrew Kelley
efa771af75
compile time improvement - add __zig_panic_slice fn
...
move some boilerplate code having to do with panicking
to a function.
Here's the timing difference. It's not much:
Before:
full test: 1m36.511s
debug test: 20.862s
hello.zig
Name Start End Duration Percent
Initialize 0.0000 0.0000 0.0000 0.0001
Semantic Analysis 0.0000 0.0421 0.0420 0.2109
Code Generation 0.0421 0.0620 0.0200 0.1003
LLVM Emit Object 0.0620 0.1852 0.1231 0.6180
Build Dependencies 0.1852 0.1974 0.0122 0.0615
LLVM Link 0.1974 0.1993 0.0018 0.0093
Generate .h 0.1993 0.1993 0.0000 0.0000
Total 0.0000 0.1993 0.1993 1.0000
After:
full test: 1m33.588s
debug test: 20.303s
hello.zig
Name Start End Duration Percent
Initialize 0.0000 0.0000 0.0000 0.0002
Semantic Analysis 0.0000 0.0425 0.0425 0.2202
Code Generation 0.0425 0.0675 0.0250 0.1293
LLVM Emit Object 0.0675 0.1789 0.1114 0.5773
Build Dependencies 0.1789 0.1913 0.0124 0.0640
LLVM Link 0.1913 0.1931 0.0018 0.0091
Generate .h 0.1931 0.1931 0.0000 0.0000
Total 0.0000 0.1931 0.1931 1.0000
2017-04-25 14:20:15 -04:00
Andrew Kelley
e0050af293
add some timing diagnostics
...
pass --enable-timing-info to print a nice table like this:
```
Name Start End Duration Percent
Initialize 0.0000 0.0000 0.0000 0.0001
Semantic Analysis 0.0000 0.0421 0.0420 0.2109
Code Generation 0.0421 0.0620 0.0200 0.1003
LLVM Emit Object 0.0620 0.1852 0.1231 0.6180
Build Dependencies 0.1852 0.1974 0.0122 0.0615
LLVM Link 0.1974 0.1993 0.0018 0.0093
Generate .h 0.1993 0.1993 0.0000 0.0000
Total 0.0000 0.1993 0.1993 1.0000
```
2017-04-25 12:29:25 -04:00
Andrew Kelley
245eed8afe
better stack traces for ELF x86_64
2017-04-24 12:14:45 -04:00
Josh Wolfe
c6605cba83
blocks check that their statements are void
...
closes #291
This changes the error message "return value ignored" to "expression value is ignored".
This is because this error also applies to {1;}, which has no function calls.
Also fix ignored expression values in std and test.
This caught a bug in debug.readAllocBytes where an early Eof error would have been missed.
See #219 .
2017-04-23 21:15:15 -07:00
Andrew Kelley
6de33ded81
make undefined as a constant value lazy
...
closes #268
2017-04-23 14:34:40 -04:00
Andrew Kelley
0f633167c5
fix crash when unwrapping error with no error decls
...
closes #339
2017-04-23 03:14:22 -04:00
Andrew Kelley
e3c524c1d4
rename @ptrcast
to @ptrCast
to follow convention
2017-04-21 10:39:13 -04:00
Andrew Kelley
fb492d19eb
zig build system supports building a library
...
See #329
Supporting work:
* move std.cstr.Buffer0 to std.buffer.Buffer
* add build.zig to example/shared_library/ and add an automated test
for it
* add std.list.List.resizeDown
* improve std.os.makePath
- no longer recursive
- takes into account . and ..
* add std.os.path.isAbsolute
* add std.os.path.resolve
* reimplement std.os.path.dirname
- no longer requires an allocator
- handles edge cases correctly
2017-04-21 01:56:12 -04:00
Raul Leal
5234016561
Add @offsetOf builtin function
2017-04-20 11:53:00 +00:00
Andrew Kelley
d12f1f5b49
test framework supports name prefix and filter argument
...
rename self hosted tests to behavior tests
2017-04-19 15:38:12 -04:00
Andrew Kelley
237dfdbdc6
error when building exe with no entry point
...
closes #30
2017-04-18 14:04:48 -04:00
Andrew Kelley
a791417552
add @fieldParentPtr
builtin function
...
closes #320
2017-04-18 02:28:05 -04:00
Andrew Kelley
407916cd2f
rename @intType
to @IntType
to follow convention
...
closes #327
2017-04-18 00:05:09 -04:00
Andrew Kelley
47336abae3
improvements to zig build system and unwrap error safety
...
* zig build system: create standard dynamic library sym links
* unwrapping an error results in a panic message that contains
the error name
* rename error.SysResources to error.SystemResources
* add std.os.symLink
* add std.os.deleteFile
2017-04-17 06:47:20 -04:00
Andrew Kelley
dcfa0e50dc
all internal functions get unnamed_addr attribute
2017-04-13 03:34:57 -04:00
Andrew Kelley
bf57d8a7e3
typedefpocalypse
...
closes #314
2017-04-13 03:07:58 -04:00
Andrew Kelley
41144a8566
ability to inline at function callsite
...
closes #306
2017-04-13 00:13:54 -04:00