From 86609dfaeb583640afd96b0311bd88396a3fd816 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 11 Apr 2006 16:43:33 +0000 Subject: [PATCH] Fixed Push with immediate creation enabled Push peephole optimization --- ir/be/ia32/ia32_optimize.c | 6 ++++++ ir/be/ia32/ia32_spec.pl | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ir/be/ia32/ia32_optimize.c b/ir/be/ia32/ia32_optimize.c index 073af411d..68ff39fd7 100644 --- a/ir/be/ia32/ia32_optimize.c +++ b/ir/be/ia32/ia32_optimize.c @@ -440,6 +440,10 @@ static void ia32_create_Push(ir_node *irn, ia32_code_gen_t *cg) { proj_res = new_r_Proj(current_ir_graph, bl, push, get_irn_mode(sp), pn_ia32_Push_stack); proj_M = new_r_Proj(current_ir_graph, bl, push, mode_M, pn_ia32_Push_M); + /* copy a possible constant from the store */ + set_ia32_id_cnst(push, get_ia32_id_cnst(irn)); + set_ia32_immop_type(push, get_ia32_immop_type(irn)); + /* the push must have SP out register */ arch_set_irn_register(cg->arch_env, push, arch_get_irn_register(cg->arch_env, sp)); @@ -554,6 +558,8 @@ void ia32_peephole_optimization(ir_node *irn, void *env) { ia32_optimize_CondJmp(irn, cg); else if (be_is_IncSP(irn)) ia32_optimize_IncSP(irn, cg); + else if (is_ia32_Store(irn)) + ia32_create_Push(irn, cg); } diff --git a/ir/be/ia32/ia32_spec.pl b/ir/be/ia32/ia32_spec.pl index b2016b6a7..102e41c3a 100644 --- a/ir/be/ia32/ia32_spec.pl +++ b/ir/be/ia32/ia32_spec.pl @@ -501,7 +501,18 @@ $comment_string = "/*"; "Push" => { "comment" => "push a gp register on the stack", "reg_req" => { "in" => [ "esp", "gp", "none" ], "out" => [ "esp" ] }, - "emit" => '. push %S2 /* Push(%A2) */', + "emit" => ' +if (get_ia32_id_cnst(n)) { + if (get_ia32_immop_type(n) == ia32_ImmConst) { +. push %C /* Push(%A2) */ + } else { +. push OFFSET FLAT:%C /* Push(%A2) */ + } +} +else { +. push %S2 /* Push(%A2) */ +} +', "outs" => [ "stack", "M" ], }, -- 2.20.1