[committed] mips.md macroisation (13/n)
Richard Sandiford
rsandifo@redhat.com
Tue Aug 24 20:01:00 GMT 2004
Part 13 of the mips.md macroisation process. This patch handles indirect
and table jumps. It gets rid of some lingering Pmode != ptr_mode code and
removes the MIPS16 tablejump insns in favour of a call to expand_binop.
Bootstrapped & regression tested on mips-sgi-irix6.5. Also compared
the gcc.c-torture and gcc.dg output of -O2 -mips16 before and after
the patch, no changes. Applied to head.
Richard
* config/mips/mips.md (indirect_jump): Use force_reg. Adjust names
of internal patterns.
(indirect_jump[sd]i): Renamed from indirect_jump_internal[12].
Redefine using :P.
(tablejump): Use expand_binop to calculate address. Adjust names
of internal patterns.
(tablejump[sd]i): Renamed from tablejump_internal[12].
Redefine using :P.
(tablejump_mips16[12]): Delete.
Index: config/mips/mips.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.md,v
retrieving revision 1.283
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.283 mips.md
*** config/mips/mips.md 24 Aug 2004 19:39:00 -0000 1.283
--- config/mips/mips.md 24 Aug 2004 19:40:11 -0000
*************** (define_expand "indirect_jump"
*** 5484,5516 ****
[(set (pc) (match_operand 0 "register_operand"))]
""
{
! rtx dest;
!
! dest = operands[0];
! if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode)
! operands[0] = copy_to_mode_reg (Pmode, dest);
!
! if (!(Pmode == DImode))
! emit_jump_insn (gen_indirect_jump_internal1 (operands[0]));
else
! emit_jump_insn (gen_indirect_jump_internal2 (operands[0]));
!
DONE;
})
! (define_insn "indirect_jump_internal1"
! [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
! "!(Pmode == DImode)"
! "%*j\t%0%/"
! [(set_attr "type" "jump")
! (set_attr "mode" "none")])
!
! (define_insn "indirect_jump_internal2"
! [(set (pc) (match_operand:DI 0 "register_operand" "d"))]
! "Pmode == DImode"
"%*j\t%0%/"
! [(set_attr "type" "jump")
! (set_attr "mode" "none")])
(define_expand "tablejump"
[(set (pc)
--- 5484,5503 ----
[(set (pc) (match_operand 0 "register_operand"))]
""
{
! operands[0] = force_reg (Pmode, operands[0]);
! if (Pmode == SImode)
! emit_jump_insn (gen_indirect_jumpsi (operands[0]));
else
! emit_jump_insn (gen_indirect_jumpdi (operands[0]));
DONE;
})
! (define_insn "indirect_jump<mode>"
! [(set (pc) (match_operand:P 0 "register_operand" "d"))]
! ""
"%*j\t%0%/"
! [(set_attr "type" "jump")
! (set_attr "mode" "none")])
(define_expand "tablejump"
[(set (pc)
*************** (define_expand "tablejump"
*** 5519,5599 ****
""
{
if (TARGET_MIPS16)
! {
! if (GET_MODE (operands[0]) != HImode)
! abort ();
! if (!(Pmode == DImode))
! emit_insn (gen_tablejump_mips161 (operands[0], operands[1]));
! else
! emit_insn (gen_tablejump_mips162 (operands[0], operands[1]));
! DONE;
! }
!
! if (GET_MODE (operands[0]) != ptr_mode)
! abort ();
!
! if (TARGET_GPWORD)
! operands[0] = expand_binop (ptr_mode, add_optab, operands[0],
pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
if (Pmode == SImode)
! emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
else
! emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
DONE;
})
! (define_insn "tablejump_internal1"
[(set (pc)
! (match_operand:SI 0 "register_operand" "d"))
(use (label_ref (match_operand 1 "" "")))]
""
"%*j\t%0%/"
! [(set_attr "type" "jump")
! (set_attr "mode" "none")])
!
! (define_insn "tablejump_internal2"
! [(set (pc)
! (match_operand:DI 0 "register_operand" "d"))
! (use (label_ref (match_operand 1 "" "")))]
! "TARGET_64BIT"
! "%*j\t%0%/"
! [(set_attr "type" "jump")
! (set_attr "mode" "none")])
!
! (define_expand "tablejump_mips161"
! [(set (pc) (plus:SI (sign_extend:SI (match_operand:HI 0 "register_operand"))
! (label_ref:SI (match_operand 1 ""))))]
! "TARGET_MIPS16 && !(Pmode == DImode)"
! {
! rtx t1, t2, t3;
!
! t1 = gen_reg_rtx (SImode);
! t2 = gen_reg_rtx (SImode);
! t3 = gen_reg_rtx (SImode);
! emit_insn (gen_extendhisi2 (t1, operands[0]));
! emit_move_insn (t2, gen_rtx_LABEL_REF (SImode, operands[1]));
! emit_insn (gen_addsi3 (t3, t1, t2));
! emit_jump_insn (gen_tablejump_internal1 (t3, operands[1]));
! DONE;
! })
!
! (define_expand "tablejump_mips162"
! [(set (pc) (plus:DI (sign_extend:DI (match_operand:HI 0 "register_operand"))
! (label_ref:DI (match_operand 1 ""))))]
! "TARGET_MIPS16 && Pmode == DImode"
! {
! rtx t1, t2, t3;
!
! t1 = gen_reg_rtx (DImode);
! t2 = gen_reg_rtx (DImode);
! t3 = gen_reg_rtx (DImode);
! emit_insn (gen_extendhidi2 (t1, operands[0]));
! emit_move_insn (t2, gen_rtx_LABEL_REF (DImode, operands[1]));
! emit_insn (gen_adddi3 (t3, t1, t2));
! emit_jump_insn (gen_tablejump_internal2 (t3, operands[1]));
! DONE;
! })
;; For TARGET_ABICALLS, we save the gp in the jmp_buf as well.
;; While it is possible to either pull it off the stack (in the
--- 5506,5534 ----
""
{
if (TARGET_MIPS16)
! operands[0] = expand_binop (Pmode, add_optab,
! convert_to_mode (Pmode, operands[0], false),
! gen_rtx_LABEL_REF (Pmode, operands[1]),
! 0, 0, OPTAB_WIDEN);
! else if (TARGET_GPWORD)
! operands[0] = expand_binop (Pmode, add_optab, operands[0],
pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
if (Pmode == SImode)
! emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
else
! emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
DONE;
})
! (define_insn "tablejump<mode>"
[(set (pc)
! (match_operand:P 0 "register_operand" "d"))
(use (label_ref (match_operand 1 "" "")))]
""
"%*j\t%0%/"
! [(set_attr "type" "jump")
! (set_attr "mode" "none")])
;; For TARGET_ABICALLS, we save the gp in the jmp_buf as well.
;; While it is possible to either pull it off the stack (in the
More information about the Gcc-patches
mailing list