mirror of
https://github.com/odin-lang/Odin.git
synced 2026-09-02 02:03:35 +00:00
Merge branch 'master' of https://github.com/odin-lang/Odin
This commit is contained in:
@@ -7008,6 +7008,18 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
|
||||
}
|
||||
}
|
||||
|
||||
// an `asm` template's `$` parameter is encoded as an immediate, so only a constant can reach it
|
||||
if (e && e->kind == Entity_Variable && (e->flags & EntityFlag_PolyConst)) {
|
||||
if (o->mode != Addressing_Constant) {
|
||||
if (show_error) {
|
||||
gbString str = expr_to_string(o->expr);
|
||||
error(o->expr, "Expected a constant value for the '$' immediate '%.*s', got %s", LIT(e->token.string), str);
|
||||
gb_string_free(str);
|
||||
}
|
||||
err = CallArgumentError_NoneConstantParameter;
|
||||
}
|
||||
}
|
||||
|
||||
if (e && e->kind == Entity_Constant && is_type_proc(e->type)) {
|
||||
bool ok = false;
|
||||
if (o->mode == Addressing_Constant) {
|
||||
|
||||
@@ -3872,6 +3872,24 @@ gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left
|
||||
rhs = lb_emit_byte_swap(p, {rhs, pt}, pt).value;
|
||||
}
|
||||
|
||||
if (is_type_boolean(a) && is_type_boolean(b) && (op_kind == Token_CmpEq || op_kind == Token_NotEq)) {
|
||||
// anything not 0 is true, which is what control flow already tests for
|
||||
bool lhs_is_const = LLVMIsAConstantInt(lhs) != nullptr;
|
||||
bool rhs_is_const = LLVMIsAConstantInt(rhs) != nullptr;
|
||||
if (lhs_is_const != rhs_is_const) {
|
||||
// against a literal, the truthiness test is the whole comparison
|
||||
LLVMValueRef v = rhs_is_const ? lhs : rhs;
|
||||
LLVMValueRef c = rhs_is_const ? rhs : lhs;
|
||||
bool is_true = LLVMConstIntGetZExtValue(c) != 0;
|
||||
pred = ((op_kind == Token_CmpEq) == is_true) ? LLVMIntNE : LLVMIntEQ;
|
||||
lhs = v;
|
||||
rhs = LLVMConstNull(LLVMTypeOf(v));
|
||||
} else {
|
||||
lhs = LLVMBuildICmp(p->builder, LLVMIntNE, lhs, LLVMConstNull(LLVMTypeOf(lhs)), "");
|
||||
rhs = LLVMBuildICmp(p->builder, LLVMIntNE, rhs, LLVMConstNull(LLVMTypeOf(rhs)), "");
|
||||
}
|
||||
}
|
||||
|
||||
res.value = LLVMBuildICmp(p->builder, pred, lhs, rhs, "");
|
||||
} else if (is_type_float(a)) {
|
||||
LLVMRealPredicate pred = {};
|
||||
|
||||
Reference in New Issue
Block a user