From fbedabc5d80ef50d337ac67bec6f19309bd750c3 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jun 2022 10:17:41 +0300 Subject: [PATCH] cleanup --- ir_aarch64.dasc | 5 ++-- ir_x86.dasc | 62 +++++++++++++++++++++---------------------------- 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/ir_aarch64.dasc b/ir_aarch64.dasc index a853a9e..99cd357 100644 --- a/ir_aarch64.dasc +++ b/ir_aarch64.dasc @@ -4366,12 +4366,11 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size) |.align 8 |=>label: |.long insn->val.u32, insn->val.u32_hi - } else if (insn->type == IR_FLOAT) { + } else { + IR_ASSERT(insn->type == IR_FLOAT); |.align 4 |=>label: |.long insn->val.u32 - } else { - IR_ASSERT(0); } } else if (insn->op == IR_STR) { int label = ctx->cfg_blocks_count + i; diff --git a/ir_x86.dasc b/ir_x86.dasc index d15830e..f670d50 100644 --- a/ir_x86.dasc +++ b/ir_x86.dasc @@ -305,22 +305,20 @@ |.endmacro |.macro ASM_SSE2_REG_REG_OP, fop, dop, type, dst, src -|| if (type == IR_FLOAT) { -| fop xmm(dst-IR_REG_FP_FIRST), xmm(src-IR_REG_FP_FIRST) -|| } else if (type == IR_DOUBLE) { +|| if (type == IR_DOUBLE) { | dop xmm(dst-IR_REG_FP_FIRST), xmm(src-IR_REG_FP_FIRST) || } else { -|| IR_ASSERT(0); +|| IR_ASSERT(type == IR_FLOAT); +| fop xmm(dst-IR_REG_FP_FIRST), xmm(src-IR_REG_FP_FIRST) || } |.endmacro |.macro ASM_SSE2_REG_MEM_OP, fop, dop, type, dst, src -|| if (type == IR_FLOAT) { -| fop xmm(dst-IR_REG_FP_FIRST), dword src -|| } else if (type == IR_DOUBLE) { +|| if (type == IR_DOUBLE) { | dop xmm(dst-IR_REG_FP_FIRST), qword src || } else { -|| IR_ASSERT(0); +|| IR_ASSERT(type == IR_FLOAT); +| fop xmm(dst-IR_REG_FP_FIRST), dword src || } |.endmacro @@ -338,22 +336,20 @@ |.endmacro |.macro ASM_AVX_REG_REG_REG_OP, fop, dop, type, dst, op1, op2 -|| if (type == IR_FLOAT) { -| fop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), xmm(op2-IR_REG_FP_FIRST) -|| } else if (type == IR_DOUBLE) { +|| if (type == IR_DOUBLE) { | dop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), xmm(op2-IR_REG_FP_FIRST) || } else { -|| IR_ASSERT(0); +|| IR_ASSERT(type == IR_FLOAT); +| fop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), xmm(op2-IR_REG_FP_FIRST) || } |.endmacro |.macro ASM_AVX_REG_REG_MEM_OP, fop, dop, type, dst, op1, op2 -|| if (type == IR_FLOAT) { -| fop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), dword op2 -|| } else if (type == IR_DOUBLE) { +|| if (type == IR_DOUBLE) { | dop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), qword op2 || } else { -|| IR_ASSERT(0); +|| IR_ASSERT(type == IR_FLOAT); +| fop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), dword op2 || } |.endmacro @@ -379,20 +375,19 @@ |.endmacro |.macro ASM_FP_MEM_REG_OP, fop, dop, avx_fop, avx_dop, type, dst, src -|| if (type == IR_FLOAT) { -|| if (ctx->flags & IR_AVX) { -| avx_fop dword dst, xmm(src-IR_REG_FP_FIRST) -|| } else { -| fop dword dst, xmm(src-IR_REG_FP_FIRST) -|| } -|| } else if (type == IR_DOUBLE) { +|| if (type == IR_DOUBLE) { || if (ctx->flags & IR_AVX) { | avx_dop qword dst, xmm(src-IR_REG_FP_FIRST) || } else { | dop qword dst, xmm(src-IR_REG_FP_FIRST) || } || } else { -|| IR_ASSERT(0); +|| IR_ASSERT(type == IR_FLOAT); +|| if (ctx->flags & IR_AVX) { +| avx_fop dword dst, xmm(src-IR_REG_FP_FIRST) +|| } else { +| fop dword dst, xmm(src-IR_REG_FP_FIRST) +|| } || } |.endmacro @@ -3456,12 +3451,11 @@ static void ir_emit_return_fp(ir_ctx *ctx, ir_reg ref, ir_insn *insn) if (op2_reg == IR_REG_NONE || (op2_reg & IR_REG_SPILL_LOAD)) { int32_t offset = ir_ref_spill_slot(ctx, insn->op2); ir_reg fp = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER; - if (type == IR_FLOAT) { - | fld dword [Ra(fp)+offset] - } else if (type == IR_DOUBLE) { + if (type == IR_DOUBLE) { | fld qword [Ra(fp)+offset] } else { - IR_ASSERT(0); + IR_ASSERT(type == IR_FLOAT); + | fld dword [Ra(fp)+offset] } } else { int32_t offset = (type == IR_FLOAT) ? data->float_ret_slot : data->double_ret_slot; @@ -3471,12 +3465,11 @@ static void ir_emit_return_fp(ir_ctx *ctx, ir_reg ref, ir_insn *insn) offset = IR_SPILL_POS_TO_OFFSET(offset); fp = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER; ir_emit_store_mem_fp(ctx, type, fp, offset, op2_reg); - if (type == IR_FLOAT) { - | fld dword [Ra(fp)+offset] - } else if (type == IR_DOUBLE) { + if (type == IR_DOUBLE) { | fld qword [Ra(fp)+offset] } else { - IR_ASSERT(0); + IR_ASSERT(type == IR_FLOAT); + | fld dword [Ra(fp)+offset] } } #endif @@ -6415,12 +6408,11 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size) |.align 8 |=>label: |.dword insn->val.u32, insn->val.u32_hi - } else if (insn->type == IR_FLOAT) { + } else { + IR_ASSERT(insn->type == IR_FLOAT); |.align 4 |=>label: |.dword insn->val.u32 - } else { - IR_ASSERT(0); } } else if (insn->op == IR_STR) { int label = ctx->cfg_blocks_count + i;