Annotation of gcc/config/vax/vms.h, revision 1.1.1.3

1.1       root        1: /* Output variables, constants and external declarations, for GNU compiler.
1.1.1.3 ! root        2:    Copyright (C) 1988, 1994 Free Software Foundation, Inc.
1.1       root        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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
1.1.1.3 ! root       20: #define VMS_TARGET
        !            21: 
1.1       root       22: /* This enables certain macros in vax.h, which will make an indirect
                     23:    reference to an external symbol an invalid address.  This needs to be
                     24:    defined before we include vax.h, since it determines which macros
                     25:    are used for GO_IF_*.  */
                     26: 
                     27: #define NO_EXTERNAL_INDIRECT_ADDRESS
                     28: 
                     29: #include "vax/vax.h"
                     30: 
                     31: #undef LIB_SPEC
                     32: #undef CPP_PREDEFINES
                     33: #undef TARGET_VERSION
                     34: #undef TARGET_DEFAULT
                     35: #undef CALL_USED_REGISTERS
                     36: #undef MAYBE_VMS_FUNCTION_PROLOGUE
                     37: #undef FUNCTION_PROLOGUE
                     38: #undef STARTING_FRAME_OFFSET
                     39: 
                     40: /* Predefine this in CPP because VMS limits the size of command options
                     41:    and GNU CPP is not used on VMS except with GNU C.  */
1.1.1.3 ! root       42: #define CPP_PREDEFINES \
        !            43: "-Dvax -Dvms -DVMS -D__vax__ -D__vms__ -D__VMS__\
        !            44:  -D__GNUC__=2 -D__GNUC_MINOR__=6 -Asystem(vms) -Acpu(vax) -Amachine(vax)"
1.1       root       45: 
                     46: /* These match the definitions used in VAXCRTL, the VMS C run-time library */
                     47: 
                     48: #define SIZE_TYPE "unsigned int"
                     49: #define PTRDIFF_TYPE "int"
                     50: #define WCHAR_TYPE     "unsigned int"
                     51: 
                     52: /* Use memcpy for structure copying, and so forth.  */
                     53: #define TARGET_MEM_FUNCTIONS
                     54: 
                     55: /* Strictly speaking, VMS does not use DBX at all, but the interpreter built
                     56:    into gas only speaks straight DBX.  */
                     57: 
                     58: #define DEFAULT_GDB_EXTENSIONS 0
                     59: 
                     60: /* By default, allow $ to be part of an identifier.  */
                     61: #define DOLLARS_IN_IDENTIFIERS 2
                     62: 
                     63: #define TARGET_DEFAULT 1
                     64: #define TARGET_VERSION fprintf (stderr, " (vax vms)");
                     65: 
                     66: /* The structure return address arrives as an "argument" on VMS.  */
                     67: #undef STRUCT_VALUE_REGNUM
                     68: #define STRUCT_VALUE 0
                     69: #undef PCC_STATIC_STRUCT_RETURN
                     70: 
                     71: #define CALL_USED_REGISTERS {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
                     72: 
                     73: /* We redefine this because there is a hidden variable on the stack
                     74:    that VAXC$ESTABLISH uses.  We just need to add four bytes to whatever
                     75:    gcc thinks that we need.  Similarly, we need to move all local variables
                     76:    down 4 bytes in the stack.  */
                     77: 
                     78: #define STARTING_FRAME_OFFSET -4
                     79: 
                     80: #define FUNCTION_PROLOGUE(FILE, SIZE)     \
                     81: { register int regno;                                          \
                     82:   register int mask = 0;                                       \
                     83:   register int newsize = SIZE + 4;                             \
                     84:   extern char call_used_regs[];                                        \
                     85:   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)      \
                     86:     if (regs_ever_live[regno] && !call_used_regs[regno])       \
                     87:        mask |= 1 << regno;                                     \
                     88:   fprintf (FILE, "\t.word 0x%x\n", mask);                      \
                     89:   MAYBE_VMS_FUNCTION_PROLOGUE(FILE)                            \
                     90:   if (newsize >= 64) fprintf (FILE, "\tmovab %d(sp),sp\n", -newsize);\
                     91:   else fprintf (FILE, "\tsubl2 $%d,sp\n", newsize); }
                     92: 
1.1.1.2   root       93: #define __MAIN_NAME " main("
1.1       root       94: /*
                     95:  * The MAYBE_VMS_FUNCTION_PROLOGUE macro works for both gcc and g++.  It
                     96:  * first checks to see if the current routine is "main", which will only
                     97:  * happen for GCC, and add the jsb if it is.  If is not the case then try and 
                     98:  * see if __MAIN_NAME is part of current_function_name, which will only happen
                     99:  * if we are running g++, and add the jsb if it is.  In gcc there should never
1.1.1.2   root      100:  * be a paren in the function name, and in g++ there is always a "(" in the
1.1       root      101:  * function name, thus there should never be any confusion.
                    102:  *
                    103:  * Adjusting the stack pointer by 4 before calling C$MAIN_ARGS is required
                    104:  * when linking with the VMS POSIX version of the C run-time library; using
                    105:  * `subl2 $4,r0' is adequate but we use `clrl -(sp)' instead.  The extra 4
                    106:  * bytes could be removed after the call because STARTING_FRAME_OFFSET's
                    107:  * setting of -4 will end up adding them right back again, but don't bother.
                    108:  */
                    109: #define MAYBE_VMS_FUNCTION_PROLOGUE(FILE)      \
                    110: { extern char *current_function_name;          \
                    111:   char *p = current_function_name;             \
                    112:   int is_main = strcmp ("main", p) == 0;       \
                    113:   while (!is_main && *p != '\0')               \
                    114:     {                                          \
                    115:       if (*p == *__MAIN_NAME                   \
                    116:          && strncmp (p, __MAIN_NAME, sizeof __MAIN_NAME - sizeof "") == 0) \
                    117:        is_main = 1;                            \
                    118:       else                                     \
                    119:        p++;                                    \
                    120:     }                                          \
                    121:   if (is_main)                                 \
                    122:     fprintf (FILE, "\t%s\n\t%s\n", "clrl -(sp)", "jsb _C$MAIN_ARGS");  \
                    123: }
                    124: 
                    125: /* This macro definition sets up a default value for `main' to return.  */
                    126: #define DEFAULT_MAIN_RETURN  c_expand_return (integer_one_node)
                    127: 
                    128: /* This makes use of a hook in varasm.c to mark all external variables
                    129:    for us.  We use this to make sure that external variables are correctly
                    130:    addressed.  Under VMS there is some brain damage in the linker that requires
                    131:    us to do this.  */
                    132: 
                    133: #define ENCODE_SECTION_INFO(decl)                              \
                    134:   if (DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))              \
                    135:     SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1; 
                    136: 
                    137: /* This is how to output a command to make the user-level label named NAME
                    138:    defined for reference from other files.  */
                    139: 
                    140: #undef ASM_GLOBALIZE_LABEL
                    141: #define ASM_GLOBALIZE_LABEL(FILE,NAME)         \
                    142:   do { fputs (".globl ", FILE);                        \
                    143:        assemble_name (FILE, NAME);             \
                    144:        fputs ("\n", FILE);                     \
1.1.1.3 ! root      145:        vms_check_external (NULL_TREE, NAME, 0); \
1.1       root      146:      } while (0)
                    147: 
                    148: /* Under VMS we write the actual size of the storage to be allocated even
                    149:    though the symbol is external.  Although it is possible to give external
                    150:    symbols a size of 0 (as unix does), the VMS linker does not make the
                    151:    distinction between a variable definition and an external reference of a
                    152:    variable, and thus the linker will not complain about a missing definition.
                    153:    If we followed the unix example of giving external symbols a size of
                    154:    zero, you tried to link a program where a given variable was externally
                    155:    defined but none of the object modules contained a non-extern definition,
                    156:    the linker would allocate 0 bytes for the variable, and any attempt to
                    157:    use that variable would use the storage allocated to some other variable.
                    158: 
                    159:    We must also select either const_section or data_section: this will indicate
                    160:    whether or not the variable will get the readonly bit set.  Since the
                    161:    VMS linker does not distinguish between a variable's definition and an
                    162:    external reference, all usages of a given variable must have the readonly
                    163:    bit set the same way, or the linker will get confused and give warning
                    164:    messages.  */
                    165: 
                    166: /* We used to round the size up to a multiple of 4,
                    167:    but that causes linker errors sometimes when the variable was initialized
                    168:    since the size of its definition was not likewise rounded up.  */
                    169: 
1.1.1.3 ! root      170: /* Note:  the original ASM_OUTPUT_EXTERNAL code has been moved into
        !           171:    vms_check_external and vms_flush_pending_externals.  */
        !           172: 
1.1       root      173: #define ASM_OUTPUT_EXTERNAL(FILE,DECL,NAME)                            \
1.1.1.3 ! root      174: { if (DECL_INITIAL (DECL) == 0 && TREE_CODE (DECL) != FUNCTION_DECL)   \
        !           175:     vms_check_external ((DECL), (NAME), 1);                            \
        !           176: }
        !           177: 
        !           178: /* ASM_OUTPUT_EXTERNAL will have wait until after an initializer is
        !           179:    completed in order to switch sections for an external object, so
        !           180:    use the DECLARE_OBJECT hooks to manage deferred declarations.  */
        !           181: 
        !           182: /* This is the default action for ASM_DECLARE_OBJECT_NAME, but if it
        !           183:    is explicitly defined, then ASM_FINISH_DECLARE_OBJECT will be used.  */
        !           184: 
        !           185: #define ASM_DECLARE_OBJECT_NAME(ASM_OUT_FILE,NAME,DECL)                \
        !           186: { if (output_bytecode)                                         \
        !           187:     BC_OUTPUT_LABEL ((ASM_OUT_FILE), (NAME));                          \
        !           188:   else                                                         \
        !           189:     ASM_OUTPUT_LABEL ((ASM_OUT_FILE), (NAME));                 \
1.1       root      190: }
                    191: 
1.1.1.3 ! root      192: /* We don't need to do anything special to finish the current object, but it
        !           193:    should now be safe to output any deferred external global declarations.  */
        !           194: 
        !           195: #define ASM_FINISH_DECLARE_OBJECT(FILE,DECL,TOPLVL,ATEND)              \
        !           196:   vms_flush_pending_externals(FILE)
        !           197: 
        !           198: /* Anything still pending must be flushed at the very end.  */
        !           199: 
        !           200: #define ASM_FILE_END(STREAM)                                           \
        !           201:   vms_flush_pending_externals(STREAM)
        !           202: 
1.1       root      203: /* Here we redefine ASM_OUTPUT_COMMON to select the data_section or the
                    204:    const_section before writing the ".const" assembler directive.
                    205:    If we were specifying a size of zero for external variables, we would
                    206:    not have to select a section, since the assembler can assume that
                    207:    when the size > 0, the storage is for a non-external, uninitialized
                    208:    variable (for which a "const" declaration would be senseless),
                    209:    and the assembler can make the storage read/write.
                    210: 
                    211:    Since the ".const" directive specifies the actual size of the storage used
                    212:    for both external and non-external variables, the assembler cannot
                    213:    make this assumption, and thus it has no way of deciding if storage should
                    214:    be read/write or read-only.  To resolve this, we give the assembler some
                    215:    assistance, in the form of a ".const" or a ".data" directive.
                    216: 
                    217:    Under GCC 1.40, external variables were declared with a size of zero.
                    218:    The GNU assembler, GAS, will recognize the "-2" switch when built for VMS;
                    219:    when compiling programs with GCC 2.n this switch should be used or the
                    220:    assembler will not give the read-only attribute to external constants.
                    221:    Failure to use this switch will result in linker warning messages about
                    222:    mismatched psect attributes.  */
                    223: 
                    224: #undef ASM_OUTPUT_COMMON
                    225: 
                    226: #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)           \
                    227: ( ((TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl))       \
                    228:    ? (const_section (), 0) : (data_section (), 0)),            \
                    229:   fputs (".comm ", (FILE)),                                    \
                    230:   assemble_name ((FILE), (NAME)),                              \
                    231:   fprintf ((FILE), ",%u\n", (SIZE)))
                    232: 
                    233: /* We define this to prevent the name mangler from putting dollar signs into
                    234:    function names.  This isn't really needed, but it has been here for
                    235:    some time and  removing it would cause the object files generated by the
                    236:    compiler to be incompatible with the object files from a compiler that
                    237:    had this defined.  Since it does no harm, we leave it in.  */
                    238: 
                    239: #define NO_DOLLAR_IN_LABEL
                    240: 
                    241: /* Add a "const" section.  This is viewed by the assembler as being nearly
                    242:    the same as the "data" section, with the only difference being that a
                    243:    flag is set for variables declared while in the const section.  This
                    244:    flag is used to determine whether or not the read/write bit should be
                    245:    set in the Psect definition.  */
                    246: 
                    247: #define EXTRA_SECTIONS in_const
                    248: 
                    249: #define EXTRA_SECTION_FUNCTIONS                                \
                    250: void                                                   \
                    251: const_section ()                                       \
                    252: {                                                      \
                    253:   if (in_section != in_const) {                                \
                    254:     fprintf(asm_out_file,".const\n");                  \
                    255:     in_section = in_const;                             \
                    256:   }                                                    \
                    257: }
                    258: 
                    259: /* This macro contains the logic to decide which section a variable
                    260:    should be stored in.  Static constant variables go in the text_section,
                    261:    non-const variables go in the data_section, and non-static const
                    262:    variables go in the const_section.
                    263: 
                    264:    Since this macro is used in a number of places, we must also be able
                    265:    to decide where to place string constants.  */
                    266: 
                    267: #define SELECT_SECTION(T,RELOC)                                                \
                    268: {                                                                      \
                    269:   if (TREE_CODE (T) == VAR_DECL)                                       \
                    270:     {                                                                  \
1.1.1.3 ! root      271:       if (TREE_READONLY (T) && ! TREE_THIS_VOLATILE (T)                        \
        !           272:          && DECL_INITIAL (T)                                           \
        !           273:          && (DECL_INITIAL (T) == error_mark_node                       \
        !           274:              || TREE_CONSTANT (DECL_INITIAL (T))))                     \
1.1       root      275:        {                                                               \
                    276:          if (TREE_PUBLIC (T))                                          \
                    277:            const_section ();                                           \
                    278:          else                                                          \
                    279:            text_section ();                                            \
                    280:        }                                                               \
                    281:       else                                                             \
                    282:        data_section ();                                                \
                    283:     }                                                                  \
                    284:   if (*tree_code_type[(int) TREE_CODE (T)] == 'c')                     \
                    285:     {                                                                  \
                    286:       if ((TREE_CODE (T) == STRING_CST && flag_writable_strings))      \
                    287:        data_section ();                                                \
                    288:       else                                                             \
                    289:        text_section ();                                                \
                    290:     }                                                                  \
                    291: }
                    292: 
                    293: /* This is used by a hook in varasm.c to write the assembler directives
                    294:    that are needed to tell the startup code which constructors need to
                    295:    be run.  */
                    296: 
                    297: #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                              \
                    298: {                                                                      \
                    299:   fprintf ((FILE),".globl $$PsectAttributes_NOOVR$$__gxx_init_1\n");   \
                    300:   data_section();                                                      \
                    301:   fprintf ((FILE),"$$PsectAttributes_NOOVR$$__gxx_init_1:\n\t.long\t"); \
                    302:   assemble_name ((FILE), (NAME));                                      \
                    303:   fputc ('\n', (FILE));                                                        \
                    304: }
                    305: 
                    306: /* This is used by a hook in varasm.c to write the assembler directives
                    307:    that are needed to tell the startup code which destructors need to
                    308:    be run.  */
                    309: 
                    310: #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                               \
                    311: {                                                                      \
                    312:   fprintf ((FILE),".globl $$PsectAttributes_NOOVR$$__gxx_clean_1\n");  \
                    313:   data_section();                                                      \
                    314:   fprintf ((FILE),"$$PsectAttributes_NOOVR$$__gxx_clean_1:\n\t.long\t");\
                    315:   assemble_name ((FILE), (NAME));                                      \
                    316:   fputc ('\n', (FILE));                                                        \
                    317: }
                    318: 
                    319: /* The following definitions are used in libgcc2.c with the __main
                    320:    function.  The _SHR symbol is used when the sharable image library
                    321:    for libg++ is used - this is picked up automatically by the linker
                    322:    and this symbol points to the start of the __CTOR_LIST__ from libg++.
                    323:    If libg++ is not being used, then __CTOR_LIST_SHR__ occurs just after
                    324:    __CTOR_LIST__, and essentially points to the same list as __CTOR_LIST.  */
                    325: 
                    326: #ifdef L__main
                    327: 
                    328: #define __CTOR_LIST__ __gxx_init_0
                    329: #define __CTOR_LIST_END__ __gxx_init_2
                    330: 
                    331: #define __CTOR_LIST_SHR__ $$PsectAttributes_NOSHR$$__gxx_init_0_shr
                    332: #define __CTOR_LIST_SHR_END__ $$PsectAttributes_NOSHR$$__gxx_init_2_shr
                    333: 
                    334: #define DO_GLOBAL_CTORS_BODY                                           \
                    335: do {                                                                   \
                    336:   func_ptr *p;                                                         \
                    337:   extern func_ptr __CTOR_LIST__[1];                                    \
                    338:   extern func_ptr __CTOR_LIST_END__[1];                                        \
                    339:   extern func_ptr __CTOR_LIST_SHR__[1];                                        \
                    340:   extern func_ptr __CTOR_LIST_SHR_END__[1];                            \
                    341:   if( &__CTOR_LIST_SHR__[0] != &__CTOR_LIST__[1])                      \
                    342:   for (p = __CTOR_LIST_SHR__ + 1; p < __CTOR_LIST_SHR_END__ ; p++ )    \
                    343:     if (*p) (*p) ();                                                   \
                    344:   for (p = __CTOR_LIST__ + 1; p < __CTOR_LIST_END__ ; p++ )            \
                    345:     if (*p) (*p) ();                                                   \
                    346:   atexit (__do_global_dtors);                                          \
                    347:     {                                                                  \
                    348:       __label__ foo;                                                   \
                    349:       int *callers_caller_fp = (int *) __builtin_frame_address (3);    \
                    350:       register int retval asm ("r0");                                  \
                    351:       callers_caller_fp[4] = (int) && foo;                             \
                    352:       return;                                                          \
                    353:     foo:                                                               \
                    354:       exit (retval);                                                   \
                    355:     }                                                                  \
                    356: } while (0)
                    357: 
                    358: #define __DTOR_LIST__ __gxx_clean_0
                    359: #define __DTOR_LIST_END__ __gxx_clean_2
                    360: 
                    361: #define __DTOR_LIST_SHR__ $$PsectAttributes_NOSHR$$__gxx_clean_0_shr
                    362: #define __DTOR_LIST_SHR_END__ $$PsectAttributes_NOSHR$$__gxx_clean_2_shr
                    363: 
                    364: #define DO_GLOBAL_DTORS_BODY                                           \
                    365: do {                                                                   \
                    366:   func_ptr *p;                                                         \
                    367:   extern func_ptr __DTOR_LIST__[1];                                    \
                    368:   extern func_ptr __DTOR_LIST_END__[1];                                        \
                    369:   extern func_ptr __DTOR_LIST_SHR__[1];                                        \
                    370:   extern func_ptr __DTOR_LIST_SHR_END__[1];                            \
                    371:   for (p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__ ; p++ )            \
                    372:     if (*p) (*p) ();                                                   \
                    373:   if( &__DTOR_LIST_SHR__[0] != &__DTOR_LIST__[1])                      \
                    374:   for (p = __DTOR_LIST_SHR__ + 1; p < __DTOR_LIST_SHR_END__ ; p++ )    \
                    375:     if (*p) (*p) ();                                                   \
                    376: } while (0)
                    377: 
                    378: #endif /* L__main */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.