Fix most MSVC compilation warnings

This commit is contained in:
Dmitry Stogov 2023-02-28 02:11:09 +03:00
parent 81d87444af
commit 9b34731d16
12 changed files with 100 additions and 73 deletions

View File

@ -86,7 +86,7 @@ int find_hash(uint32_t *mask, uint32_t count)
static int find_op(const char *s, size_t len)
{
return ir_strtab_find(&strtab, s, len) - 1;
return ir_strtab_find(&strtab, s, (uint8_t)len) - 1;
}
static int parse_rule(const char *buf)

21
ir.c
View File

@ -70,10 +70,10 @@ const char *ir_op_name[IR_LAST_OP] = {
void ir_print_const(ir_ctx *ctx, ir_insn *insn, FILE *f)
{
if (insn->op == IR_FUNC) {
fprintf(f, "%s", ir_get_str(ctx, insn->val.addr));
fprintf(f, "%s", ir_get_str(ctx, insn->val.i32));
return;
} else if (insn->op == IR_STR) {
fprintf(f, "\"%s\"", ir_get_str(ctx, insn->val.addr));
fprintf(f, "\"%s\"", ir_get_str(ctx, insn->val.i32));
return;
}
IR_ASSERT(IR_IS_CONST_OP(insn->op) || insn->op == IR_FUNC_ADDR);
@ -611,10 +611,14 @@ ir_ref ir_const_str(ir_ctx *ctx, ir_ref str)
ir_ref ir_str(ir_ctx *ctx, const char *s)
{
size_t len;
if (!ctx->strtab.data) {
ir_strtab_init(&ctx->strtab, 64, 4096);
}
return ir_strtab_lookup(&ctx->strtab, s, strlen(s), ir_strtab_count(&ctx->strtab) + 1);
len = strlen(s);
IR_ASSERT(len <= 0xffffffff);
return ir_strtab_lookup(&ctx->strtab, s, (uint32_t)len, ir_strtab_count(&ctx->strtab) + 1);
}
ir_ref ir_strl(ir_ctx *ctx, const char *s, size_t len)
@ -622,7 +626,8 @@ ir_ref ir_strl(ir_ctx *ctx, const char *s, size_t len)
if (!ctx->strtab.data) {
ir_strtab_init(&ctx->strtab, 64, 4096);
}
return ir_strtab_lookup(&ctx->strtab, s, len, ir_strtab_count(&ctx->strtab) + 1);
IR_ASSERT(len <= 0xffffffff);
return ir_strtab_lookup(&ctx->strtab, s, (uint32_t)len, ir_strtab_count(&ctx->strtab) + 1);
}
const char *ir_get_str(ir_ctx *ctx, ir_ref idx)
@ -1346,7 +1351,7 @@ static ir_alias ir_check_partial_aliasing(ir_ctx *ctx, ir_ref addr1, ir_ref addr
insn2 = &ctx->ir_base[addr2];
if (insn1->op == IR_ADD && IR_IS_CONST_REF(insn1->op2)) {
if (insn1->op1 == addr2) {
uintptr_t offset1 = ctx->ir_base[insn1->op2].val.u64;
uintptr_t offset1 = ctx->ir_base[insn1->op2].val.addr;
uintptr_t size2 = ir_type_size[type2];
return (offset1 < size2) ? IR_MUST_ALIAS : IR_NO_ALIAS;
@ -1354,8 +1359,8 @@ static ir_alias ir_check_partial_aliasing(ir_ctx *ctx, ir_ref addr1, ir_ref addr
if (insn1->op2 == insn2->op2) {
return IR_MUST_ALIAS;
} else if (IR_IS_CONST_REF(insn1->op2) && IR_IS_CONST_REF(insn2->op2)) {
uintptr_t offset1 = ctx->ir_base[insn1->op2].val.u64;
uintptr_t offset2 = ctx->ir_base[insn2->op2].val.u64;
uintptr_t offset1 = ctx->ir_base[insn1->op2].val.addr;
uintptr_t offset2 = ctx->ir_base[insn2->op2].val.addr;
if (offset1 == offset2) {
return IR_MUST_ALIAS;
@ -1376,7 +1381,7 @@ static ir_alias ir_check_partial_aliasing(ir_ctx *ctx, ir_ref addr1, ir_ref addr
}
} else if (insn2->op == IR_ADD && IR_IS_CONST_REF(insn2->op2)) {
if (insn2->op1 == addr1) {
uintptr_t offset2 = ctx->ir_base[insn2->op2].val.u64;
uintptr_t offset2 = ctx->ir_base[insn2->op2].val.addr;
uintptr_t size1 = ir_type_size[type1];
return (offset2 < size1) ? IR_MUST_ALIAS : IR_NO_ALIAS;

36
ir.g
View File

@ -33,7 +33,9 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32
# include <unistd.h>
#endif
const unsigned char *yy_buf;
const unsigned char *yy_end;
@ -58,22 +60,32 @@ static ir_strtab op_tab;
((ir_ref)0xc0000000 - (ref))
static ir_ref ir_use_var(ir_parser_ctx *p, uint32_t n, const char *str, size_t len) {
ir_ref ref = ir_strtab_find(&p->var_tab, str, len);
ir_ref ref;
uint32_t len32;
IR_ASSERT(len <= 0xffffffff);
len32 = (uint32_t)len;
ref = ir_strtab_find(&p->var_tab, str, len32);
if (!ref) {
p->undef_count++;
/* create a linked list of unresolved references with header in "var_tab" */
ref = IR_UNUSED; /* list terminator */
ir_strtab_lookup(&p->var_tab, str, len, IR_ENCODE_UNRESOLVED_REF(p->ctx->insns_count, n));
ir_strtab_lookup(&p->var_tab, str, len32, IR_ENCODE_UNRESOLVED_REF(p->ctx->insns_count, n));
} else if (IR_IS_UNRESOLVED(ref)) {
/* keep the linked list of unresolved references with header in "var_tab" */
/* "ref" keeps the tail of the list */
ir_strtab_update(&p->var_tab, str, len, IR_ENCODE_UNRESOLVED_REF(p->ctx->insns_count, n));
ir_strtab_update(&p->var_tab, str, len32, IR_ENCODE_UNRESOLVED_REF(p->ctx->insns_count, n));
}
return ref;
}
static void ir_define_var(ir_parser_ctx *p, const char *str, size_t len, ir_ref ref) {
ir_ref old_ref = ir_strtab_lookup(&p->var_tab, str, len, ref);
ir_ref old_ref;
uint32_t len32;
IR_ASSERT(len <= 0xffffffff);
len32 = (uint32_t)len;
old_ref = ir_strtab_lookup(&p->var_tab, str, len32, ref);
if (ref != old_ref) {
if (IR_IS_UNRESOLVED(old_ref)) {
p->undef_count--;
@ -83,9 +95,9 @@ static void ir_define_var(ir_parser_ctx *p, const char *str, size_t len, ir_ref
old_ref = *ptr;
*ptr = ref;
} while (old_ref != IR_UNUSED);
ir_strtab_update(&p->var_tab, str, len, ref);
ir_strtab_update(&p->var_tab, str, len32, ref);
} else {
fprintf(stderr, "ERROR: Redefined variable `%*s` on line %d\n", (int)len, str, yy_line);
fprintf(stderr, "ERROR: Redefined variable `%*s` on line %d\n", (int)len32, str, yy_line);
exit(2);
}
}
@ -241,7 +253,8 @@ type(uint8_t *t):
{size_t len;}
{ir_ref ref;}
ID(&str, &len)
{ref = ir_strtab_find(&type_tab, str, len);}
{IR_ASSERT(len <= 0xffffffff);}
{ref = ir_strtab_find(&type_tab, str, (uint32_t)len);}
{if (!ref) yy_error("invalid type");}
{*t = ref;}
;
@ -251,7 +264,8 @@ func(uint8_t *op):
{size_t len;}
{ir_ref ref;}
ID(&str, &len)
{ref = ir_strtab_find(&op_tab, str, len);}
{IR_ASSERT(len <= 0xffffffff);}
{ref = ir_strtab_find(&op_tab, str, (uint32_t)len);}
{if (!ref) yy_error("invalid op");}
{*op = ref - 1;}
;
@ -270,7 +284,7 @@ val(ir_parser_ctx *p, uint8_t op, uint32_t n, ir_ref *ref):
| DECNUMBER(IR_I32, &val)
{if (kind != IR_OPND_NUM && kind != IR_OPND_PROB) yy_error("unexpected number");}
{if (val.i64 < 0 || val.i64 > 0x7fffffff) yy_error("number out of range");}
{*ref = val.u64;}
{*ref = val.i32;}
| "null"
{*ref = IR_UNUSED;}
)
@ -388,12 +402,12 @@ void ir_loader_init(void)
ir_strtab_init(&type_tab, IR_LAST_OP, 0);
for (i = 1; i < IR_LAST_TYPE; i++) {
ir_strtab_lookup(&type_tab, ir_type_cname[i], strlen(ir_type_cname[i]), i);
ir_strtab_lookup(&type_tab, ir_type_cname[i], (uint32_t)strlen(ir_type_cname[i]), i);
}
ir_strtab_init(&op_tab, IR_LAST_OP, 0);
for (i = 0; i < IR_LAST_OP; i++) {
ir_strtab_lookup(&op_tab, ir_op_name[i], strlen(ir_op_name[i]), i + 1);
ir_strtab_lookup(&op_tab, ir_op_name[i], (uint32_t)strlen(ir_op_name[i]), i + 1);
}
}

View File

@ -3775,7 +3775,7 @@ static void ir_emit_call(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) {
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.addr));
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32));
} else {
addr = (void*)addr_insn->val.addr;
}
@ -3852,7 +3852,7 @@ static void ir_emit_tailcall(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) {
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.addr));
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32));
} else {
addr = (void*)addr_insn->val.addr;
}
@ -4232,7 +4232,7 @@ static void ir_emit_exitcall(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) {
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.addr));
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32));
} else {
addr = (void*)addr_insn->val.addr;
}
@ -5186,7 +5186,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
}
} else if (insn->op == IR_STR) {
int label = ctx->cfg_blocks_count + i;
const char *str = ir_get_str(ctx, insn->val.addr);
const char *str = ir_get_str(ctx, insn->val.i32);
int i = 0;
if (!data.rodata_label) {

View File

@ -241,7 +241,7 @@ static void *ir_jmp_addr(ir_ctx *ctx, ir_insn *insn, ir_insn *addr_insn)
IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) {
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.addr));
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32));
} else {
IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR);
addr = (void*)addr_insn->val.addr;

View File

@ -525,7 +525,7 @@ static void ir_emit_call(ir_ctx *ctx, FILE *f, ir_ref def, ir_insn *insn)
ir_emit_def_ref(ctx, f, def);
}
if (IR_IS_CONST_REF(insn->op2)) {
fprintf(f, "%s", ir_get_str(ctx, ctx->ir_base[insn->op2].val.addr));
fprintf(f, "%s", ir_get_str(ctx, ctx->ir_base[insn->op2].val.i32));
} else {
ir_emit_ref(ctx, f, insn->op2);
}
@ -548,7 +548,7 @@ static void ir_emit_tailcall(ir_ctx *ctx, FILE *f, ir_insn *insn)
fprintf(f, "\treturn ");
}
if (IR_IS_CONST_REF(insn->op2)) {
fprintf(f, "%s", ir_get_str(ctx, ctx->ir_base[insn->op2].val.addr));
fprintf(f, "%s", ir_get_str(ctx, ctx->ir_base[insn->op2].val.i32));
} else {
ir_emit_ref(ctx, f, insn->op2);
}

View File

@ -666,7 +666,7 @@ restart:
while (ref != IR_TRUE) {
_xlat[ref] = ref;
if (new_insn->op == IR_FUNC || new_insn->op == IR_STR) {
new_insn->val.addr = ir_str(&new_ctx, ir_get_str(ctx, new_insn->val.addr));
new_insn->val.addr = ir_str(&new_ctx, ir_get_str(ctx, new_insn->val.i32));
}
new_insn++;
ref++;
@ -682,7 +682,7 @@ restart:
new_insn->optx = insn->optx;
new_insn->prev_const = 0;
if (insn->op == IR_FUNC || insn->op == IR_STR) {
new_insn->val.addr = ir_str(&new_ctx, ir_get_str(ctx, insn->val.addr));
new_insn->val.addr = ir_str(&new_ctx, ir_get_str(ctx, insn->val.i32));
} else {
new_insn->val.u64 = insn->val.u64;
}

View File

@ -42,22 +42,32 @@ static ir_strtab op_tab;
((ir_ref)0xc0000000 - (ref))
static ir_ref ir_use_var(ir_parser_ctx *p, uint32_t n, const char *str, size_t len) {
ir_ref ref = ir_strtab_find(&p->var_tab, str, len);
ir_ref ref;
uint32_t len32;
IR_ASSERT(len <= 0xffffffff);
len32 = (uint32_t)len;
ref = ir_strtab_find(&p->var_tab, str, len32);
if (!ref) {
p->undef_count++;
/* create a linked list of unresolved references with header in "var_tab" */
ref = IR_UNUSED; /* list terminator */
ir_strtab_lookup(&p->var_tab, str, len, IR_ENCODE_UNRESOLVED_REF(p->ctx->insns_count, n));
ir_strtab_lookup(&p->var_tab, str, len32, IR_ENCODE_UNRESOLVED_REF(p->ctx->insns_count, n));
} else if (IR_IS_UNRESOLVED(ref)) {
/* keep the linked list of unresolved references with header in "var_tab" */
/* "ref" keeps the tail of the list */
ir_strtab_update(&p->var_tab, str, len, IR_ENCODE_UNRESOLVED_REF(p->ctx->insns_count, n));
ir_strtab_update(&p->var_tab, str, len32, IR_ENCODE_UNRESOLVED_REF(p->ctx->insns_count, n));
}
return ref;
}
static void ir_define_var(ir_parser_ctx *p, const char *str, size_t len, ir_ref ref) {
ir_ref old_ref = ir_strtab_lookup(&p->var_tab, str, len, ref);
ir_ref old_ref;
uint32_t len32;
IR_ASSERT(len <= 0xffffffff);
len32 = (uint32_t)len;
old_ref = ir_strtab_lookup(&p->var_tab, str, len32, ref);
if (ref != old_ref) {
if (IR_IS_UNRESOLVED(old_ref)) {
p->undef_count--;
@ -67,9 +77,9 @@ static void ir_define_var(ir_parser_ctx *p, const char *str, size_t len, ir_ref
old_ref = *ptr;
*ptr = ref;
} while (old_ref != IR_UNUSED);
ir_strtab_update(&p->var_tab, str, len, ref);
ir_strtab_update(&p->var_tab, str, len32, ref);
} else {
fprintf(stderr, "ERROR: Redefined variable `%*s` on line %d\n", (int)len, str, yy_line);
fprintf(stderr, "ERROR: Redefined variable `%*s` on line %d\n", (int)len32, str, yy_line);
exit(2);
}
}
@ -862,7 +872,8 @@ static int parse_type(int sym, uint8_t *t) {
size_t len;
ir_ref ref;
sym = parse_ID(sym, &str, &len);
ref = ir_strtab_find(&type_tab, str, len);
IR_ASSERT(len <= 0xffffffff);
ref = ir_strtab_find(&type_tab, str, (uint32_t)len);
if (!ref) yy_error("invalid type");
*t = ref;
return sym;
@ -873,7 +884,8 @@ static int parse_func(int sym, uint8_t *op) {
size_t len;
ir_ref ref;
sym = parse_ID(sym, &str, &len);
ref = ir_strtab_find(&op_tab, str, len);
IR_ASSERT(len <= 0xffffffff);
ref = ir_strtab_find(&op_tab, str, (uint32_t)len);
if (!ref) yy_error("invalid op");
*op = ref - 1;
return sym;
@ -896,7 +908,7 @@ static int parse_val(int sym, ir_parser_ctx *p, uint8_t op, uint32_t n, ir_ref *
sym = parse_DECNUMBER(sym, IR_I32, &val);
if (kind != IR_OPND_NUM && kind != IR_OPND_PROB) yy_error("unexpected number");
if (val.i64 < 0 || val.i64 > 0x7fffffff) yy_error("number out of range");
*ref = val.u64;
*ref = val.i32;
} else if (sym == YY_NULL) {
sym = get_sym();
*ref = IR_UNUSED;
@ -1049,12 +1061,12 @@ void ir_loader_init(void)
ir_strtab_init(&type_tab, IR_LAST_OP, 0);
for (i = 1; i < IR_LAST_TYPE; i++) {
ir_strtab_lookup(&type_tab, ir_type_cname[i], strlen(ir_type_cname[i]), i);
ir_strtab_lookup(&type_tab, ir_type_cname[i], (uint32_t)strlen(ir_type_cname[i]), i);
}
ir_strtab_init(&op_tab, IR_LAST_OP, 0);
for (i = 0; i < IR_LAST_OP; i++) {
ir_strtab_lookup(&op_tab, ir_op_name[i], strlen(ir_op_name[i]), i + 1);
ir_strtab_lookup(&op_tab, ir_op_name[i], (uint32_t)strlen(ir_op_name[i]), i + 1);
}
}

View File

@ -139,14 +139,10 @@ IR_ALWAYS_INLINE uint32_t ir_ntzl(uint64_t num)
{
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl))
return __builtin_ctzl(num);
#elif defined(_WIN32)
#elif defined(_WIN64)
unsigned long index;
#if defined(_WIN64)
if (!_BitScanForward64(&index, num)) {
#else
if (!_BitScanForward(&index, num)) {
#endif
/* undefined behavior */
return 64;
}
@ -155,15 +151,15 @@ IR_ALWAYS_INLINE uint32_t ir_ntzl(uint64_t num)
#else
uint32_t n;
if (num == Z_UL(0)) return 64;
if (num == 0) return 64;
n = 1;
if ((num & 0xffffffff) == 0) {n += 32; num = num >> Z_UL(32);}
if ((num & 0xffffffff) == 0) {n += 32; num = num >> 32;}
if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;}
if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;}
if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;}
if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;}
return n - (num & 1);
return n - (uint32_t)(num & 1);
#endif
}
@ -199,14 +195,10 @@ IR_ALWAYS_INLINE int ir_nlzl(uint64_t num)
{
#if (defined(__GNUC__) || __has_builtin(__builtin_clzll))
return __builtin_clzll(num);
#elif defined(_WIN32)
uint32_t index;
#elif defined(_WIN64)
unsigned long index;
#if defined(_WIN64)
if (!_BitScanReverse64(&index, num)) {
#else
if (!_BitScanReverse(&index, num)) {
#endif
/* undefined behavior */
return 64;
}
@ -214,7 +206,7 @@ IR_ALWAYS_INLINE int ir_nlzl(uint64_t num)
return (int) (64 - 1) - index;
#else
uint64_t x;
uint64_t n;
uint32_t n;
n = 64;
x = num >> 32; if (x != 0) {n -= 32; num = x;}
@ -223,7 +215,7 @@ IR_ALWAYS_INLINE int ir_nlzl(uint64_t num)
x = num >> 4; if (x != 0) {n -= 4; num = x;}
x = num >> 2; if (x != 0) {n -= 2; num = x;}
x = num >> 1; if (x != 0) return n - 2;
return n - num;
return n - (uint32_t)num;
#endif
}

View File

@ -814,8 +814,8 @@ static bool ir_try_coalesce(ir_ctx *ctx, ir_live_range **unused, ir_ref from, ir
uint32_t v2 = ctx->vregs[to];
if (v1 != v2 && !ir_vregs_overlap(ctx, v1, v2)) {
uint8_t f1 = ctx->live_intervals[v1]->flags;
uint8_t f2 = ctx->live_intervals[v2]->flags;
uint16_t f1 = ctx->live_intervals[v1]->flags;
uint16_t f2 = ctx->live_intervals[v2]->flags;
if ((f1 & IR_LIVE_INTERVAL_COALESCED) && !(f2 & IR_LIVE_INTERVAL_COALESCED)) {
ir_vregs_join(ctx, unused, v1, v2);

View File

@ -20,9 +20,9 @@ void ir_save(ir_ctx *ctx, FILE *f)
fprintf(f, "\t%s c_%d = ", ir_type_cname[insn->type], i);
if (insn->op == IR_FUNC) {
if (!insn->const_flags) {
fprintf(f, "func(%s)", ir_get_str(ctx, insn->val.addr));
fprintf(f, "func(%s)", ir_get_str(ctx, insn->val.i32));
} else {
fprintf(f, "func(%s, %d)", ir_get_str(ctx, insn->val.addr), insn->const_flags);
fprintf(f, "func(%s, %d)", ir_get_str(ctx, insn->val.i32), insn->const_flags);
}
} else if (insn->op == IR_FUNC_ADDR) {
fprintf(f, "func_addr(");

View File

@ -2852,12 +2852,14 @@ static void ir_emit_shift_const(ir_ctx *ctx, ir_ref def, ir_insn *insn)
{
ir_backend_data *data = ctx->data;
dasm_State **Dst = &data->dasm_state;
uint32_t shift = ctx->ir_base[insn->op2].val.u64;
int32_t shift;
ir_type type = insn->type;
ir_ref op1 = insn->op1;
ir_reg def_reg = IR_REG_NUM(ctx->regs[def][0]);
ir_reg op1_reg = ctx->regs[def][1];
IR_ASSERT(IR_IS_SIGNED_32BIT(ctx->ir_base[insn->op2].val.i64));
shift = ctx->ir_base[insn->op2].val.i32;
IR_ASSERT(def_reg != IR_REG_NONE);
if (op1_reg != IR_REG_NONE && (op1_reg & IR_REG_SPILL_LOAD)) {
@ -2901,10 +2903,12 @@ static void ir_emit_mem_shift_const(ir_ctx *ctx, ir_ref def, ir_insn *insn)
dasm_State **Dst = &data->dasm_state;
ir_insn *op_insn = &ctx->ir_base[insn->op3];
ir_type type = op_insn->type;
uint32_t shift = ctx->ir_base[op_insn->op2].val.u64;
int32_t shift;
ir_reg reg;
int32_t offset = 0;
IR_ASSERT(IR_IS_SIGNED_32BIT(ctx->ir_base[insn->op2].val.i64));
shift = ctx->ir_base[insn->op2].val.i32;
if (insn->op == IR_VSTORE) {
offset = ir_ref_spill_slot(ctx, insn->op2, &reg);
} else if (insn->op == IR_STORE) {
@ -5170,7 +5174,7 @@ static void ir_emit_load_int(ir_ctx *ctx, ir_ref def, ir_insn *insn)
void *addr = (void*)ctx->ir_base[insn->op2].val.addr;
if (sizeof(void*) == 4 || IR_IS_SIGNED_32BIT(addr)) {
int32_t addr32 = (intptr_t)addr;
int32_t addr32 = (int32_t)(intptr_t)addr;
| ASM_REG_MEM_OP mov, type, def_reg, [addr32]
return;
}
@ -5216,7 +5220,7 @@ static void ir_emit_load_fp(ir_ctx *ctx, ir_ref def, ir_insn *insn)
void *addr = (void*)ctx->ir_base[insn->op2].val.addr;
if (sizeof(void*) == 4 || IR_IS_SIGNED_32BIT(addr)) {
int32_t addr32 = (intptr_t)addr;
int32_t addr32 = (int32_t)(intptr_t)addr;
| ASM_FP_REG_MEM_OP movss, movsd, vmovss, vmovsd, type, def_reg, [addr32]
return;
}
@ -5257,7 +5261,7 @@ static void ir_emit_store_int(ir_ctx *ctx, ir_ref ref, ir_insn *insn)
void *addr = (void*)ctx->ir_base[insn->op2].val.addr;
if (sizeof(void*) == 4 || IR_IS_SIGNED_32BIT(addr)) {
int32_t addr32 = (intptr_t)addr;
int32_t addr32 = (int32_t)(intptr_t)addr;
if (IR_IS_CONST_REF(insn->op3) && IR_IS_32BIT(type, val_insn->val)) {
| ASM_MEM_IMM_OP mov, type, [addr32], val_insn->val.i32
} else {
@ -5311,7 +5315,7 @@ static void ir_emit_store_fp(ir_ctx *ctx, ir_ref ref, ir_insn *insn)
void *addr = (void*)ctx->ir_base[insn->op2].val.addr;
if (sizeof(void*) == 4 || IR_IS_SIGNED_32BIT(addr)) {
int32_t addr32 = (intptr_t)addr;
int32_t addr32 = (int32_t)(intptr_t)addr;
| ASM_FP_MEM_REG_OP movss, movsd, vmovss, vmovsd, type, [addr32], op2_reg
return;
}
@ -5558,7 +5562,7 @@ static void ir_emit_switch(ir_ctx *ctx, uint32_t b, ir_ref def, ir_insn *insn)
/* Generate a table jmp or a seqence of calls */
if ((max.i64-min.i64) < count * 8) {
int *labels = ir_mem_malloc(sizeof(int) * (max.i64 - min.i64 + 1));
int *labels = ir_mem_malloc(sizeof(int) * (size_t)(max.i64 - min.i64 + 1));
for (i = 0; i <= (max.i64 - min.i64); i++) {
labels[i] = default_label;
@ -6101,7 +6105,7 @@ static void ir_emit_call(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) {
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.addr));
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32));
} else {
addr = (void*)addr_insn->val.addr;
}
@ -6213,7 +6217,7 @@ static void ir_emit_tailcall(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) {
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.addr));
addr = ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32));
} else {
addr = (void*)addr_insn->val.addr;
}
@ -7869,7 +7873,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
int64_t long_offset = ctx->ir_base[insn->op2].val.i64;
long_offset = -long_offset;
IR_ASSERT(IR_IS_SIGNED_32BIT(long_offset));
offset = long_offset;
offset = (int32_t)long_offset;
}
if (op1_reg & IR_REG_SPILL_LOAD) {
op1_reg &= ~IR_REG_SPILL_LOAD;
@ -8393,7 +8397,7 @@ next_block:;
}
} else if (insn->op == IR_STR) {
int label = ctx->cfg_blocks_count + i;
const char *str = ir_get_str(ctx, insn->val.addr);
const char *str = ir_get_str(ctx, insn->val.i32);
int i = 0;
if (!data.rodata_label) {