• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision2c5d8f7b95da577e030a8d61c81c0550887d28c4 (tree)
Time2022-11-25 21:00:18
AuthorYoshinori Sato <yo-satoh@sios...>
CommiterYoshinori Sato

Log Message

Merge branch 'rx-pic' into rx-fdpic

Change Summary

Incremental Difference

--- a/gcc/config/rx/rx-protos.h
+++ b/gcc/config/rx/rx-protos.h
@@ -172,6 +172,7 @@ rx_find_use_of_reg (rtx reg, rtx_insn* insn, F stepfunc)
172172 #endif
173173
174174 bool nonpic_symbol_mentioned_p (rtx x);
175-void rx_expand_sym_label2reg (rtx reg, rtx sym, rtx lab, bool sibcall_p);
175+rtx legitimize_pic_address (rtx orig,
176+ machine_mode mode ATTRIBUTE_UNUSED, rtx reg);
176177
177178 #endif /* GCC_RX_PROTOS_H */
--- a/gcc/config/rx/rx.cc
+++ b/gcc/config/rx/rx.cc
@@ -143,11 +143,9 @@ rx_pid_data_operand (rtx op)
143143 return PID_NOT_PID;
144144 }
145145
146-rtx
147-legitimize_pic_address (rtx orig, machine_mode mode ATTRIBUTE_UNUSED, rtx reg);
148-
149146 static rtx
150-rx_legitimize_address (rtx x, rtx oldx ,
147+rx_legitimize_address (rtx x,
148+ rtx oldx ATTRIBUTE_UNUSED,
151149 machine_mode mode ATTRIBUTE_UNUSED)
152150 {
153151 if (flag_pic)
@@ -168,6 +166,32 @@ rx_legitimize_address (rtx x, rtx oldx ,
168166 return x;
169167 }
170168
169+/* Convert a non-PIC address in `orig' to a PIC address using @GOT or
170+ @GOTOFF in `reg'. */
171+rtx
172+legitimize_pic_address (rtx orig, machine_mode mode ATTRIBUTE_UNUSED, rtx reg)
173+{
174+ if (GET_CODE (orig) == LABEL_REF || GET_CODE (orig) == SYMBOL_REF)
175+ {
176+ if (reg == NULL_RTX)
177+ reg = gen_reg_rtx (Pmode);
178+
179+ emit_insn (gen_symGOTOFF2reg (reg, orig));
180+ crtl->uses_pic_offset_table = 1;
181+ return reg;
182+ }
183+ else if (GET_CODE (orig) == SYMBOL_REF)
184+ {
185+ if (reg == NULL_RTX)
186+ reg = gen_reg_rtx (Pmode);
187+
188+ emit_insn (gen_symGOT2reg (reg, orig));
189+ crtl->uses_pic_offset_table = 1;
190+ return reg;
191+ }
192+ return orig;
193+}
194+
171195 /* Return true if OP is a reference to an object in a small data area. */
172196
173197 static bool
@@ -303,44 +327,18 @@ nonpic_symbol_mentioned_p (rtx x)
303327 for (int i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
304328 {
305329 if (fmt[i] == 'E')
306- {
330+ {
307331 for (int j = XVECLEN (x, i) - 1; j >= 0; j--)
308332 if (nonpic_symbol_mentioned_p (XVECEXP (x, i, j)))
309333 return true;
310- }
334+ }
311335 else if (fmt[i] == 'e' && nonpic_symbol_mentioned_p (XEXP (x, i)))
312- return true;
336+ return true;
313337 }
314338
315339 return false;
316340 }
317341
318-/* Convert a non-PIC address in `orig' to a PIC address using @GOT or
319- @GOTOFF in `reg'. */
320-rtx
321-legitimize_pic_address (rtx orig, machine_mode mode ATTRIBUTE_UNUSED, rtx reg)
322-{
323- if (GET_CODE (orig) == LABEL_REF || GET_CODE (orig) == SYMBOL_REF)
324- {
325- if (reg == NULL_RTX)
326- reg = gen_reg_rtx (Pmode);
327-
328- emit_insn (gen_symGOTOFF2reg (reg, orig));
329- crtl->uses_pic_offset_table = 1;
330- return reg;
331- }
332- else if (GET_CODE (orig) == SYMBOL_REF)
333- {
334- if (reg == NULL_RTX)
335- reg = gen_reg_rtx (Pmode);
336-
337- emit_insn (gen_symGOT2reg (reg, orig));
338- crtl->uses_pic_offset_table = 1;
339- return reg;
340- }
341- return orig;
342-}
343-
344342 /* Returns TRUE for simple memory addresses, ie ones
345343 that do not involve register indirect addressing
346344 or pre/post increment/decrement. */
@@ -536,10 +534,8 @@ rx_print_operand_address (FILE * file, machine_mode /*mode*/, rtx addr)
536534 switch (post)
537535 {
538536 case UNSPEC_GOTOFF:
539- fprintf (file, "#");
540537 output_addr_const (file, addr);
541538 fprintf (file, "@GOTOFF");
542- crtl->uses_pic_offset_table = 1;
543539 return;
544540 }
545541 }
@@ -598,8 +594,8 @@ rx_assemble_integer (rtx x, unsigned int size, int is_aligned)
598594 %P Register used for PID addressing
599595 %Q If the operand is a MEM, then correctly generate
600596 register indirect or register relative addressing.
601- %R Like %Q but for zero-extending loads.
602- %T symbol@PLT */
597+ %R Like %Q but for zero-extending loads. */
598+
603599
604600 static void
605601 rx_print_operand (FILE * file, rtx op, int letter)
@@ -886,20 +882,6 @@ rx_print_operand (FILE * file, rtx op, int letter)
886882 }
887883 break;
888884 }
889- case 'T':
890- /* Print an operand and @PLT. */
891- if (MEM_P (op))
892- op = XEXP (op, 0);
893-
894- switch (GET_CODE (op))
895- {
896- case LABEL_REF:
897- case SYMBOL_REF:
898- output_addr_const (file, op);
899- fprintf (file, "@PLT");
900- break;
901- }
902- break;
903885
904886 /* Fall through. */
905887
@@ -1030,47 +1012,6 @@ rx_print_operand (FILE * file, rtx op, int letter)
10301012 }
10311013 }
10321014
1033-/* Implement TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */
1034-static bool
1035-rx_asm_output_addr_const_extra (FILE *file, rtx x)
1036-{
1037- if (GET_CODE (x) == UNSPEC)
1038- {
1039- switch (XINT (x, 1))
1040- {
1041- case UNSPEC_PIC:
1042- /* GLOBAL_OFFSET_TABLE or local symbols, no suffix. */
1043- output_addr_const (file, XVECEXP (x, 0, 0));
1044- break;
1045- case UNSPEC_GOT:
1046- output_addr_const (file, XVECEXP (x, 0, 0));
1047- fputs ("@GOT", file);
1048- break;
1049- case UNSPEC_GOTOFF:
1050- output_addr_const (file, XVECEXP (x, 0, 0));
1051- fputs ("@GOTOFF", file);
1052- break;
1053- case UNSPEC_PLT:
1054- output_addr_const (file, XVECEXP (x, 0, 0));
1055- fputs ("@PLT", file);
1056- break;
1057- case UNSPEC_GOTPLT:
1058- output_addr_const (file, XVECEXP (x, 0, 0));
1059- fputs ("@GOTPLT", file);
1060- break;
1061- case UNSPEC_PCREL:
1062- output_addr_const (file, XVECEXP (x, 0, 0));
1063- fputs ("@PCREL", file);
1064- break;
1065- default:
1066- return false;
1067- }
1068- return true;
1069- }
1070- else
1071- return false;
1072-}
1073-
10741015 /* Maybe convert an operand into its PID format. */
10751016
10761017 rtx
@@ -1634,8 +1575,8 @@ rx_get_stack_layout (unsigned int * lowest,
16341575 they can be used in the fast interrupt handler without
16351576 saving them on the stack. */
16361577 || (is_fast_interrupt_func (NULL_TREE)
1637- && ! IN_RANGE (reg, 10, 13)))
16381578 || (flag_pic && reg == PIC_REGNUM))
1579+ && ! IN_RANGE (reg, 10, 13)))
16391580 {
16401581 if (low == 0)
16411582 low = reg;
@@ -1906,9 +1847,6 @@ rx_expand_prologue (void)
19061847 else if (low)
19071848 push_regs (high, low);
19081849
1909- // if (flag_pic && df_regs_ever_live_p (PIC_REGNUM))
1910- // emit_insn (gen_GOTaddr2picreg (const0_rtx));
1911-
19121850 if (MUST_SAVE_ACC_REGISTER)
19131851 {
19141852 unsigned int acc_high, acc_low;
@@ -3103,9 +3041,9 @@ rx_is_legitimate_constant (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
31033041
31043042 case UNSPEC:
31053043 return XINT (x, 1) == UNSPEC_CONST ||
3106- XINT (x, 1) == UNSPEC_PID_ADDR ||
3107- XINT (x, 1) == UNSPEC_GOTOFF ||
3108- XINT (x, 1) == UNSPEC_PLT;
3044+ XINT (x, 1) == UNSPEC_PID_ADDR ||
3045+ XINT (x, 1) == UNSPEC_GOTOFF ||
3046+ XINT (x, 1) == UNSPEC_PLT;
31093047
31103048 default:
31113049 /* FIXME: Can this ever happen ? */
@@ -3807,11 +3745,6 @@ int rx_legitimate_pic_operand_p(rtx x)
38073745 || ! nonpic_symbol_mentioned_p (get_pool_constant (x)))));
38083746 }
38093747
3810-static void
3811-rx_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx operands[], int num_rtx)
3812-{
3813- return;
3814-}
38153748
38163749 #undef TARGET_NARROW_VOLATILE_BITFIELD
38173750 #define TARGET_NARROW_VOLATILE_BITFIELD rx_narrow_volatile_bitfield
@@ -3971,13 +3904,6 @@ rx_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx operands[], int num_rtx)
39713904 #undef TARGET_HAVE_SPECULATION_SAFE_VALUE
39723905 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
39733906
3974-#undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
3975-#define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA rx_asm_output_addr_const_extra
3976-
3977-#undef TARGET_ASM_FINAL_POSTSCAN_INSN
3978-#define TARGET_ASM_FINAL_POSTSCAN_INSN rx_asm_final_postscan_insn
3979-
39803907 struct gcc_target targetm = TARGET_INITIALIZER;
39813908
39823909 #include "gt-rx.h"
3983-
--- a/gcc/config/rx/rx.h
+++ b/gcc/config/rx/rx.h
@@ -650,7 +650,7 @@ typedef unsigned int CUMULATIVE_ARGS;
650650 /* We can't directly access anything that contains a symbol,
651651 nor can we indirect via the constant pool. */
652652 int rx_legitimate_pic_operand_p(rtx x);
653-#define LEGITIMATE_PIC_OPERAND_P(X) \
653+#define LEGITIMATE_PIC_OPERAND_P(X) \
654654 rx_legitimate_pic_operand_p (X)
655655
656656 #define SYMBOLIC_CONST_P(X) \
--- a/gcc/config/rx/rx.md
+++ b/gcc/config/rx/rx.md
@@ -460,39 +460,31 @@
460460 (set_attr "timings" "33")]
461461 )
462462
463-(define_expand "call_site"
464- [(unspec [(match_dup 0)] 0)]
465- ""
466-{
467- static HOST_WIDE_INT i = 0;
468- operands[0] = GEN_INT (i);
469- i++;
470-})
471-
472463 (define_expand "call_value"
473464 [(set (match_operand 0 "register_operand")
474465 (call (match_operand:QI 1 "general_operand")
475466 (match_operand:SI 2 "general_operand")))]
476467 ""
477- {
478- rtx dest = XEXP (operands[1], 0);
468+{
469+ rtx dest = XEXP (operands[1], 0);
479470
480- if (! rx_call_operand (dest, Pmode))
481- dest = force_reg (Pmode, dest);
482- if (1 || !flag_pic || !(GET_CODE (dest) == SYMBOL_REF && !SYMBOL_REF_LOCAL_P (dest)))
483- emit_call_insn (gen_call_value_internal (operands[0], dest));
484- else
485- {
486- if (TARGET_JSR)
487- emit_call_insn (gen_call_value_got (operands[0], dest));
488- else {
489- printf("%s\n", __func__);
490- emit_call_insn (gen_call_value_plt (dest));
491- }
492- }
493- DONE;
494- }
495-)
471+ if (flag_pic &&
472+ (GET_CODE (dest) == SYMBOL_REF) && (!SYMBOL_REF_LOCAL_P (dest)))
473+ {
474+ if (flag_plt)
475+ emit_call_insn (gen_call_value_internal_plt (operands[0], dest));
476+ else
477+ emit_call_insn (gen_call_value_internal_got (operands[0], dest));
478+ DONE;
479+ }
480+ else
481+ {
482+ if (! rx_call_operand (dest, Pmode))
483+ dest = force_reg (Pmode, dest);
484+ emit_call_insn (gen_call_value_internal (operands[0], dest));
485+ }
486+ DONE;
487+})
496488
497489 (define_insn "call_value_internal"
498490 [(set (match_operand 0 "register_operand" "=r,r")
@@ -2924,45 +2916,73 @@
29242916 ""
29252917 "")
29262918
2927-(define_insn "mov_from_rirb"
2928- [(match_operand 0 "" "") (match_operand 1 "" "")]
2929- ""
2930-{
2931- return "mov.l\t[%0,%1],%0";
2932-}
2933-)
2934-
29352919 (define_expand "symGOTOFF2reg"
29362920 [(match_operand 0 "" "") (match_operand 1 "" "")]
29372921 ""
29382922 {
29392923 rtx gotoffsym;
29402924 rtx t = (!can_create_pseudo_p ()
2941- ? operands[0]
2942- : gen_reg_rtx (GET_MODE (operands[0])));
2925+ ? operands[0]
2926+ : gen_reg_rtx (GET_MODE (operands[0])));
29432927
29442928 rtx picreg = gen_rtx_REG (Pmode, PIC_REG);
29452929
29462930 gotoffsym = gen_sym2GOTOFF (operands[1]);
2947- emit_move_insn (t, gotoffsym);
2931+ emit_insn (gen_mov_from_got(t, picreg, gotoffsym));
29482932 emit_move_insn (operands[0], t);
2949- emit_insn(gen_mov_from_rirb(operands[0], picreg));
2933+ //emit_insn(gen_mov_from_rirb(operands[0], picreg));
29502934 // set_unique_reg_note (insn, REG_EQUAL, operands[1]);
29512935 DONE;
29522936 })
29532937
2954-(define_expand "sym2PIC"
2955- [(const (unspec [(match_operand:SI 0 "" "")] UNSPEC_PIC))]
2938+(define_insn "mov_from_got"
2939+ [(match_operand 0 "register_operand" "r")
2940+ (match_operand 1 "register_operand" "r")
2941+ (match_operand 2 "" "g")]
29562942 ""
2957- "")
2943+ "mov.l\t%A2[%1],%0"
2944+)
29582945
29592946 (define_insn "loadGOT"
29602947 [(set (match_operand:SI 0 "register_operand" "=r")
2961- (unspec:SI [(const_int 0)] UNSPEC_GOT))]
2948+ (unspec:SI [(const_int 0)] UNSPEC_GOT))]
29622949 ""
29632950 {
29642951 return "mvfc\tpc,%0\n\tadd\t#_GLOBAL_OFFSET_TABLE_,%0";
2965-}
2952+})
2953+
2954+(define_expand "call_value_internal_got"
2955+ [(set (match_operand 0 "register_operand" "=r,r")
2956+ (call (mem:QI (match_operand:SI 1 "rx_call_operand" "r,CALL_OP_SYMBOL_REF"))
2957+ (const_int 0)))
2958+ (clobber (reg:CC CC_REG))]
2959+ ""
2960+{
2961+ rtx gotoffsym;
2962+ rtx t = (!can_create_pseudo_p ()
2963+ ? operands[0]
2964+ : gen_reg_rtx (GET_MODE (operands[0])));
2965+
2966+ rtx picreg = gen_rtx_REG (Pmode, PIC_REG);
2967+
2968+ gotoffsym = gen_sym2GOTOFF (operands[1]);
2969+ emit_move_insn (t, gotoffsym);
2970+ emit_insn (gen_mov_from_got(t, picreg, gotoffsym));
2971+ emit_move_insn (operands[0], t);
2972+ emit_call_insn (gen_call_internal (operands[0]));
2973+ DONE;
2974+})
2975+
2976+(define_insn "call_value_internal_plt"
2977+ [(set (match_operand 0 "register_operand" "=r")
2978+ (call (mem:QI (match_operand:SI 1 "rx_symbolic_call_operand" ""))
2979+ (const_int 0)))
2980+ (use (reg:SI PIC_REG))
2981+ (clobber (reg:CC CC_REG))]
2982+ ""
2983+ "bsr\t%A1@PLT"
2984+ [(set_attr "length" "4")
2985+ (set_attr "timings" "33")]
29662986 )
29672987
29682988 (define_expand "call_value_got"
@@ -2981,8 +3001,8 @@
29813001
29823002 gotoffsym = gen_sym2GOTOFF (operands[1]);
29833003 emit_move_insn (t, gotoffsym);
3004+ emit_insn (gen_mov_from_got(t, picreg, gotoffsym));
29843005 emit_move_insn (operands[0], t);
2985- emit_insn(gen_mov_from_rirb(operands[0], picreg));
29863006 emit_call_insn (gen_call_internal (operands[0]));
29873007 DONE;
29883008 })