• 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

Revisión2269d21b750f07d15e95905ad14d3f3886c64566 (tree)
Tiempo2022-11-24 19:25:15
AutorYoshinori Sato <yo-satoh@sios...>
CommiterYoshinori Sato

Log Message

WIP: rx plt

Signed-off-by: Yoshinori Sato <yo-satoh@sios.com>

Cambiar Resumen

Diferencia incremental

--- a/gcc/config/rx/rx-protos.h
+++ b/gcc/config/rx/rx-protos.h
@@ -172,5 +172,6 @@ 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);
175176
176177 #endif /* GCC_RX_PROTOS_H */
--- a/gcc/config/rx/rx.cc
+++ b/gcc/config/rx/rx.cc
@@ -540,7 +540,6 @@ rx_print_operand_address (FILE * file, machine_mode /*mode*/, rtx addr)
540540 output_addr_const (file, addr);
541541 fprintf (file, "@GOTOFF");
542542 crtl->uses_pic_offset_table = 1;
543- printf("%s %p %d\n", __func__, &(crtl->uses_pic_offset_table), crtl->uses_pic_offset_table);
544543 return;
545544 }
546545 }
@@ -599,7 +598,8 @@ rx_assemble_integer (rtx x, unsigned int size, int is_aligned)
599598 %P Register used for PID addressing
600599 %Q If the operand is a MEM, then correctly generate
601600 register indirect or register relative addressing.
602- %R Like %Q but for zero-extending loads. */
601+ %R Like %Q but for zero-extending loads.
602+ %T symbol@PLT */
603603
604604 static void
605605 rx_print_operand (FILE * file, rtx op, int letter)
@@ -886,6 +886,20 @@ rx_print_operand (FILE * file, rtx op, int letter)
886886 }
887887 break;
888888 }
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;
889903
890904 /* Fall through. */
891905
@@ -1092,7 +1106,6 @@ rx_gen_move_template (rtx * operands, bool is_movu)
10921106 rtx dest = operands[0];
10931107 rtx src = operands[1];
10941108
1095- printf("%s\n", __func__);
10961109 /* Decide which extension, if any, should be given to the move instruction. */
10971110 switch (CONST_INT_P (src) ? GET_MODE (dest) : GET_MODE (src))
10981111 {
@@ -2483,6 +2496,7 @@ rx_select_section (tree decl,
24832496
24842497 return default_elf_select_section (decl, reloc, align);
24852498 }
2499+
24862500
24872501 enum rx_builtin
24882502 {
@@ -3090,7 +3104,8 @@ rx_is_legitimate_constant (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
30903104 case UNSPEC:
30913105 return XINT (x, 1) == UNSPEC_CONST ||
30923106 XINT (x, 1) == UNSPEC_PID_ADDR ||
3093- XINT (x, 1) == UNSPEC_GOTOFF;
3107+ XINT (x, 1) == UNSPEC_GOTOFF ||
3108+ XINT (x, 1) == UNSPEC_PLT;
30943109
30953110 default:
30963111 /* FIXME: Can this ever happen ? */
--- a/gcc/config/rx/rx.md
+++ b/gcc/config/rx/rx.md
@@ -460,6 +460,15 @@
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+
463472 (define_expand "call_value"
464473 [(set (match_operand 0 "register_operand")
465474 (call (match_operand:QI 1 "general_operand")
@@ -470,10 +479,17 @@
470479
471480 if (! rx_call_operand (dest, Pmode))
472481 dest = force_reg (Pmode, dest);
473- if (!flag_pic || !(GET_CODE (dest) == SYMBOL_REF && !SYMBOL_REF_LOCAL_P (dest)))
482+ if (1 || !flag_pic || !(GET_CODE (dest) == SYMBOL_REF && !SYMBOL_REF_LOCAL_P (dest)))
474483 emit_call_insn (gen_call_value_internal (operands[0], dest));
475484 else
476- emit_call_insn (gen_call_value_pcrel (operands[0], dest));
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+ }
477493 DONE;
478494 }
479495 )
@@ -2889,26 +2905,6 @@
28892905 )
28902906
28912907 ;; PIC stuff
2892-
2893-(define_expand "sym_label2reg"
2894- [(set (match_operand:SI 0 "" "")
2895- (const:SI (unspec:SI [(match_operand:SI 1 "" "")
2896- (const (plus:SI (match_operand:SI 2 "" "")
2897- (const_int 2)))]
2898- UNSPEC_SYMOFF)))]
2899- ""
2900- "")
2901-
2902-(define_expand "symPCREL_label2reg"
2903- [(set (match_operand:SI 0 "" "")
2904- (const:SI
2905- (unspec:SI
2906- [(const:SI (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PCREL))
2907- (const:SI (plus:SI (match_operand:SI 2 "" "")
2908- (const_int 2)))] UNSPEC_PCREL_SYMOFF)))]
2909- ""
2910- "")
2911-
29122908 (define_expand "sym2GOT"
29132909 [(const (unspec [(match_operand 0 "" "")] UNSPEC_GOT))]
29142910 ""
@@ -2923,17 +2919,6 @@
29232919 DONE;
29242920 })
29252921
2926-(define_expand "symGOTPLT2reg"
2927- [(match_operand 0 "" "") (match_operand 1 "" "")]
2928- ""
2929-{
2930- rtx pltsym = gen_rtx_CONST (Pmode,
2931- gen_rtx_UNSPEC (Pmode,
2932- gen_rtvec (1, operands[1]),
2933- UNSPEC_GOTPLT));
2934- DONE;
2935-})
2936-
29372922 (define_expand "sym2GOTOFF"
29382923 [(const (unspec [(match_operand 0 "" "")] UNSPEC_GOTOFF))]
29392924 ""
@@ -2966,28 +2951,6 @@
29662951 DONE;
29672952 })
29682953
2969-(define_expand "symPLT_label2reg"
2970- [(set (match_operand:SI 0 "" "")
2971- (const:SI
2972- (unspec:SI
2973- [(const:SI (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PLT))
2974- (const:SI (plus:SI (match_operand:SI 2 "" "")
2975- (const_int 2)))] UNSPEC_PCREL_SYMOFF)))
2976- ;; Even though the PIC register is not really used by the call
2977- ;; sequence in which this is expanded, the PLT code assumes the PIC
2978- ;; register is set, so we must not skip its initialization. Since
2979- ;; we only use this expand as part of calling sequences, and never
2980- ;; to take the address of a function, this is the best point to
2981- ;; insert the (use). Using the PLT to take the address of a
2982- ;; function would be wrong, not only because the PLT entry could
2983- ;; then be called from a function that doesn't initialize the PIC
2984- ;; register to the proper GOT, but also because pointers to the
2985- ;; same function might not compare equal, should they be set by
2986- ;; different shared libraries.
2987- (use (reg:SI PIC_REG))]
2988- ""
2989- "")
2990-
29912954 (define_expand "sym2PIC"
29922955 [(const (unspec [(match_operand:SI 0 "" "")] UNSPEC_PIC))]
29932956 ""
@@ -3002,7 +2965,7 @@
30022965 }
30032966 )
30042967
3005-(define_expand "call_value_pcrel"
2968+(define_expand "call_value_got"
30062969 [(set (match_operand 0 "register_operand" "=r,r")
30072970 (call (mem:QI (match_operand:SI 1 "rx_call_operand" "r,CALL_OP_SYMBOL_REF"))
30082971 (const_int 0)))
@@ -3023,3 +2986,13 @@
30232986 emit_call_insn (gen_call_internal (operands[0]));
30242987 DONE;
30252988 })
2989+
2990+(define_insn "call_value_plt"
2991+ [(call (mem:QI (match_operand:SI 0 "rx_call_operand" "CALL_OP_SYMBOL_REF"))
2992+ (const_int 0))
2993+ (clobber (reg:CC CC_REG))]
2994+ ""
2995+ "bsr\t%T0"
2996+ [(set_attr "length" "4")
2997+ (set_attr "timings" "33")]
2998+)