This commit is contained in:
Dmitry Stogov 2022-06-07 10:17:41 +03:00
parent 1108acf9b8
commit fbedabc5d8
2 changed files with 29 additions and 38 deletions

View File

@ -4366,12 +4366,11 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size)
|.align 8 |.align 8
|=>label: |=>label:
|.long insn->val.u32, insn->val.u32_hi |.long insn->val.u32, insn->val.u32_hi
} else if (insn->type == IR_FLOAT) { } else {
IR_ASSERT(insn->type == IR_FLOAT);
|.align 4 |.align 4
|=>label: |=>label:
|.long insn->val.u32 |.long insn->val.u32
} else {
IR_ASSERT(0);
} }
} else if (insn->op == IR_STR) { } else if (insn->op == IR_STR) {
int label = ctx->cfg_blocks_count + i; int label = ctx->cfg_blocks_count + i;

View File

@ -305,22 +305,20 @@
|.endmacro |.endmacro
|.macro ASM_SSE2_REG_REG_OP, fop, dop, type, dst, src |.macro ASM_SSE2_REG_REG_OP, fop, dop, type, dst, src
|| if (type == IR_FLOAT) { || if (type == IR_DOUBLE) {
| fop xmm(dst-IR_REG_FP_FIRST), xmm(src-IR_REG_FP_FIRST)
|| } else if (type == IR_DOUBLE) {
| dop xmm(dst-IR_REG_FP_FIRST), xmm(src-IR_REG_FP_FIRST) | dop xmm(dst-IR_REG_FP_FIRST), xmm(src-IR_REG_FP_FIRST)
|| } else { || } else {
|| IR_ASSERT(0); || IR_ASSERT(type == IR_FLOAT);
| fop xmm(dst-IR_REG_FP_FIRST), xmm(src-IR_REG_FP_FIRST)
|| } || }
|.endmacro |.endmacro
|.macro ASM_SSE2_REG_MEM_OP, fop, dop, type, dst, src |.macro ASM_SSE2_REG_MEM_OP, fop, dop, type, dst, src
|| if (type == IR_FLOAT) { || if (type == IR_DOUBLE) {
| fop xmm(dst-IR_REG_FP_FIRST), dword src
|| } else if (type == IR_DOUBLE) {
| dop xmm(dst-IR_REG_FP_FIRST), qword src | dop xmm(dst-IR_REG_FP_FIRST), qword src
|| } else { || } else {
|| IR_ASSERT(0); || IR_ASSERT(type == IR_FLOAT);
| fop xmm(dst-IR_REG_FP_FIRST), dword src
|| } || }
|.endmacro |.endmacro
@ -338,22 +336,20 @@
|.endmacro |.endmacro
|.macro ASM_AVX_REG_REG_REG_OP, fop, dop, type, dst, op1, op2 |.macro ASM_AVX_REG_REG_REG_OP, fop, dop, type, dst, op1, op2
|| if (type == IR_FLOAT) { || if (type == IR_DOUBLE) {
| fop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), xmm(op2-IR_REG_FP_FIRST)
|| } else if (type == IR_DOUBLE) {
| dop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), xmm(op2-IR_REG_FP_FIRST) | dop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), xmm(op2-IR_REG_FP_FIRST)
|| } else { || } 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 |.endmacro
|.macro ASM_AVX_REG_REG_MEM_OP, fop, dop, type, dst, op1, op2 |.macro ASM_AVX_REG_REG_MEM_OP, fop, dop, type, dst, op1, op2
|| if (type == IR_FLOAT) { || if (type == IR_DOUBLE) {
| fop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), dword op2
|| } else if (type == IR_DOUBLE) {
| dop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), qword op2 | dop xmm(dst-IR_REG_FP_FIRST), xmm(op1-IR_REG_FP_FIRST), qword op2
|| } else { || } 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 |.endmacro
@ -379,20 +375,19 @@
|.endmacro |.endmacro
|.macro ASM_FP_MEM_REG_OP, fop, dop, avx_fop, avx_dop, type, dst, src |.macro ASM_FP_MEM_REG_OP, fop, dop, avx_fop, avx_dop, type, dst, src
|| if (type == IR_FLOAT) { || if (type == IR_DOUBLE) {
|| 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 (ctx->flags & IR_AVX) { || if (ctx->flags & IR_AVX) {
| avx_dop qword dst, xmm(src-IR_REG_FP_FIRST) | avx_dop qword dst, xmm(src-IR_REG_FP_FIRST)
|| } else { || } else {
| dop qword dst, xmm(src-IR_REG_FP_FIRST) | dop qword dst, xmm(src-IR_REG_FP_FIRST)
|| } || }
|| } else { || } 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 |.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)) { if (op2_reg == IR_REG_NONE || (op2_reg & IR_REG_SPILL_LOAD)) {
int32_t offset = ir_ref_spill_slot(ctx, insn->op2); 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; ir_reg fp = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER;
if (type == IR_FLOAT) { if (type == IR_DOUBLE) {
| fld dword [Ra(fp)+offset]
} else if (type == IR_DOUBLE) {
| fld qword [Ra(fp)+offset] | fld qword [Ra(fp)+offset]
} else { } else {
IR_ASSERT(0); IR_ASSERT(type == IR_FLOAT);
| fld dword [Ra(fp)+offset]
} }
} else { } else {
int32_t offset = (type == IR_FLOAT) ? data->float_ret_slot : data->double_ret_slot; 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); offset = IR_SPILL_POS_TO_OFFSET(offset);
fp = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER; 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); ir_emit_store_mem_fp(ctx, type, fp, offset, op2_reg);
if (type == IR_FLOAT) { if (type == IR_DOUBLE) {
| fld dword [Ra(fp)+offset]
} else if (type == IR_DOUBLE) {
| fld qword [Ra(fp)+offset] | fld qword [Ra(fp)+offset]
} else { } else {
IR_ASSERT(0); IR_ASSERT(type == IR_FLOAT);
| fld dword [Ra(fp)+offset]
} }
} }
#endif #endif
@ -6415,12 +6408,11 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size)
|.align 8 |.align 8
|=>label: |=>label:
|.dword insn->val.u32, insn->val.u32_hi |.dword insn->val.u32, insn->val.u32_hi
} else if (insn->type == IR_FLOAT) { } else {
IR_ASSERT(insn->type == IR_FLOAT);
|.align 4 |.align 4
|=>label: |=>label:
|.dword insn->val.u32 |.dword insn->val.u32
} else {
IR_ASSERT(0);
} }
} else if (insn->op == IR_STR) { } else if (insn->op == IR_STR) {
int label = ctx->cfg_blocks_count + i; int label = ctx->cfg_blocks_count + i;