This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
patch frv: misc infrastructure changes
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 5 Oct 2004 16:05:31 -0400
- Subject: patch frv: misc infrastructure changes
Hi folks.
This patch adds some necessary infrastructure changes for the upcoming
TLS work.
First, there is a skeleton legitimize_address. Second, I have rewritten
the move patterns to use one function.
Tested on frv-elf with a simulator.
Committed to mainline.
Aldy
* config/frv/frv.h (LEGITIMIZE_ADDRESS): New.
* config/frv/frv-protos.h (frv_legitimize_address): Protoize.
(frv_emit_move): Same.
* config/frv/frv.c (frv_emit_move): New.
(frv_legitimize_address): New.
* config/frv/frv.md ("movsi"): Call frv_emit_move.
("movqi"): Same.
("movhi"): Same.
("movdi"): Same.
("movsf"): Same.
("movdf"): Same.
Index: config/frv/frv.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.h,v
retrieving revision 1.54
diff -c -p -r1.54 frv.h
*** config/frv/frv.h 9 Sep 2004 06:33:57 -0000 1.54
--- config/frv/frv.h 5 Oct 2004 20:04:19 -0000
*************** __asm__("\n" \
*** 2335,2340 ****
--- 2335,2350 ----
will reload one or both registers only if neither labeling works. */
#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)
+ #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
+ do { \
+ rtx new_x = frv_legitimize_address (X, OLDX, MODE); \
+ if (new_x) \
+ { \
+ (X) = new_x; \
+ goto WIN; \
+ } \
+ } while (0)
+
#define FIND_BASE_TERM frv_find_base_term
/* A C statement or compound statement with a conditional `goto LABEL;'
Index: config/frv/frv-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv-protos.h,v
retrieving revision 1.19
diff -c -p -r1.19 frv-protos.h
*** config/frv/frv-protos.h 9 Sep 2004 06:33:55 -0000 1.19
--- config/frv/frv-protos.h 5 Oct 2004 20:04:19 -0000
*************** extern int frv_initial_elimination_offse
*** 68,73 ****
--- 68,74 ----
#ifdef RTX_CODE
extern int frv_legitimate_address_p (enum machine_mode, rtx,
int, int, int);
+ extern rtx frv_legitimize_address (rtx, rtx, enum machine_mode);
extern rtx frv_find_base_term (rtx);
#ifdef TREE_CODE
*************** extern const char *frv_asm_output_opcode
*** 100,105 ****
--- 101,107 ----
extern void frv_final_prescan_insn (rtx, rtx *, int);
extern void frv_print_operand (FILE *, rtx, int);
extern void frv_print_operand_address (FILE *, rtx);
+ extern void frv_emit_move (enum machine_mode, rtx, rtx);
extern int frv_emit_movsi (rtx, rtx);
extern const char *output_move_single (rtx *, rtx);
extern const char *output_move_double (rtx *, rtx);
Index: config/frv/frv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.c,v
retrieving revision 1.71
diff -c -p -r1.71 frv.c
*** config/frv/frv.c 28 Sep 2004 07:59:52 -0000 1.71
--- config/frv/frv.c 5 Oct 2004 20:04:24 -0000
*************** frv_legitimate_address_p (enum machine_m
*** 3427,3432 ****
--- 3427,3439 ----
return ret;
}
+ rtx
+ frv_legitimize_address (rtx x ATTRIBUTE_UNUSED,
+ rtx oldx ATTRIBUTE_UNUSED,
+ enum machine_mode mode ATTRIBUTE_UNUSED)
+ {
+ return NULL_RTX;
+ }
/* Test whether a local function descriptor is canonical, i.e.,
whether we can use FUNCDESC_GOTOFF to compute the address of the
*************** direct_return_p (void)
*** 5342,5347 ****
--- 5349,5383 ----
}
+ void
+ frv_emit_move (enum machine_mode mode, rtx dest, rtx src)
+ {
+ switch (mode)
+ {
+ case SImode:
+ if (frv_emit_movsi (dest, src))
+ return;
+ break;
+
+ case QImode:
+ case HImode:
+ case DImode:
+ case SFmode:
+ case DFmode:
+ if (!reload_in_progress
+ && !reload_completed
+ && !register_operand (dest, mode)
+ && !reg_or_0_operand (src, mode))
+ src = copy_to_mode_reg (mode, src);
+ break;
+
+ default:
+ abort ();
+ }
+
+ emit_insn (gen_rtx_SET (VOIDmode, dest, src));
+ }
+
/* Emit code to handle a MOVSI, adding in the small data register or pic
register if needed to load up addresses. Return TRUE if the appropriate
instructions are emitted. */
Index: config/frv/frv.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.md,v
retrieving revision 1.23
diff -c -p -r1.23 frv.md
*** config/frv/frv.md 18 Sep 2004 19:19:34 -0000 1.23
--- config/frv/frv.md 5 Oct 2004 20:04:26 -0000
***************
*** 1558,1571 ****
[(set (match_operand:QI 0 "general_operand" "")
(match_operand:QI 1 "general_operand" ""))]
""
! "
! {
! if (!reload_in_progress
! && !reload_completed
! && !register_operand (operands[0], QImode)
! && !reg_or_0_operand (operands[1], QImode))
! operands[1] = copy_to_mode_reg (QImode, operands[1]);
! }")
(define_insn "*movqi_load"
[(set (match_operand:QI 0 "register_operand" "=d,f")
--- 1558,1564 ----
[(set (match_operand:QI 0 "general_operand" "")
(match_operand:QI 1 "general_operand" ""))]
""
! "{ frv_emit_move (QImode, operands[0], operands[1]); DONE; }")
(define_insn "*movqi_load"
[(set (match_operand:QI 0 "register_operand" "=d,f")
***************
*** 1587,1600 ****
[(set (match_operand:HI 0 "general_operand" "")
(match_operand:HI 1 "general_operand" ""))]
""
! "
! {
! if (!reload_in_progress
! && !reload_completed
! && !register_operand (operands[0], HImode)
! && !reg_or_0_operand (operands[1], HImode))
! operands[1] = copy_to_mode_reg (HImode, operands[1]);
! }")
(define_insn "*movhi_load"
[(set (match_operand:HI 0 "register_operand" "=d,f")
--- 1580,1586 ----
[(set (match_operand:HI 0 "general_operand" "")
(match_operand:HI 1 "general_operand" ""))]
""
! "{ frv_emit_move (HImode, operands[0], operands[1]); DONE; }")
(define_insn "*movhi_load"
[(set (match_operand:HI 0 "register_operand" "=d,f")
***************
*** 1645,1655 ****
[(set (match_operand:SI 0 "move_destination_operand" "")
(match_operand:SI 1 "move_source_operand" ""))]
""
! "
! {
! if (frv_emit_movsi (operands[0], operands[1]))
! DONE;
! }")
;; Note - it is best to only have one movsi pattern and to handle
;; all the various contingencies by the use of alternatives. This
--- 1631,1637 ----
[(set (match_operand:SI 0 "move_destination_operand" "")
(match_operand:SI 1 "move_source_operand" ""))]
""
! "{ frv_emit_move (SImode, operands[0], operands[1]); DONE; }")
;; Note - it is best to only have one movsi pattern and to handle
;; all the various contingencies by the use of alternatives. This
***************
*** 1673,1679 ****
;; re-recognize them again after the substitution for memory. So keep
;; a memory constraint available, just make sure reload won't be
;; tempted to use it.
!
(define_insn "*movsi_load"
[(set (match_operand:SI 0 "register_operand" "=d,f")
(match_operand:SI 1 "frv_load_operand" "m,m"))]
--- 1655,1663 ----
;; re-recognize them again after the substitution for memory. So keep
;; a memory constraint available, just make sure reload won't be
;; tempted to use it.
! ;;
!
!
(define_insn "*movsi_load"
[(set (match_operand:SI 0 "register_operand" "=d,f")
(match_operand:SI 1 "frv_load_operand" "m,m"))]
***************
*** 1752,1765 ****
[(set (match_operand:DI 0 "nonimmediate_operand" "")
(match_operand:DI 1 "general_operand" ""))]
""
! "
! {
! if (!reload_in_progress
! && !reload_completed
! && !register_operand (operands[0], DImode)
! && !reg_or_0_operand (operands[1], DImode))
! operands[1] = copy_to_mode_reg (DImode, operands[1]);
! }")
(define_insn "*movdi_double"
[(set (match_operand:DI 0 "move_destination_operand" "=e,?h,??d,??f,R,?R,??m,??m,e,?h,??d,??f,?e,??d,?h,??f,R,m,e,??d,e,??d,?h,??f")
--- 1736,1742 ----
[(set (match_operand:DI 0 "nonimmediate_operand" "")
(match_operand:DI 1 "general_operand" ""))]
""
! "{ frv_emit_move (DImode, operands[0], operands[1]); DONE; }")
(define_insn "*movdi_double"
[(set (match_operand:DI 0 "move_destination_operand" "=e,?h,??d,??f,R,?R,??m,??m,e,?h,??d,??f,?e,??d,?h,??f,R,m,e,??d,e,??d,?h,??f")
***************
*** 1893,1906 ****
[(set (match_operand:SF 0 "general_operand" "")
(match_operand:SF 1 "general_operand" ""))]
""
! "
! {
! if (!reload_in_progress
! && !reload_completed
! && !register_operand (operands[0], SFmode)
! && !reg_or_0_operand (operands[1], SFmode))
! operands[1] = copy_to_mode_reg (SFmode, operands[1]);
! }")
(define_split
[(set (match_operand:SF 0 "integer_register_operand" "")
--- 1870,1876 ----
[(set (match_operand:SF 0 "general_operand" "")
(match_operand:SF 1 "general_operand" ""))]
""
! "{ frv_emit_move (SFmode, operands[0], operands[1]); DONE; }")
(define_split
[(set (match_operand:SF 0 "integer_register_operand" "")
***************
*** 1962,1975 ****
[(set (match_operand:DF 0 "nonimmediate_operand" "")
(match_operand:DF 1 "general_operand" ""))]
""
! "
! {
! if (!reload_in_progress
! && !reload_completed
! && !register_operand (operands[0], DFmode)
! && !reg_or_0_operand (operands[1], DFmode))
! operands[1] = copy_to_mode_reg (DFmode, operands[1]);
! }")
(define_insn "*movdf_double"
[(set (match_operand:DF 0 "move_destination_operand" "=h,?e,??f,??d,R,?R,??m,??m,h,?e,??f,??d,?h,??f,?e,??d,R,m,h,??f,e,??d,e,??d")
--- 1932,1938 ----
[(set (match_operand:DF 0 "nonimmediate_operand" "")
(match_operand:DF 1 "general_operand" ""))]
""
! "{ frv_emit_move (DFmode, operands[0], operands[1]); DONE; }")
(define_insn "*movdf_double"
[(set (match_operand:DF 0 "move_destination_operand" "=h,?e,??f,??d,R,?R,??m,??m,h,?e,??f,??d,?h,??f,?e,??d,R,m,h,??f,e,??d,e,??d")