Constant or
This commit is contained in:
parent
648fe7480d
commit
9b8011086f
@ -584,6 +584,10 @@ pub const Builder = opaque {
|
||||
return api.LLVMBuildAnd(builder, left, right, "");
|
||||
}
|
||||
|
||||
pub fn create_or(builder: *Builder, left: *Value, right: *Value) *Value {
|
||||
return api.LLVMBuildOr(builder, left, right, "");
|
||||
}
|
||||
|
||||
pub fn create_ret_void(builder: *Builder) void {
|
||||
builder.create_ret(null);
|
||||
}
|
||||
|
@ -306,6 +306,7 @@ const Converter = struct {
|
||||
ashr,
|
||||
lshr,
|
||||
@"and",
|
||||
@"or",
|
||||
};
|
||||
|
||||
fn parse_value(noalias converter: *Converter, noalias thread: *llvm.Thread, expected_type: Type) *llvm.Value {
|
||||
@ -338,6 +339,7 @@ const Converter = struct {
|
||||
.ashr => thread.builder.create_ashr(left, right),
|
||||
.lshr => thread.builder.create_lshr(left, right),
|
||||
.@"and" => thread.builder.create_and(left, right),
|
||||
.@"or" => thread.builder.create_or(left, right),
|
||||
};
|
||||
|
||||
const ch = converter.content[converter.offset];
|
||||
@ -398,6 +400,10 @@ const Converter = struct {
|
||||
converter.offset += 1;
|
||||
break :blk .@"and";
|
||||
},
|
||||
'|' => blk: {
|
||||
converter.offset += 1;
|
||||
break :blk .@"or";
|
||||
},
|
||||
else => os.abort(),
|
||||
};
|
||||
|
||||
|
@ -114,3 +114,7 @@ test "constant shift right" {
|
||||
test "constant and" {
|
||||
try invoke("constant_and");
|
||||
}
|
||||
|
||||
test "constant or" {
|
||||
try invoke("constant_or");
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ pub extern fn LLVMBuildShl(builder: *llvm.Builder, left: *llvm.Value, right: *ll
|
||||
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 LLVMBuildOr(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_or.bbb
Normal file
4
tests/constant_or.bbb
Normal file
@ -0,0 +1,4 @@
|
||||
[export] main = fn [cc(c)] () s32
|
||||
{
|
||||
return 0 | 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user