From: yu.dongliang <18588496441@163.com> Date: Mon, 11 Nov 2024 07:53:22 +0000 (+0800) Subject: fix: scf_inst_data_same() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;ds=sidebyside;p=scf.git fix: scf_inst_data_same() --- diff --git a/examples/coroutine_fmt.c b/examples/coroutine_fmt.c new file mode 100644 index 0000000..fa24b04 --- /dev/null +++ b/examples/coroutine_fmt.c @@ -0,0 +1,13 @@ +int printf(const char* fmt, ...); + +int scf_async(uintptr_t funcptr, const char* fmt, ...) +{ + printf("fmt: %s\n", fmt); + return 0; +} + +int main() +{ + async printf("hello world, %d\n", 1, 2, 3, 4, 5, 6, 7, 8); + return 0; +} diff --git a/native/scf_native.h b/native/scf_native.h index 74f68ae..f095717 100644 --- a/native/scf_native.h +++ b/native/scf_native.h @@ -6,7 +6,8 @@ typedef struct scf_native_ops_s scf_native_ops_t; -struct scf_register_s { +struct scf_register_s +{ uint32_t id; int bytes; char* name; @@ -18,8 +19,10 @@ struct scf_register_s { uint32_t updated; uint32_t used; }; +#define SCF_COLOR_CONFLICT(c0, c1) ((c0) >> 16 == (c1) >> 16 && (c0) & (c1) & 0xffff) -struct scf_OpCode_s { +struct scf_OpCode_s +{ int type; char* name; }; @@ -34,7 +37,6 @@ typedef struct { } scf_sib_t; typedef struct { - scf_register_t* base; scf_register_t* index; int scale; @@ -47,7 +49,6 @@ typedef struct { } scf_inst_data_t; typedef struct { - scf_3ac_code_t* c; scf_OpCode_t* OpCode; @@ -244,14 +245,20 @@ static inline int scf_inst_data_same(scf_inst_data_t* id0, scf_inst_data_t* id1) if ((id0->flag && !id0->base) || (id1->flag && !id1->base)) return 0; - if (id0->base == id1->base - && id0->scale == id1->scale - && id0->index == id1->index + if (id0->scale == id1->scale && id0->disp == id1->disp && id0->flag == id1->flag && id0->imm == id1->imm - && id0->imm_size == id1->imm_size) - return 1; + && id0->imm_size == id1->imm_size) { + + if (id0->base == id1->base + || (id0->base && id1->base && SCF_COLOR_CONFLICT(id0->base->color, id1->base->color))) { + + if (id0->index == id1->index + || (id0->index && id1->index && SCF_COLOR_CONFLICT(id0->index->color, id1->index->color))) + return 1; + } + } return 0; } diff --git a/native/x64/scf_x64.c b/native/x64/scf_x64.c index 42cd47f..5ebd062 100644 --- a/native/x64/scf_x64.c +++ b/native/x64/scf_x64.c @@ -1091,7 +1091,7 @@ int _scf_x64_select_inst(scf_native_t* ctx) return ret; } } -#if 0 +#if 1 if (x64_optimize_peephole(ctx, f) < 0) { scf_loge("\n"); return -1;