Commit c00fc5cf by Hans-Peter Nilsson Committed by Hans-Peter Nilsson

Rewrite PIC support to more closely model actual instructions.

	* config/cris/cris-protos.h (cris_gotless_symbol, cris_got_symbol)
	(cris_symbol): Remove prototypes for removed functions.
	(cris_pic_symbol_type_of, cris_valid_pic_const)
	(cris_expand_pic_call_address): Prototypes for new functions.
	* config/cris/cris/cris.c (cris_pic_sympart_only): Remove unused
	variable.
	(cris_print_operand) <case 'v', 'P'>: Remove cases for unused
	modifiers.
	<case ':'>: Add case for new punctuation character.
	<case 'd'>: Temporarily set flag_pic = 2 instead of incorrectly
	emitting (extra) PIC modifier.
	<case UNSPEC>: Do not assert for PLT.
	(cris_initial_frame_pointer_offset, cris_simple_epilogue)
	(cris_expand_prologue, cris_expand_epilogue): Check
	for pic_offset_table_rtx usage instead of taking
	current_function_uses_pic_offset_table as the final word.
	(cris_rtx_costs, cris_address_cost, cris_side_effect_mode_ok):
	Remove flag_pic difference.
	(cris_valid_pic_const, cris_pic_symbol_type_of): New functions,
	the moral equivalents of...
	(cris_symbol, cris_gotless_symbol, cris_got_symbol): Remove
	functions.
	(cris_legitimate_pic_operand): Just call cris_valid_pic_const.
	(cris_handle_option): Mark ARG as unused.
	(cris_expand_pic_call_address): New worker function for "call",
	"call_value".
	(cris_asm_output_symbol_ref, cris_asm_output_label_ref): Do not
	output PIC constructs here.
	(cris_output_addr_const_extra): Changes for emitting PIC modifiers
	as symbol-specific modifers, not whole or part of operands.
	* config/cris/cris/cris.h (EXTRA_CONSTRAINT): Remove 'U' case.
	(EXTRA_CONSTRAINT_S): Changed semantics: allow only CONST-wrapped
	constants and flag_pic.
	(CONSTANT_INDEX_P): Adjust for new functions.
	(enum cris_pic_symbol_type): New helper type.
	(PRINT_OPERAND_PUNCT_VALID_P): Add ':'.
	* config/cris/cris/cris.md (CRIS_UNSPEC_GOTREL)
	(CRIS_UNSPEC_GOTREAD, CRIS_UNSPEC_PLTGOTREAD): New
	define_constants.
	("movsi"): Emit actual instructions for GOT and relative access.
	("*movsi_got_load"): New pattern to set up the register holding
	the GOT pointer.
	("*movsi_internal"): Operand 1 is not a plain general_operand.
	Adjust FIXME for 'S'.
	<output for 'S' alternative>: Sanity-check UNSPEC types for PIC.
	Use "movs" for -fpic cases.
	("addsi3"): Add alternative for 'S'; use adds.w when possible.
	("uminsi3","*expanded_call_value"): Remove 'S' alternative.
	("call", "call_value"): Just call cris_expand_pic_call_address for
	PIC addresses.
	("*expanded_call_no_gotplt", "*expanded_call_value_no_gotplt"):
	Remove special pattern.
	("*expanded_call_side", "*expanded_call_value_side"): New
	patterns.
	(gotplt-to-plt, gotplt-to-plt-side-call)
	(gotplt-to-plt-side-call-value, gotplt-to-plt-side): New
	peephole2:s.
	* config/cris/cris/predicates.md
	("cris_general_operand_or_gotless_symbol"): Remove unused
	predicate.
	("cris_general_operand_or_symbol"): Adjust for new functions.

From-SVN: r101812
parent 68ece23d
2005-07-08 Hans-Peter Nilsson <hp@axis.com>
Rewrite PIC support to more closely model actual instructions.
* config/cris/cris-protos.h (cris_gotless_symbol, cris_got_symbol)
(cris_symbol): Remove prototypes for removed functions.
(cris_pic_symbol_type_of, cris_valid_pic_const)
(cris_expand_pic_call_address): Prototypes for new functions.
* config/cris/cris/cris.c (cris_pic_sympart_only): Remove unused
variable.
(cris_print_operand) <case 'v', 'P'>: Remove cases for unused
modifiers.
<case ':'>: Add case for new punctuation character.
<case 'd'>: Temporarily set flag_pic = 2 instead of incorrectly
emitting (extra) PIC modifier.
<case UNSPEC>: Do not assert for PLT.
(cris_initial_frame_pointer_offset, cris_simple_epilogue)
(cris_expand_prologue, cris_expand_epilogue): Check
for pic_offset_table_rtx usage instead of taking
current_function_uses_pic_offset_table as the final word.
(cris_rtx_costs, cris_address_cost, cris_side_effect_mode_ok):
Remove flag_pic difference.
(cris_valid_pic_const, cris_pic_symbol_type_of): New functions,
the moral equivalents of...
(cris_symbol, cris_gotless_symbol, cris_got_symbol): Remove
functions.
(cris_legitimate_pic_operand): Just call cris_valid_pic_const.
(cris_handle_option): Mark ARG as unused.
(cris_expand_pic_call_address): New worker function for "call",
"call_value".
(cris_asm_output_symbol_ref, cris_asm_output_label_ref): Do not
output PIC constructs here.
(cris_output_addr_const_extra): Changes for emitting PIC modifiers
as symbol-specific modifers, not whole or part of operands.
* config/cris/cris/cris.h (EXTRA_CONSTRAINT): Remove 'U' case.
(EXTRA_CONSTRAINT_S): Changed semantics: allow only CONST-wrapped
constants and flag_pic.
(CONSTANT_INDEX_P): Adjust for new functions.
(enum cris_pic_symbol_type): New helper type.
(PRINT_OPERAND_PUNCT_VALID_P): Add ':'.
* config/cris/cris/cris.md (CRIS_UNSPEC_GOTREL)
(CRIS_UNSPEC_GOTREAD, CRIS_UNSPEC_PLTGOTREAD): New
define_constants.
("movsi"): Emit actual instructions for GOT and relative access.
("*movsi_got_load"): New pattern to set up the register holding
the GOT pointer.
("*movsi_internal"): Operand 1 is not a plain general_operand.
Adjust FIXME for 'S'.
<output for 'S' alternative>: Sanity-check UNSPEC types for PIC.
Use "movs" for -fpic cases.
("addsi3"): Add alternative for 'S'; use adds.w when possible.
("uminsi3","*expanded_call_value"): Remove 'S' alternative.
("call", "call_value"): Just call cris_expand_pic_call_address for
PIC addresses.
("*expanded_call_no_gotplt", "*expanded_call_value_no_gotplt"):
Remove special pattern.
("*expanded_call_side", "*expanded_call_value_side"): New
patterns.
(gotplt-to-plt, gotplt-to-plt-side-call)
(gotplt-to-plt-side-call-value, gotplt-to-plt-side): New
peephole2:s.
* config/cris/cris/predicates.md
("cris_general_operand_or_gotless_symbol"): Remove unused
predicate.
("cris_general_operand_or_symbol"): Adjust for new functions.
2005-07-08 Andrew Pinski <pinskia@physics.uc.edu>
* config/darwin.h (TARGET_C99_FUNCTIONS): Define to 1.
......
......@@ -38,9 +38,8 @@ extern int cris_side_effect_mode_ok (enum rtx_code, rtx *, int, int,
extern rtx cris_return_addr_rtx (int, rtx);
extern rtx cris_split_movdx (rtx *);
extern int cris_legitimate_pic_operand (rtx);
extern int cris_gotless_symbol (rtx);
extern int cris_got_symbol (rtx);
extern int cris_symbol (rtx);
extern enum cris_pic_symbol_type cris_pic_symbol_type_of (rtx);
extern bool cris_valid_pic_const (rtx);
extern bool cris_store_multiple_op_p (rtx);
extern bool cris_movem_load_rest_p (rtx, int);
extern void cris_asm_output_symbol_ref (FILE *, rtx);
......@@ -48,6 +47,7 @@ extern bool cris_output_addr_const_extra (FILE *, rtx);
extern int cris_cfun_uses_pic_table (void);
extern rtx cris_gen_movem_load (rtx, rtx, int);
extern rtx cris_emit_movem_store (rtx, rtx, int, bool);
extern void cris_expand_pic_call_address (rtx *);
#endif /* RTX_CODE */
extern void cris_asm_output_label_ref (FILE *, char *);
extern void cris_target_asm_named_section (const char *, unsigned int, tree);
......
......@@ -634,8 +634,6 @@ enum reg_class
(C) == 'S' ? EXTRA_CONSTRAINT_S (X) : \
/* A three-address addressing-mode? */ \
(C) == 'T' ? EXTRA_CONSTRAINT_T (X) : \
/* A global PIC symbol? */ \
(C) == 'U' ? EXTRA_CONSTRAINT_U (X) : \
0)
#define EXTRA_MEMORY_CONSTRAINT(X, STR) ((X) == 'Q')
......@@ -685,16 +683,9 @@ enum reg_class
&& BIAP_INDEX_P (XEXP (XEXP (X, 0), 0)))))) \
)
/* We're kind of out of constraints, so we use "S" for both gotless
symbols and the GOT-address load. Both must go in a general register
only: for pre-V32, arithmetic is done on the destination. */
/* PIC-constructs for symbols. */
#define EXTRA_CONSTRAINT_S(X) \
(flag_pic \
&& ((CONSTANT_P (X) && cris_gotless_symbol (X)) \
|| (GET_CODE (X) == UNSPEC && XINT ((X), 1) == CRIS_UNSPEC_GOT)))
#define EXTRA_CONSTRAINT_U(X) \
(flag_pic && CONSTANT_P (X) && cris_got_symbol (X))
(flag_pic && GET_CODE (X) == CONST && cris_valid_pic_const (X))
/* Node: Frame Layout */
......@@ -956,7 +947,7 @@ struct cum_args {int regs;};
/* No symbol can be used as an index (or more correct, as a base) together
with a register with PIC; the PIC register must be there. */
#define CONSTANT_INDEX_P(X) \
(CONSTANT_P (X) && !(flag_pic && cris_symbol (X)))
(CONSTANT_P (X) && (!flag_pic || cris_valid_pic_const (X)))
/* True if X is a valid base register. */
#define BASE_P(X) \
......@@ -1003,10 +994,7 @@ struct cum_args {int regs;};
rtx x1, x2; \
if (SIMPLE_ADDRESS_P (X)) \
goto ADDR; \
if (CONSTANT_P (X) \
&& (! flag_pic \
|| cris_gotless_symbol (X) \
|| ! cris_symbol (X))) \
if (CONSTANT_INDEX_P (X)) \
goto ADDR; \
/* Indexed? */ \
if (GET_CODE (X) == PLUS) \
......@@ -1150,6 +1138,17 @@ struct cum_args {int regs;};
/* Node: PIC */
/* Helper type. */
enum cris_pic_symbol_type
{
cris_no_symbol = 0,
cris_got_symbol = 1,
cris_gotrel_symbol = 2,
cris_got_symbol_needing_fixup = 3,
cris_invalid_pic_symbol = 4
};
#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? CRIS_GOT_REGNUM : INVALID_REGNUM)
#define LEGITIMATE_PIC_OPERAND_P(X) cris_legitimate_pic_operand (X)
......@@ -1276,7 +1275,7 @@ struct cum_args {int regs;};
/* For delay-slot handling. */
#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
((CODE) == '#' || (CODE) == '!')
((CODE) == '#' || (CODE) == '!' || (CODE) == ':')
#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
cris_print_operand_address (FILE, ADDR)
......
......@@ -63,8 +63,8 @@
(define_predicate "cris_bdap_const_operand"
(and (match_code "label_ref, symbol_ref, const_int, const_double, const")
(not (and (match_test "flag_pic")
(match_test "cris_symbol (op)")))))
(ior (not (match_test "flag_pic"))
(match_test "cris_valid_pic_const (op)"))))
(define_predicate "cris_simple_address_operand"
(ior (match_operand:SI 0 "register_operand")
......@@ -127,16 +127,6 @@
(ior (match_operand 0 "cris_bdap_operand")
(match_operand 0 "cris_biap_mult_operand")))
;; Since a PIC symbol without a GOT entry is not a general_operand, we
;; have to have a predicate that matches it. We use this in the expanded
;; "movsi" anonymous pattern.
;; FIXME: Can s/special_// when PR 20413 is fixed.
(define_special_predicate "cris_general_operand_or_gotless_symbol"
(ior (match_operand 0 "general_operand")
(and (match_code "const, symbol_ref, label_ref, unspec")
(match_test "cris_gotless_symbol (op)"))))
;; Since with -fPIC, not all symbols are valid PIC symbols or indeed
;; general_operands, we have to have a predicate that matches it for the
;; "movsi" expander.
......@@ -145,7 +135,8 @@
(define_special_predicate "cris_general_operand_or_symbol"
(ior (match_operand 0 "general_operand")
(and (match_code "const, symbol_ref, label_ref")
(match_test "cris_symbol (op)"))))
; The following test is actually just an assertion.
(match_test "cris_pic_symbol_type_of (op) != cris_no_symbol"))))
;; Since a PLT symbol is not a general_operand, we have to have a
;; predicate that matches it when we need it. We use this in the expanded
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment