1 /* 2 * Copyright (c) 1994-2018, NVIDIA CORPORATION. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 /** 19 * \file gbldefs.h 20 * \brief miscellaneous macros and prototypes used by Fortran front-end 21 * Function prototypes and host/version dependent miscellaneous macros used 22 * throughout the Fortran front-end. 23 */ 24 25 #ifndef FE_GBLDEFS_H 26 #define FE_GBLDEFS_H 27 28 #include <stdint.h> 29 #include "universal.h" 30 #include "platform.h" 31 #include "pgifeat.h" 32 #include <scutil.h> 33 34 #define NEW_ARG_PARSER 35 36 /* enable negative zero */ 37 #define USEFNEG 1 38 39 #define FE90 40 #define PGFTN 41 #define PGHPF 42 #define SCFTN 43 #define SCC_SCFTN 44 #define PGC_PGFTN 45 46 #ifndef DEBUG 47 #define DEBUG 1 48 #endif 49 #define DBGBIT(n, m) (flg.dbg[n] & m) 50 51 #define GBL_SIZE_T_FORMAT "zu" 52 53 #define XBIT(n, m) (flg.x[n] & m) 54 #define F77OUTPUT XBIT(49, 0x80) 55 /* This x-bit controls the insertion of scope labels. On by default. */ 56 #define XBIT_USE_SCOPE_LABELS !XBIT(198, 0x40000) 57 58 /* used to determine what kind of runtime descriptor to use */ 59 /* flag to test if using WINNT calling conventions: */ 60 #define WINNT_CALL XBIT(121, 0x10000) 61 #define WINNT_CREF XBIT(121, 0x40000) 62 #define WINNT_NOMIXEDSTRLEN XBIT(121, 0x80000) 63 64 #define CNULL ((char *)0) 65 #undef uf 66 #define uf(s) error(0, 1, gbl.lineno, "Unimplemented feature", s) 67 68 /* Fortran Standard max identifier length (used with -Mstandard) */ 69 #define STANDARD_MAXIDLEN 63 70 71 /* internal max identifier length - allow room for suffix like $sd and $td$ft */ 72 #define MAXIDLEN 163 73 74 /* should replace local MAX_FNAME_LENs with: */ 75 #define MAX_FILENAME_LEN 256 76 77 /* maximum number of array subscripts */ 78 #define MAXSUBS 7 79 80 typedef int8_t INT8; 81 typedef int16_t INT16; 82 typedef uint16_t UINT16; 83 84 /* define a host type which represents 'size_t' for array extents. */ 85 #define ISZ_T BIGINT 86 #define UISZ_T BIGUINT 87 #define ISZ_PF BIGIPFSZ 88 #define ISZ_2_INT64(s, r) bgitoi64(s, r) 89 #define INT64_2_ISZ(s, r) r = i64tobgi(s) 90 91 #define BITS_PER_BYTE 8 92 93 /* ETLS/TLS threadprivate features */ 94 95 typedef int LOGICAL; 96 #undef TRUE 97 #define TRUE 1 98 #undef FALSE 99 #define FALSE 0 100 101 /* 102 * Define truth values for Fortran. The negate operation is dependent 103 * upon the values chosen. 104 */ 105 #define SCFTN_TRUE gbl.ftn_true 106 #define SCFTN_FALSE 0 107 #define SCFTN_NEGATE(n) ((~(n)) & SCFTN_TRUE) 108 109 #define BCOPY(p, q, dt, n) memcpy(p, q, ((UINT)sizeof(dt) * (n))) 110 #define BZERO(p, dt, n) memset((p), 0, ((UINT)sizeof(dt) * (n))) 111 #define FREE(p) sccfree((char *)p), p = NULL 112 113 #if DEBUG 114 #define NEW(p, dt, n) \ 115 if (1) { \ 116 p = (dt *)sccalloc((BIGUINT64)((INT)sizeof(dt) * (n))); \ 117 if (DBGBIT(7, 2)) \ 118 bjunk((char *)(p), (BIGUINT64)((INT)sizeof(dt) * (n))); \ 119 } else 120 #define NEED(n, p, dt, size, newsize) \ 121 if (n > size) { \ 122 p = (dt *)sccrelal((char *)p, ((BIGUINT64)((newsize) * (INT)sizeof(dt)))); \ 123 if (DBGBIT(7, 2)) \ 124 bjunk((char *)(p + size), (BIGUINT64)((newsize - size) * (INT)sizeof(dt))); \ 125 size = newsize; \ 126 } else 127 128 #else 129 #define NEW(p, dt, n) p = (dt *)sccalloc((BIGUINT64)((INT)sizeof(dt) * (n))) 130 #define NEED(n, p, dt, size, newsize) \ 131 if (n > size) { \ 132 p = (dt *)sccrelal((char *)p, ((BIGUINT64)((newsize) * (INT)sizeof(dt)))); \ 133 size = newsize; \ 134 } else 135 #endif 136 137 #define NEEDB(n, p, dt, size, newsize) \ 138 if (n > size) { \ 139 p = (dt *)sccrelal((char *)p, ((BIGUINT64)((newsize) * (INT)sizeof(dt)))); \ 140 BZERO(p + size, dt, newsize - size); \ 141 size = newsize; \ 142 } else 143 144 #include "sharedefs.h" 145 146 #define CLRFPERR() (Fperr = FPE_NOERR) 147 /* NOTE :fperror prints an error message and then sets Fperr to FPE_NOERR */ 148 /* it returns zero if Fperr was equal to FPE_NOERR , otherwise nonzero */ 149 #define CHKFPERR() (Fperr != FPE_NOERR ? fperror() : 0) 150 151 /* declare external functions which are used globally: */ 152 153 void finish(void); /* from main.c */ 154 155 /* mall.c */ 156 char *sccalloc(BIGUINT64); 157 void sccfree(char *); 158 char *sccrelal(char *, BIGUINT64); 159 #ifdef DEBUG 160 void bjunk(void *p, BIGUINT64 n); 161 #endif 162 163 char *getitem(int, int); /* from salloc.c: */ 164 #define GETITEM(area, type) (type *) getitem(area, sizeof(type)) 165 #define GETITEMS(area, type, n) (type *) getitem(area, (n) * sizeof(type)) 166 void freearea(int); 167 int put_getitem_p(void *); 168 void *get_getitem_p(int); 169 void free_getitem_p(void); 170 171 char *mkfname(char *, char *, char *); /* from miscutil.c: */ 172 bool is_xflag_bit(int); 173 void set_xflag(int, INT); 174 void set_yflag(int, INT); 175 void bzero(void *, size_t); 176 void list_init(FILE *); /* listing.c: */ 177 void list_line(char *); /* listing.c */ 178 void list_page(void); /* listing.c */ 179 180 ISZ_T get_bss_addr(void); /* from assem.c */ 181 void assemble(void); 182 void assemble_init(void); 183 void assemble_end(void); 184 ISZ_T set_bss_addr(ISZ_T); 185 ISZ_T pad_cmn_mem(int, ISZ_T, int *); 186 void fix_equiv_locals(int loc_list, ISZ_T loc_addr); 187 void fix_equiv_statics(int loc_list, ISZ_T loc_addr, LOGICAL dinitflg); 188 189 void dbg_print_ast(int, FILE *); 190 void deferred_to_pointer(void); 191 void dumpfgraph(); 192 void dumploops(); 193 void dumpnmes(); 194 void dumpuses(void); 195 void dumpdefs(void); 196 197 /* dump.c */ 198 void dcommons(void); 199 void dumpdts(void); 200 void dstds(int std1, int std2); 201 void dsyms(int l, int u); 202 void dstdps(int std1, int std2); 203 void dumpasts(void); 204 void dumpstdtrees(void); 205 void dumpshapes(void); 206 void dumplists(void); 207 void dsstds(int std1, int std2); 208 209 void dump_ast_tree(int i); /* ast.c */ 210 211 void dumpaccrout(void); /* accroutine.c */ 212 213 void reportarea(int full); /* salloc.c */ 214 void lower_ipa_info(FILE *lowerfile); /* ipa.c */ 215 216 void ipa_init(void); /* ipa.c */ 217 void ipa_startfunc(int currfunc); /* ipa.c */ 218 void ipa_header1(int currfunc); /* ipa.c */ 219 void ipa_header2(int currfunc); /* ipa.c */ 220 void ipa(void); /* ipa.c */ 221 long IPA_sstride(int sptr); /* ipa.c */ 222 long IPA_pstride(int sptr); /* ipa.c */ 223 224 void ipasave_endfunc(void); /* ipasave.c */ 225 void fill_ipasym(void); /* ipasave.c */ 226 227 void ipa_import_highpoint(void); /* interf.c */ 228 void ipa_import(void); /*interf.c */ 229 void ipa_set_vestigial_host(void); /* interf.c */ 230 void import_module_print(void); /* interf.c */ 231 void import_host_subprogram(FILE *fd, char *file_name, int oldsymavl, 232 int oldastavl, int olddtyavl, int modbase, 233 int moddiff); /* interf.c */ 234 void import_fini(void); /* interf.c */ 235 void ipa_import_highpoint(void); /* exterf.c */ 236 void set_tag(void); /* exterf.c */ 237 void ipa_export_endmodule(void); /* exterf.c */ 238 void ipa_export_highpoint(void); /* exterf.c */ 239 void ipa_export_endcontained(void); /* exterf.c */ 240 void exterf_init(void); /* exterf.c */ 241 void exterf_init_host(void); /* exterf.c */ 242 void export_public_module(int module, int exceptlist); /* exterf.c */ 243 void export_inline(FILE *export_fd, char *export_name, 244 char *file_name); /* exterf.c */ 245 246 LOGICAL is_initialized(int *bv, int nme); /* flow.c */ 247 248 int IPA_isnoconflict(int sptr); /* main.c */ 249 void reinit(void); /* main.c */ 250 251 int can_map_initsym(int old_firstosym); /* symtab.c */ 252 int map_initsym(int oldsym, int old_firstosym); /* symtab.c */ 253 int hashcon(INT *value, int dtype, int sptr); 254 255 void end_contained(void); /* main.c */ 256 void set_exitcode(int ec); /* main.c */ 257 258 void eliminate_unused_variables(int which); /* bblock.c */ 259 void bblock_init(void); /* bblock.c */ 260 int bblock(void); /* bblock.c */ 261 void merge_commons(void); /* bblock.c */ 262 void renumber_lines(void); /* bblock.c */ 263 264 void lower_constructor(void); /* lower.c */ 265 void lower_pstride_info(FILE *lowerfile); /* pstride.c */ 266 267 void parse_init(void); 268 269 void fpp(void); /* fpp.c */ 270 271 #if defined(HOST_WIN) 272 #define snprintf _snprintf 273 #endif 274 275 #endif /* FE_GBLDEFS_H */ 276