X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fia32%2Fia32_emitter.c;h=4476029c98adddebe386f668cb811546b01a7862;hb=8694468860fe14808c20e9e246fe1368c097b322;hp=4678e7ef62427b0795441b741555d5ec8c981cb8;hpb=04ca356a8165637c38566714c4293cef2bc9eb32;p=libfirm diff --git a/ir/be/ia32/ia32_emitter.c b/ir/be/ia32/ia32_emitter.c index 4678e7ef6..4476029c9 100644 --- a/ir/be/ia32/ia32_emitter.c +++ b/ir/be/ia32/ia32_emitter.c @@ -359,6 +359,8 @@ const char *ia32_emit_binop(const ir_node *n, ia32_emit_env_t *env) { is_ia32_Store8Bit(n) || \ is_ia32_CondJmp(n) || \ is_ia32_xCondJmp(n) || \ + is_ia32_CmpSet(n) || \ + is_ia32_xCmpSet(n) || \ is_ia32_SwitchJmp(n))) if (! buf) { @@ -963,7 +965,6 @@ static void emit_ia32_x87CondJmp(ir_node *irn, ia32_emit_env_t *env) { snprintf(cmd_buf, SNPRINTF_BUF_LEN, "%s %s", instr, reg); lc_esnprintf(ia32_get_arg_env(), cmnt_buf, SNPRINTF_BUF_LEN, "/* %+F */", irn); IA32_DO_EMIT(irn); -// lc_esnprintf(ia32_get_arg_env(), cmd_buf, SNPRINTF_BUF_LEN, "fnstsw %3D", irn); lc_esnprintf(ia32_get_arg_env(), cmd_buf, SNPRINTF_BUF_LEN, "fnstsw %%ax", irn); snprintf(cmnt_buf, SNPRINTF_BUF_LEN, "/* Store x87 FPU Control Word */"); IA32_DO_EMIT(irn); @@ -974,7 +975,7 @@ static void emit_ia32_x87CondJmp(ir_node *irn, ia32_emit_env_t *env) { finish_CondJmp(F, irn, mode_Is); } -static void emit_ia32_CMov(ir_node *irn, ia32_emit_env_t *env) { +static void CMov_emitter(ir_node *irn, ia32_emit_env_t *env) { FILE *F = env->out; const lc_arg_env_t *arg_env = ia32_get_arg_env(); const char *cmp_suffix = get_cmp_suffix(get_ia32_pncode(irn), ! mode_is_signed(get_irn_mode(get_irn_n(irn, 0)))); @@ -989,7 +990,15 @@ static void emit_ia32_CMov(ir_node *irn, ia32_emit_env_t *env) { /* we have to emit the cmp first, because the destination register */ /* could be one of the compare registers */ - lc_esnprintf(arg_env, cmd_buf, SNPRINTF_BUF_LEN, "cmp %1S, %2S", irn, irn); + if (is_ia32_CmpCMov(irn)) { + lc_esnprintf(arg_env, cmd_buf, SNPRINTF_BUF_LEN, "cmp %1S, %2S", irn, irn); + } + else if (is_ia32_xCmpCMov(irn)) { + lc_esnprintf(arg_env, cmd_buf, SNPRINTF_BUF_LEN, "ucomis%M %1S, %2S", get_irn_n(irn, 0), irn, irn); + } + else { + assert(0 && "unsupported CMov"); + } lc_esnprintf(arg_env, cmnt_buf, SNPRINTF_BUF_LEN, "/* Psi condition */" ); IA32_DO_EMIT(irn); @@ -1017,7 +1026,15 @@ static void emit_ia32_CMov(ir_node *irn, ia32_emit_env_t *env) { IA32_DO_EMIT(irn); } -static void emit_ia32_Set(ir_node *irn, ia32_emit_env_t *env) { +static void emit_ia32_CmpCMov(ir_node *irn, ia32_emit_env_t *env) { + CMov_emitter(irn, env); +} + +static void emit_ia32_xCmpCMov(ir_node *irn, ia32_emit_env_t *env) { + CMov_emitter(irn, env); +} + +static void Set_emitter(ir_node *irn, ia32_emit_env_t *env) { FILE *F = env->out; const lc_arg_env_t *arg_env = ia32_get_arg_env(); const char *cmp_suffix = get_cmp_suffix(get_ia32_pncode(irn), ! mode_is_signed(get_irn_mode(get_irn_n(irn, 0)))); @@ -1036,11 +1053,19 @@ static void emit_ia32_Set(ir_node *irn, ia32_emit_env_t *env) { instr = "sub"; } - lc_esnprintf(arg_env, cmd_buf, SNPRINTF_BUF_LEN, "%s %1D, %1D", instr, irn, irn); + snprintf(cmd_buf, SNPRINTF_BUF_LEN, "%s %%%s, %%%s", instr, arch_register_get_name(out), arch_register_get_name(out)); snprintf(cmnt_buf, SNPRINTF_BUF_LEN, "/* clear target as set modifies only lower 8 bit */"); IA32_DO_EMIT(irn); - lc_esnprintf(arg_env, cmd_buf, SNPRINTF_BUF_LEN, "cmp %1S, %2S", irn, irn); + if (is_ia32_CmpSet(irn)) { + lc_esnprintf(arg_env, cmd_buf, SNPRINTF_BUF_LEN, "cmp %s", ia32_emit_binop(irn, env)); + } + else if (is_ia32_xCmpSet(irn)) { + lc_esnprintf(arg_env, cmd_buf, SNPRINTF_BUF_LEN, "ucomis%M %s", get_irn_n(irn, 0), ia32_emit_binop(irn, env)); + } + else { + assert(0 && "unsupported Set"); + } snprintf(cmnt_buf, SNPRINTF_BUF_LEN, "/* calculate Psi condition */" ); IA32_DO_EMIT(irn); @@ -1049,6 +1074,14 @@ static void emit_ia32_Set(ir_node *irn, ia32_emit_env_t *env) { IA32_DO_EMIT(irn); } +static void emit_ia32_CmpSet(ir_node *irn, ia32_emit_env_t *env) { + Set_emitter(irn, env); +} + +static void emit_ia32_xCmpSet(ir_node *irn, ia32_emit_env_t *env) { + Set_emitter(irn, env); +} + static void emit_ia32_xCmp(ir_node *irn, ia32_emit_env_t *env) { FILE *F = env->out; const lc_arg_env_t *arg_env = ia32_get_arg_env(); @@ -1083,11 +1116,11 @@ static void emit_ia32_xCmp(ir_node *irn, ia32_emit_env_t *env) { break; } + assert(sse_pnc >= 0 && "unsupported floating point compare"); + lc_esnprintf(arg_env, cmd_buf, SNPRINTF_BUF_LEN, "cmps%M %s, %d", irn, ia32_emit_binop(irn, env), sse_pnc); lc_esnprintf(arg_env, cmnt_buf, SNPRINTF_BUF_LEN, "/* SSE compare with result in %1D */", irn); IA32_DO_EMIT(irn); - - assert(sse_pnc >= 0 && "unsupported floating point compare"); } /********************************************************* @@ -1673,8 +1706,8 @@ static void ia32_register_emitters(void) { IA32_EMIT(TestJmp); IA32_EMIT(CJmp); IA32_EMIT(CJmpAM); - IA32_EMIT(CMov); - IA32_EMIT(Set); + IA32_EMIT(CmpCMov); + IA32_EMIT(CmpSet); IA32_EMIT(SwitchJmp); IA32_EMIT(CopyB); IA32_EMIT(CopyB_i); @@ -1685,6 +1718,8 @@ static void ia32_register_emitters(void) { IA32_EMIT(Conv_I2I8Bit); IA32_EMIT(Const); IA32_EMIT(xCmp); + IA32_EMIT(xCmpSet); + IA32_EMIT(xCmpCMov); IA32_EMIT2(fcomJmp, x87CondJmp); IA32_EMIT2(fcompJmp, x87CondJmp); IA32_EMIT2(fcomppJmp, x87CondJmp);