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

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