home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / gcc / help / 2561 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  6.6 KB

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!cronkite.Central.Sun.COM!texsun!legion!jeremy
  2. From: jeremy@legion.Corp.Sun.COM (Jeremy Allison)
  3. Newsgroups: gnu.gcc.help
  4. Subject: sun386i pic patch
  5. Message-ID: <13868@texsun.Central.Sun.COM>
  6. Date: 18 Nov 92 23:54:06 GMT
  7. Sender: news@texsun.Central.Sun.COM
  8. Reply-To: Jeremy.Allison@Corp.Sun.COM
  9. Organization: Sun Microsystems CTE Corporate Technical Escalations center
  10. Lines: 199
  11.  
  12. Jeremy Allison 11/18/92 (jeremy.allison@corp.sun.com)
  13.  
  14. I have created a patch that allows gcc-2.3.1 to produce position
  15. independent code on a Sun386i under 4.0.2. The patch only works if the sun
  16. assembler is used rather than gas, as gas does not handle pic code.
  17.  
  18. Most of the changes I have made are in the config directory, to the files 
  19.  
  20. i386.c, i386.md, i386sun.h
  21.  
  22. but I had to make one change to stmt.c for the following reason. When gcc
  23. generates switch statements it can generate code that tests each case in
  24. turn (comparison code), or produces a table of offsets as a jump table.
  25. When operating in pic code mode, the sun assembler cannot handle these jump
  26. tables, so I added an #ifdef that forced comparison code to be generated if
  27. the machine is a sun386i and if pic code was requested. 
  28.  
  29. I have submitted this to the GNU project, but rms found the change to stmt.c
  30. unacceptable. However, it does seem to work, I have compiled X11R5
  31. successfully with these patches in place - so if you don't mind these not
  32. being an officially blessed GNU patch.... go ahead !
  33.  
  34. The context diffs follow, where the original files are <filename>-orig.
  35.  
  36. ********************* DISCLAIMER *****************************
  37.  
  38. NOTE THIS IS NOT A SUN SUPPLIED PATCH, I HAVE GENERATED IT IN MY SPARE
  39. TIME. THIS IS NOT A SUN SUPPORTED POSTING. I WILL LOOK AT ANY PROBLEMS
  40. PEOPLE MAY FIND BUT THIS IS BEING DONE IN MY SPARE TIME FOR MY OWN
  41. PROJECTS (I own a 386i at home).
  42.  
  43.  
  44. ---------------diff for config/i386.c---------------------------------
  45. % diff -c config/i386.c-orig config/i386.c
  46. *** config/i386.c-orig  Mon Nov  2 16:31:52 1992
  47. --- config/i386.c       Mon Nov  2 16:35:39 1992
  48. ***************
  49. *** 579,587 ****
  50. --- 579,589 ----
  51.           if (reg == 0)
  52.             reg = gen_reg_rtx (Pmode);
  53.   
  54. + #ifndef sun386
  55.           if (GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FLAG (addr))
  56.             new = gen_rtx (PLUS, Pmode, pic_offset_table_rtx, orig);
  57.           else
  58. + #endif
  59.             new = gen_rtx (MEM, Pmode,
  60.                            gen_rtx (PLUS, Pmode,
  61.                                     pic_offset_table_rtx, orig));
  62. ***************
  63. *** 693,699 ****
  64. --- 695,705 ----
  65.         output_asm_insn (AS1 (call,%P1), xops);
  66.         ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (xops[1]));
  67.         output_asm_insn (AS1 (pop%L0,%0), xops);
  68. + #ifdef sun386
  69. +       output_asm_insn ("addl $_globtb_offset,%0", xops);
  70. + #else
  71.         output_asm_insn ("addl $_GLOBAL_OFFSET_TABLE_+[.-%P1],%0", xops);
  72. + #endif
  73.       }
  74.   }
  75.   
  76. ***************
  77. *** 879,885 ****
  78. --- 885,902 ----
  79.           assemble_name (asm_out_file, buf);
  80.         }
  81.   
  82. + #ifdef sun386
  83.         if (GET_CODE (x) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (x))
  84. +         fprintf (file, "(%%ebx)");
  85. +       else if (code == 'P')
  86. +         fprintf (file, ", %%eax"); /* Needed for stupid sun386i assembler to
  87. +                                     generate pic reference */
  88. +       else if (GET_CODE (x) == LABEL_REF || ! SYMBOL_REF_FLAG (x))
  89. +         ;
  90. +       else
  91. +         ;
  92. + #else
  93. +       if (GET_CODE (x) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (x))
  94.         fprintf (file, "@GOTOFF(%%ebx)");
  95.         else if (code == 'P')
  96.         fprintf (file, "@PLT");
  97. ***************
  98. *** 887,892 ****
  99. --- 904,910 ----
  100.         fprintf (file, "@GOT");
  101.         else
  102.         fprintf (file, "@GOTOFF");
  103. + #endif
  104.   
  105.         break;
  106.  
  107.  
  108. -------------context diff for config/i386.md-------------------
  109. % diff -c config/i386.md-orig config/i386.md
  110. *** config/i386.md-orig Mon Nov  2 16:28:00 1992
  111. --- config/i386.md      Tue Nov 17 11:10:21 1992
  112. ***************
  113. *** 867,873 ****
  114.       return AS1 (fxch,%0);
  115.   }")
  116.   
  117. ! (define_insn "movdf"
  118.     [(set (match_operand:DF 0 "general_operand" "=f,fm,!*rf,!*rm")
  119.         (match_operand:DF 1 "general_operand" "fmG,f,*rfm,*rfF"))]
  120.     ""
  121. --- 867,888 ----
  122.       return AS1 (fxch,%0);
  123.   }")
  124.   
  125. ! (define_expand "movdf"
  126. !   [(set (match_operand:DF 0 "general_operand" "")
  127. !         (match_operand:DF 1 "general_operand" ""))]
  128. !   ""
  129. !   " 
  130. ! {
  131. !   extern int flag_pic;
  132. !   if (flag_pic && (GET_CODE(operands[1])== CONST_DOUBLE)) {
  133. !       operands[1] = XEXP(force_const_mem( DFmode, operands[1]),0);
  134. !       CONSTANT_POOL_ADDRESS_P(operands[1]) = 0; /* Cheat */
  135. !       operands[1] = gen_rtx(MEM, DFmode, emit_pic_move(operands, SImode));
  136. !   }
  137. ! }")
  138. ! (define_insn ""
  139.     [(set (match_operand:DF 0 "general_operand" "=f,fm,!*rf,!*rm")
  140.         (match_operand:DF 1 "general_operand" "fmG,f,*rfm,*rfF"))]
  141.     ""
  142. ***************
  143. *** 3672,3678 ****
  144. --- 3687,3697 ----
  145.     xops[3] = pic_offset_table_rtx;
  146.   
  147.     output_asm_insn (AS2 (mov%L2,%3,%2), xops);
  148. + #ifdef sun386
  149. +   output_asm_insn (\"sub%L2 %l1(%3,%0,4),%2\", xops);
  150. + #else
  151.     output_asm_insn (\"sub%L2 %l1@GOTOFF(%3,%0,4),%2\", xops);
  152. + #endif
  153.     output_asm_insn (AS1 (jmp,%*%2), xops);
  154.     ASM_OUTPUT_ALIGN_CODE (asm_out_file);
  155.     RET;
  156.  
  157. -----------------context diff for config/i386sun.h-----------
  158.  
  159. % diff -c config/i386sun.h-orig config/i386sun.h
  160. *** config/i386sun.h-orig       Mon Nov  2 16:26:18 1992
  161. --- config/i386sun.h    Mon Nov  2 16:27:12 1992
  162. ***************
  163. *** 39,45 ****
  164.   
  165.   /* Extra switches to give the assembler.  */
  166.   
  167. ! #define ASM_SPEC "-i386"
  168.   
  169.   /* Specify predefined symbols in preprocessor.  */
  170.   
  171. --- 39,45 ----
  172.   
  173.   /* Extra switches to give the assembler.  */
  174.   
  175. ! #define ASM_SPEC "-i386 %{fpic:-k} %{fPIC:-k}"
  176.   
  177.   /* Specify predefined symbols in preprocessor.  */
  178.   
  179. ***************
  180. *** 64,69 ****
  181. --- 64,73 ----
  182.   /* We want to output DBX debugging information.  */
  183.   
  184.   #define DBX_DEBUGGING_INFO
  185. + /* DBX info should come _before_ the function for the 386i assembler and gdb */
  186. + #define DBX_FUNCTION_FIRST
  187.   
  188.   /* Implicit library calls should use memcpy, not bcopy, etc.  */
  189.  
  190. -----------context diff for stmt.c---------------------------------
  191.  
  192. % diff -c stmt.c-orig stmt.c
  193. *** stmt.c-orig Fri Oct  9 09:59:03 1992
  194. --- stmt.c      Mon Nov  2 16:37:05 1992
  195. ***************
  196. *** 3747,3752 ****
  197. --- 3747,3755 ----
  198.   #endif /* CASE_VALUES_THRESHOLD */
  199.   
  200.         else if (TREE_INT_CST_HIGH (range) != 0
  201. + #ifdef sun386
  202. +              || flag_pic
  203. + #endif
  204.                || count < CASE_VALUES_THRESHOLD
  205.                || ((unsigned HOST_WIDE_INT) (TREE_INT_CST_LOW (range))
  206.                    > 10 * count)
  207.