Constant and
This commit is contained in:
parent
99e13a7218
commit
648fe7480d
@ -580,6 +580,10 @@ pub const Builder = opaque {
|
||||
return api.LLVMBuildLShr(builder, left, right, "");
|
||||
}
|
||||
|
||||
pub fn create_and(builder: *Builder, left: *Value, right: *Value) *Value {
|
||||
return api.LLVMBuildAnd(builder, left, right, "");
|
||||
}
|
||||
|
||||
pub fn create_ret_void(builder: *Builder) void {
|
||||
builder.create_ret(null);
|
||||
}
|
||||
|
@ -305,6 +305,7 @@ const Converter = struct {
|
||||
shl,
|
||||
ashr,
|
||||
lshr,
|
||||
@"and",
|
||||
};
|
||||
|
||||
fn parse_value(noalias converter: *Converter, noalias thread: *llvm.Thread, expected_type: Type) *llvm.Value {
|
||||
@ -336,6 +337,7 @@ const Converter = struct {
|
||||
.shl => thread.builder.create_shl(left, right),
|
||||
.ashr => thread.builder.create_ashr(left, right),
|
||||
.lshr => thread.builder.create_lshr(left, right),
|
||||
.@"and" => thread.builder.create_and(left, right),
|
||||
};
|
||||
|
||||
const ch = converter.content[converter.offset];
|
||||
@ -392,6 +394,10 @@ const Converter = struct {
|
||||
else => os.abort(),
|
||||
};
|
||||
},
|
||||
'&' => blk: {
|
||||
converter.offset += 1;
|
||||
break :blk .@"and";
|
||||
},
|
||||
else => os.abort(),
|
||||
};
|
||||
|
||||
|
@ -110,3 +110,7 @@ test "constant shift left" {
|
||||
test "constant shift right" {
|
||||
try invoke("constant_shift_right");
|
||||
}
|
||||
|
||||
test "constant and" {
|
||||
try invoke("constant_and");
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ pub extern fn LLVMBuildURem(builder: *llvm.Builder, left: *llvm.Value, right: *l
|
||||
pub extern fn LLVMBuildShl(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildAShr(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildLShr(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildAnd(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
|
||||
pub extern fn LLVMTypeOf(value: *llvm.Value) *llvm.Type;
|
||||
pub extern fn LLVMGlobalGetValueType(value: *llvm.GlobalValue) *llvm.Type;
|
||||
|
4
tests/constant_and.bbb
Normal file
4
tests/constant_and.bbb
Normal file
@ -0,0 +1,4 @@
|
||||
[export] main = fn [cc(c)] () s32
|
||||
{
|
||||
return 1 & 2;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user