home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / config / next / nextstep.c < prev    next >
C/C++ Source or Header  |  1996-12-12  |  6KB  |  228 lines

  1. /* Functions for generic NeXT as target machine for GNU C compiler.
  2.    Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21. /* Make everything that used to go in the text section really go there.  */
  22.  
  23. int flag_no_mach_text_sections = 0;
  24.  
  25. #define OPT_STRCMP(opt) ((!strncmp (opt, p, sizeof (opt)-1)) \
  26.              || (!strncmp ((opt)+1, p, sizeof (opt)-2)))
  27.  
  28. /* 1 if handle_pragma has been called yet.  */
  29.  
  30. static int pragma_initialized;
  31.  
  32. /* Initial setting of `optimize'.  */
  33.  
  34. static int initial_optimize_flag;
  35. static int initial_flag_expensive_optimizations;
  36.  
  37. extern char *get_directive_line ();
  38.  
  39. /* Called from check_newline via the macro HANDLE_PRAGMA.
  40.    FINPUT is the source file input stream.  */
  41.  
  42. void
  43. handle_pragma (finput, get_line_function)
  44.      FILE *finput;
  45.      char *(*get_line_function) ();
  46. {
  47.   register char *p = (*get_line_function) (finput);
  48.  
  49.   /* Record initial setting of optimize flag, so we can restore it.  */
  50.   if (!pragma_initialized)
  51.     {
  52.       pragma_initialized = 1;
  53.       initial_optimize_flag = optimize;
  54.       initial_flag_expensive_optimizations = flag_expensive_optimizations;
  55.     }
  56.  
  57.   if (OPT_STRCMP ("CC_OPT_ON"))
  58.     {
  59.       optimize = 1, obey_regdecls = 0;
  60.       flag_expensive_optimizations = initial_flag_expensive_optimizations;
  61.       warning ("optimization turned on");
  62.     }
  63.   else if (OPT_STRCMP ("CC_OPT_OFF"))
  64.     {
  65.       optimize = 0, obey_regdecls = 1;
  66.       flag_expensive_optimizations = 0;
  67.       warning ("optimization turned off");
  68.     }
  69.   else if (OPT_STRCMP ("CC_OPT_RESTORE"))
  70.     {
  71.       if (optimize != initial_optimize_flag)
  72.     {
  73.       if (initial_optimize_flag)
  74.         obey_regdecls = 0;
  75.       else
  76.         obey_regdecls = 1;
  77.       optimize = initial_optimize_flag;
  78.       flag_expensive_optimizations = initial_flag_expensive_optimizations;
  79.     }
  80.       warning ("optimization level restored");
  81.     }
  82.   else if (OPT_STRCMP ("CC_WRITABLE_STRINGS"))
  83.     flag_writable_strings = 1;
  84.   else if (OPT_STRCMP ("CC_NON_WRITABLE_STRINGS"))
  85.     flag_writable_strings = 0;
  86.   else if (OPT_STRCMP ("CC_NO_MACH_TEXT_SECTIONS"))
  87.     flag_no_mach_text_sections = 1;
  88.   else if (OPT_STRCMP ("SECTION"))
  89.     {
  90.       char name[1024];
  91.       char *q = &(name[0]);
  92.  
  93.       while (isalpha (*p)) p++;
  94.       while (*p && (isspace (*p) || (*p == '.'))) p++;
  95.       while (*p && !isspace (*p)) *q++ = *p++;
  96.       *q = 0;
  97.  
  98.       while (*p && isspace (*p)) p++;
  99.       if (*p == 0)
  100.         alias_section (name, 0);
  101.       else if (*p == '"')
  102.         {
  103.           char *start = ++p;
  104.           while (*p && *p != '"')
  105.             {
  106.               if (*p == '\\') p++;
  107.               p++;
  108.             }
  109.           *p = 0;
  110.           alias_section (name, start);
  111.         }
  112.       else
  113.         {
  114.           alias_section (name, p);
  115.         }
  116.     }
  117.   else if (OPT_STRCMP ("CALL_ON_MODULE_BIND"))
  118.     {
  119.       extern FILE *asm_out_file;
  120.       while (isalpha (*p) || *p == '_') p++;
  121.       while (*p && isspace (*p)) p++;
  122.  
  123.       if (*p)
  124.         {
  125.           mod_init_section ();
  126.           fprintf (asm_out_file, "\t.long _%s\n", p);
  127.         }
  128.     }
  129. }
  130.  
  131. static int
  132. name_needs_quotes(name)
  133.      const char *name;
  134. {
  135.   int c;
  136.   while ((c = *name++) != '\0')
  137.     if (!isalnum(c) && c != '_')
  138.       return 1;
  139.   return 0;
  140. }
  141.  
  142. #if defined (I386) || defined (MACHOPIC_M68K)
  143. /* Go through all the insns looking for a double constant.  Return nonzero
  144.    if one is found.  */
  145.  
  146. const_double_used ()
  147. {
  148.   rtx insn;
  149.   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
  150.     {
  151.       enum rtx_code code;
  152.       rtx set = single_set (insn);
  153.       if (set)
  154.     if ((code = GET_CODE (SET_SRC (set))) == CONST_DOUBLE)
  155.       return 1;
  156. #ifdef MACHOPIC_M68K
  157.         else
  158.       /* Hopefully this catches all the cases we're interested in.  */
  159.       switch (GET_RTX_CLASS (code))
  160.         {
  161.           int i;
  162.         case '<':
  163.         case '1':
  164.         case 'c':
  165.         case '2':
  166.           for (i = 0; i < GET_RTX_LENGTH (code); i++)
  167.         if (GET_CODE (XEXP (SET_SRC (set), i)) == CONST_DOUBLE)
  168.           return 1;
  169.         }
  170. #endif
  171.     }
  172.   return 0;
  173. }
  174. #endif /* I386 || MACHOPIC_M68K */
  175.  
  176. #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH)        \
  177.   do {                                \
  178.     const char *stub_ = (STUB);                    \
  179.     char *buffer_ = (BUF);                    \
  180.     strcpy(buffer_, stub_);                    \
  181.     if (stub_[0] == '"')                    \
  182.       {                                \
  183.     strcpy(buffer_ + (STUB_LENGTH) - 1, "_binder\"");    \
  184.       }                                \
  185.     else                            \
  186.       {                                \
  187.     strcpy(buffer_ + (STUB_LENGTH), "_binder");        \
  188.       }                                \
  189.   } while (0)
  190.  
  191. #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH)    \
  192.   do {                                \
  193.     const char *symbol_ = (SYMBOL);                \
  194.     char *buffer_ = (BUF);                    \
  195.     if (name_needs_quotes(symbol_) && symbol_[0] != '"')    \
  196.       {                                \
  197.       sprintf(buffer_, "\"%s\"", symbol_);            \
  198.       }                                \
  199.     else                            \
  200.       {                                \
  201.     strcpy(buffer_, symbol_);                \
  202.       }                                \
  203.   } while (0)
  204.  
  205. #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH)    \
  206.   do {                                \
  207.     const char *symbol_ = (SYMBOL);                \
  208.     char *buffer_ = (BUF);                    \
  209.     if (symbol_[0] == '"')                    \
  210.       {                                \
  211.         strcpy(buffer_, "\"L");                    \
  212.         strcpy(buffer_ + 2, symbol_ + 1);            \
  213.     strcpy(buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\"");    \
  214.       }                                \
  215.     else if (name_needs_quotes(symbol_))            \
  216.       {                                \
  217.         strcpy(buffer_, "\"L");                    \
  218.         strcpy(buffer_ + 2, symbol_);                \
  219.     strcpy(buffer_ + (SYMBOL_LENGTH) + 2, "$lazy_ptr\"");    \
  220.       }                                \
  221.     else                            \
  222.       {                                \
  223.         strcpy(buffer_, "L");                    \
  224.         strcpy(buffer_ + 1, symbol_);                \
  225.     strcpy(buffer_ + (SYMBOL_LENGTH) + 1, "$lazy_ptr");    \
  226.       }                                \
  227.   } while (0)
  228.