| Age | Commit message (Collapse) | Author |
|
|
|
This for example allows for multiple LLVM instances to run in parallel.
Also rename some functions in llvm_bindings.zig.
Fixes #7688
|
|
This way the generated code only has to setup the stack size at the
beginning of a function and this improves codegen.
Fixes #7689
```
fn foo() void {}
export fn hello(z: i8) void {
var x: i16 = undefined;
foo();
var y: i32 = 1;
y += z;
}
```
llvm-ir:
```
define void @hello(i8 %0) {
Entry:
%1 = alloca i8, align 1
%2 = alloca i16, align 2
%3 = alloca i32, align 4
store i8 %0, i8* %1, align 1
%4 = load i8, i8* %1, align 1
store i16 undef, i16* %2, align 2
call void @foo()
store i32 1, i32* %3, align 4
%5 = load i32, i32* %3, align 4
%6 = sext i8 %4 to i32
%7 = add nsw i32 %5, %6
store i32 %7, i32* %3, align 4
ret void
}
```
|
|
The same has been done for all the other LLVM types.
|
|
Also adds support for extern functions, simple pointer and simple array
types and values.
A simple hello world now compiles:
`zig build-exe example.zig -fLLVM -lc`
```
extern fn puts(s: [*:0]const u8) c_int;
export fn main() c_int {
_ = puts("hello world!");
return 0;
}
```
|
|
Also adds support for simple operators, like add and subtract.
The intcast and bitcast instruction also have been implemented.
Linking with libc also works, so we can now generate working executables!
`zig build-exe example.zig -fLLVM -lc`:
```
fn add(a: i32, b: i32) i32 {
return a + b;
}
export fn main() c_int {
var a: i32 = -5;
const x = add(a, 7);
var y = add(2, 0);
y -= x;
return y;
}
```
|
|
|
|
Furthermore add the Not instruction.
The following now works:
```
export fn _start() noreturn {
var x: bool = true;
var other: bool = foo(x);
exit();
}
fn foo(cond: bool) bool {
return !cond;
}
fn exit() noreturn {
unreachable;
}
```
|
|
The following now works:
```
export fn _start() noreturn {
var x: bool = true;
var y: bool = x;
exit();
}
fn exit() noreturn {
unreachable;
}
```
|
|
A HashMap has been added which store the LLVM values used in a function.
Together with the alloc and store instructions the following now works:
```
export fn _start() noreturn {
var x: bool = true;
exit();
}
fn exit() noreturn {
unreachable;
}
```
|
|
The following works:
```
export fn _start() noreturn {
assert(true);
exit();
}
fn assert(cond: bool) void {}
fn exit() noreturn {
unreachable;
}
```
|
|
|
|
Putting functions in this file will create functions like
`llvm.function`, and the compiler thinks these are llvm intrinsics.
|