home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / config / sparc / pbd.h < prev    next >
C/C++ Source or Header  |  1995-06-15  |  7KB  |  187 lines

  1. /* Definitions of target machine for GNU compiler.
  2.  
  3.    Citicorp/TTI Unicom PBD version
  4.    (using GAS and  COFF (encapsulated is unacceptable) )
  5.  
  6.    Copyright (C) 1990 Free Software Foundation, Inc.
  7.  
  8. This file is part of GNU CC.
  9.  
  10. GNU CC is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2, or (at your option)
  13. any later version.
  14.  
  15. GNU CC is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with GNU CC; see the file COPYING.  If not, write to
  22. the Free Software Foundation, 59 Temple Place - Suite 330,
  23. Boston, MA 02111-1307, USA.  */
  24.  
  25. #include "sparc/sparc.h"
  26.  
  27. /* Names to predefine in the preprocessor for this target machine.  */
  28.  
  29. #undef CPP_PREDEFINES
  30. #define CPP_PREDEFINES "-Dsparc -DUnicomPBD -Dunix -D__GCC_NEW_VARARGS__ -Asystem(unix) -Acpu(sparc) -Amachine(sparc)"
  31.  
  32. /* We want DBX format for use with gdb under COFF.  */
  33.  
  34. #define DBX_DEBUGGING_INFO
  35.  
  36. /* Generate calls to memcpy, memcmp and memset.  */
  37.  
  38. #define TARGET_MEM_FUNCTIONS
  39.  
  40. /* we use /lib/libp/lib*  when profiling */
  41.  
  42. #undef LIB_SPEC
  43. #define LIB_SPEC "%{p:-L/usr/lib/libp} %{pg:-L/usr/lib/libp} -lc"
  44.  
  45.  
  46. /* Use crt1.o as a startup file and crtn.o as a closing file.  */
  47. /*
  48.  * The loader directive file gcc.ifile defines how to merge the constructor 
  49.  * sections into the data section.  Also, since gas only puts out those 
  50.  * sections in response to N_SETT stabs, and does not (yet) have a 
  51.  * ".sections" directive, gcc.ifile also defines the list symbols 
  52.  * __DTOR_LIST__ and __CTOR_LIST__.
  53.  * 
  54.  * Finally, we must explicitly specify the file from libgcc.a that defines
  55.  * exit(), otherwise if the user specifies (for example) "-lc_s" on the 
  56.  * command line, the wrong exit() will be used and global destructors will 
  57.  * not get called .
  58.  */
  59.  
  60. #define STARTFILE_SPEC \
  61. "%{!r: gcc.ifile%s} %{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} \
  62. %{!r:_exit.o%s}"
  63.  
  64. #define ENDFILE_SPEC "crtn.o%s"
  65.  
  66. /* cpp has to support a #sccs directive for the /usr/include files */
  67.  
  68. #define SCCS_DIRECTIVE
  69.  
  70. /* LINK_SPEC is needed only for SunOS 4.  */
  71.  
  72. #undef LINK_SPEC
  73.  
  74. /* Although the gas we use can create .ctor and .dtor sections from N_SETT
  75.    stabs, it does not support section directives, so we need to have the loader
  76.    define the lists.
  77.    */
  78. #define CTOR_LISTS_DEFINED_EXTERNALLY
  79.  
  80. /* similar to default, but allows for the table defined by ld with gcc.ifile. 
  81.    nptrs is always 0.  So we need to instead check that __DTOR_LIST__[1] != 0.
  82.    The old check is left in so that the same macro can be used if and when  
  83.    a future version of gas does support section directives. */
  84.  
  85. #define DO_GLOBAL_DTORS_BODY {int nptrs = *(int *)__DTOR_LIST__; int i; \
  86.   if (nptrs == -1 || (__DTOR_LIST__[0] == 0 && __DTOR_LIST__[1] != 0))  \
  87.     for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);         \
  88.   for (i = nptrs; i >= 1; i--)                        \
  89.     __DTOR_LIST__[i] (); }
  90.  
  91. /* 
  92.  * Here is an example gcc.ifile.  I've tested it on PBD sparc
  93.  * systems. The NEXT(0x200000) works on just about all 386 and m68k systems, 
  94.  * but can be reduced to any power of 2 that is >= NBPS (0x40000 on a pbd).
  95.  
  96.    SECTIONS {
  97.        .text BIND(0x41000200) BLOCK (0x200) : 
  98.         { *(.init) *(.text) vfork = fork; *(.fini) }
  99.  
  100.           GROUP BIND( NEXT(0x200000) + ADDR(.text) + SIZEOF(.text)):
  101.     {      .data : { __CTOR_LIST__ = . ; . += 4; *(.ctor) . += 4 ;
  102.                     __DTOR_LIST__ = . ; . += 4; *(.dtor) . += 4 ; }
  103.            .bss : { }
  104.        }
  105.   }
  106.  */
  107.  
  108. #undef  ASM_OUTPUT_LABELREF
  109. #define ASM_OUTPUT_LABELREF(FILE,NAME)    \
  110.   fprintf (FILE, "%s", NAME)
  111.  
  112. /* fixes: */
  113. /*
  114.  *  Internal labels are prefixed with a period.
  115.  */
  116.  
  117. /* This is how to store into the string LABEL
  118.    the symbol_ref name of an internal numbered label where
  119.    PREFIX is the class of label and NUM is the number within the class.
  120.    This is suitable for output with `assemble_name'.  */
  121.  
  122. #undef ASM_GENERATE_INTERNAL_LABEL
  123.  
  124. #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)                   \
  125.         sprintf (LABEL, "*.%s%d", PREFIX, NUM)
  126.  
  127.  
  128. /* This is how to output an internal numbered label where
  129.    PREFIX is the class of label and NUM is the number within the class.  */
  130.  
  131. #undef  ASM_OUTPUT_INTERNAL_LABEL
  132. #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)                      \
  133.         fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
  134.  
  135. /* This is how to output an element of a case-vector that is relative.  */
  136.  
  137. #undef  ASM_OUTPUT_ADDR_DIFF_ELT
  138. #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL)  \
  139.   fprintf (FILE, "\t.word .L%d-.L%d\n", VALUE, REL)
  140.  
  141. /* This is how to output an element of a case-vector that is absolute.
  142.    (The 68000 does not use such vectors,
  143.    but we must define this macro anyway.)  */
  144.  
  145. #undef ASM_OUTPUT_ADDR_VEC_ELT
  146. #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)  \
  147.   fprintf (FILE, "\t.word .L%d\n", VALUE)
  148.  
  149. /* Output assembler code to FILE to increment profiler label # LABELNO
  150.    for profiling a function entry.  */
  151.  
  152. #undef FUNCTION_PROFILER
  153. #define FUNCTION_PROFILER(FILE, LABELNO)  \
  154.   fprintf (FILE, "\tsethi %%hi(.LP%d),%%o0\n\tcall mcount\n\tor %%lo(.LP%d),%%o0,%%o0\n", \
  155.        (LABELNO), (LABELNO))
  156.  
  157. /* Output assembler code to FILE to initialize this source file's
  158.    basic block profiling info, if that has not already been done.  */
  159.  
  160. #undef FUNCTION_BLOCK_PROFILER
  161. #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO)  \
  162.   fprintf (FILE, "\tsethi %%hi(.LPBX0),%%o0\n\tld [%%lo(.LPBX0)+%%o0],%%o1\n\ttst %%o1\n\tbne .LPY%d\n\tnop\n\tcall ___bb_init_func\n\tnop\n.LPY%d:\n",  \
  163.        (LABELNO), (LABELNO))
  164.  
  165. /* Output assembler code to FILE to increment the entry-count for
  166.    the BLOCKNO'th basic block in this source file.  */
  167.  
  168. #undef BLOCK_PROFILER
  169. #define BLOCK_PROFILER(FILE, BLOCKNO) \
  170. {                                \
  171.   int blockn = (BLOCKNO);                    \
  172.   fprintf (FILE, "\tsethi %%hi(.LPBX2+%d),%%g1\n\tld [%%lo(.LPBX2+%d)+%%g1],%%g2\n\
  173. \tadd %%g2,1,%%g2\n\tst %%g2,[%%lo(.LPBX2+%d)+%%g1]\n",        \
  174.        4 * blockn, 4 * blockn, 4 * blockn);            \
  175.   CC_STATUS_INIT;  /* We have clobbered %g1.  Also %g2.  */    \
  176. }
  177. /*   This is needed for SunOS 4.0, and should not hurt for 3.2
  178.    versions either.  */
  179. #undef ASM_OUTPUT_SOURCE_LINE(file, line) 
  180. #define ASM_OUTPUT_SOURCE_LINE(file, line)        \
  181.   { static int sym_lineno = 1;                \
  182.     fprintf (file, ".stabn 68,0,%d,.LM%d\n.LM%d:\n",    \
  183.          line, sym_lineno, sym_lineno);        \
  184.     sym_lineno += 1; }
  185.  
  186. #define ASM_INT_OP ".long "
  187.