1: /* 2: * Copyright (c) 1980 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: * 6: * @(#)defs.h 5.3 (Berkeley) 1/10/86 7: */ 8: 9: /* 10: * defs.h 11: * 12: * Definitions for f77pass1 13: * 14: * University of Utah CS Dept modification history: 15: * 16: * $Log: defs.h,v $ 17: * Revision 5.5 86/01/10 17:11:11 donn 18: * Add a vparamval field to Nameblock struct -- fix up klugy sharing between 19: * Paramblock and Nameblock structs. 20: * 21: * Revision 5.4 85/11/25 00:23:47 donn 22: * 4.3 beta 23: * 24: * Revision 5.3 85/08/10 06:31:09 donn 25: * Added missing definition for intrconv(). 26: * 27: * Revision 5.2 85/08/10 04:01:53 donn 28: * Jerry Berkman's change to add a definition for 'dblflag' and to ifdef 29: * the Fortran 66 compatibility flags. 30: * 31: * Revision 5.1 85/08/10 03:44:01 donn 32: * 4.3 alpha 33: * 34: * Revision 2.3 85/06/07 21:06:48 root 35: * Add copyright 36: * 37: * Revision 2.2 85/01/11 21:02:58 donn 38: * Added 'issaved' bit to addrblocks to help implement SAVE statements. 39: * 40: * Revision 2.1 84/07/19 12:02:46 donn 41: * Changed comment headers for UofU. 42: * 43: * Revision 1.2 84/02/27 00:49:40 donn 44: * Added external references to lists of argument temporaries, used in the 45: * Berkeley changes to reduce offsets of data. 46: * 47: */ 48: 49: #include <stdio.h> 50: 51: #ifdef unix 52: # include <ctype.h> 53: #endif 54: 55: #include "ftypes.h" 56: #include "defines.h" 57: #include "machdefs.h" 58: 59: #define VL 16 60: 61: #define MAXDIM 20 62: #define MAXINCLUDES 10 63: #define MAXLITERALS 30 64: #define MAXCTL 20 65: #define MAXHASH 1009 66: #define MAXSTNO 401 67: #define MAXEXT 200 68: #define MAXEQUIV 150 69: #define MAXLABLIST 256 70: #define MAXDEBUGFLAG 20 71: 72: typedef union Expression *expptr; 73: typedef union Taggedblock *tagptr; 74: typedef struct Chain *chainp; 75: typedef struct Addrblock *Addrp; 76: typedef struct Tempblock *Tempp; 77: typedef struct Constblock *Constp; 78: typedef struct Exprblock *Exprp; 79: typedef struct Nameblock *Namep; 80: 81: extern FILEP infile; 82: extern FILEP diagfile; 83: extern FILEP textfile; 84: extern FILEP asmfile; 85: extern FILEP initfile; 86: extern long int headoffset; 87: 88: extern char token [ ]; 89: extern int toklen; 90: extern int lineno; 91: extern char *infname; 92: extern int needkwd; 93: extern struct Labelblock *thislabel; 94: 95: extern int maxctl; 96: extern int maxequiv; 97: extern int maxstno; 98: extern int maxhash; 99: extern int maxext; 100: 101: extern flag profileflag; 102: extern flag dblflag; 103: extern flag optimflag; 104: extern flag nowarnflag; 105: extern flag ftn66flag; 106: #ifdef ONLY66 107: extern flag no66flag; 108: extern flag noextflag; 109: #endif 110: extern flag shiftcase; 111: extern flag undeftype; 112: extern flag shortsubs; 113: extern flag onetripflag; 114: extern flag checksubs; 115: extern flag debugflag[]; 116: extern flag equivdcl; 117: extern int nerr; 118: extern int nwarn; 119: extern int ndata; 120: 121: extern int parstate; 122: extern flag headerdone; 123: extern int blklevel; 124: extern flag saveall; 125: extern flag substars; 126: extern int impltype[ ]; 127: extern int implleng[ ]; 128: extern int implstg[ ]; 129: 130: extern int tyint; 131: extern int tylogical; 132: extern ftnint typesize[]; 133: extern int typealign[]; 134: extern int procno; 135: extern int proctype; 136: extern char * procname; 137: extern int rtvlabel[ ]; 138: extern int fudgelabel; /* to confuse the pdp11 optimizer */ 139: extern Addrp typeaddr; 140: extern Addrp retslot; 141: extern int cxslot; 142: extern int chslot; 143: extern int chlgslot; 144: extern int procclass; 145: extern ftnint procleng; 146: extern int nentry; 147: extern flag multitype; 148: extern int blklevel; 149: extern int lastlabno; 150: extern int lastvarno; 151: extern int lastargslot; 152: extern int argloc; 153: extern ftnint autoleng; 154: extern ftnint bssleng; 155: extern int retlabel; 156: extern int ret0label; 157: extern int dorange; 158: extern int regnum[ ]; 159: extern Namep regnamep[ ]; 160: extern int maxregvar; 161: extern int highregvar; 162: extern int nregvar; 163: extern ftnint lowbss; 164: extern ftnint highbss; 165: extern int bsslabel; 166: extern flag anyinits; 167: extern flag anylocals; 168: 169: extern chainp templist; 170: extern chainp argtemplist; 171: extern chainp activearglist; 172: extern int maxdim; 173: extern chainp holdtemps; 174: extern struct Entrypoint *entries; 175: extern struct Rplblock *rpllist; 176: extern struct Chain *curdtp; 177: extern ftnint curdtelt; 178: extern flag toomanyinit; 179: 180: extern flag inioctl; 181: extern int iostmt; 182: extern Addrp ioblkp; 183: extern int nioctl; 184: extern int nequiv; 185: extern int eqvstart; /* offset to eqv number to guarantee uniqueness */ 186: extern int nintnames; 187: 188: #ifdef SDB 189: extern int dbglabel; 190: extern flag sdbflag; 191: #endif 192: 193: extern int cdatafile; 194: extern int cchkfile; 195: extern int vdatafile; 196: extern int vchkfile; 197: 198: extern char cdatafname[]; 199: extern char cchkfname[]; 200: extern char vdatafname[]; 201: extern char vchkfname[]; 202: 203: extern long cdatahwm; 204: extern long vdatahwm; 205: 206: 207: struct Chain 208: { 209: chainp nextp; 210: tagptr datap; 211: }; 212: 213: extern chainp chains; 214: 215: struct Headblock 216: { 217: field tag; 218: field vtype; 219: field vclass; 220: field vstg; 221: expptr vleng; 222: } ; 223: 224: struct Ctlframe 225: { 226: unsigned ctltype:8; 227: unsigned dostepsign:8; 228: int ctlabels[4]; 229: int dolabel; 230: Namep donamep; 231: expptr domax; 232: expptr dostep; 233: }; 234: #define endlabel ctlabels[0] 235: #define elselabel ctlabels[1] 236: #define dobodylabel ctlabels[1] 237: #define doposlabel ctlabels[2] 238: #define doneglabel ctlabels[3] 239: extern struct Ctlframe *ctls; 240: extern struct Ctlframe *ctlstack; 241: extern struct Ctlframe *lastctl; 242: 243: struct Extsym 244: { 245: char extname[XL+1]; 246: field extstg; 247: unsigned extsave:1; 248: unsigned extinit:1; 249: chainp extp; 250: ftnint extleng; 251: ftnint maxleng; 252: char init; 253: long initoffset; 254: }; 255: 256: extern struct Extsym *extsymtab; 257: extern struct Extsym *nextext; 258: extern struct Extsym *lastext; 259: 260: struct Labelblock 261: { 262: int labelno; 263: unsigned blklevel:8; 264: unsigned labused:1; 265: unsigned labinacc:1; 266: unsigned labdefined:1; 267: unsigned labtype:2; 268: ftnint stateno; 269: }; 270: 271: extern struct Labelblock *labeltab; 272: extern struct Labelblock *labtabend; 273: extern struct Labelblock *highlabtab; 274: 275: struct Entrypoint 276: { 277: struct Entrypoint *entnextp; 278: struct Extsym *entryname; 279: chainp arglist; 280: int entrylabel; 281: int typelabel; 282: Namep enamep; 283: }; 284: 285: struct Primblock 286: { 287: field tag; 288: field vtype; 289: Namep namep; 290: struct Listblock *argsp; 291: expptr fcharp; 292: expptr lcharp; 293: }; 294: 295: 296: struct Hashentry 297: { 298: int hashval; 299: Namep varp; 300: }; 301: extern struct Hashentry *hashtab; 302: extern struct Hashentry *lasthash; 303: 304: struct Intrpacked /* bits for intrinsic function description */ 305: { 306: unsigned f1:3; 307: unsigned f2:4; 308: unsigned f3:7; 309: }; 310: 311: struct Nameblock 312: { 313: field tag; 314: field vtype; 315: field vclass; 316: field vstg; 317: expptr vleng; 318: char varname[VL]; 319: expptr vparamval; 320: unsigned vdovar:1; 321: unsigned vdcldone:1; 322: unsigned vadjdim:1; 323: unsigned vsave:1; 324: unsigned vprocclass:3; 325: unsigned vregno:4; 326: union { 327: int varno; 328: struct Intrpacked intrdesc; /* bits for intrinsic function*/ 329: } vardesc; 330: struct Dimblock *vdim; 331: ftnint voffset; 332: union { 333: chainp namelist; /* points to chain of names in */ 334: chainp vstfdesc; /* points to (formals, expr) pair */ 335: } varxptr; 336: char inlcomm; 337: char init; 338: long initoffset; 339: ftnint varsize; 340: }; 341: 342: 343: struct Paramblock 344: { 345: field tag; 346: field vtype; 347: field vclass; 348: field vstg; 349: expptr vleng; 350: char varname[VL]; 351: expptr paramval; 352: } ; 353: 354: 355: struct Exprblock 356: { 357: field tag; 358: field vtype; 359: field vclass; 360: field vstg; 361: expptr vleng; 362: unsigned opcode:6; 363: expptr leftp; 364: expptr rightp; 365: }; 366: 367: 368: union Constant 369: { 370: char *ccp; 371: ftnint ci; 372: double cd[2]; 373: }; 374: 375: struct Constblock 376: { 377: field tag; 378: field vtype; 379: field vclass; 380: field vstg; 381: expptr vleng; 382: union Constant const; 383: }; 384: 385: 386: struct Listblock 387: { 388: field tag; 389: field vtype; 390: chainp listp; 391: }; 392: 393: 394: 395: struct Addrblock 396: { 397: field tag; 398: field vtype; 399: field vclass; 400: field vstg; 401: expptr vleng; 402: int memno; 403: expptr memoffset; 404: unsigned istemp:1; 405: unsigned isarray:1; 406: unsigned issaved:1; 407: unsigned ntempelt:10; 408: ftnint varleng; 409: ftnint varsize; 410: }; 411: 412: 413: 414: struct Tempblock 415: { 416: field tag; 417: field vtype; 418: field vclass; 419: expptr vleng; 420: Addrp memalloc; 421: unsigned istemp:1; 422: unsigned ntempelt:10; 423: ftnint varleng; 424: }; 425: 426: 427: 428: struct Errorblock 429: { 430: field tag; 431: field vtype; 432: }; 433: 434: 435: union Expression 436: { 437: field tag; 438: struct Headblock headblock; 439: struct Exprblock exprblock; 440: struct Addrblock addrblock; 441: struct Tempblock tempblock; 442: struct Constblock constblock; 443: struct Errorblock errorblock; 444: struct Listblock listblock; 445: struct Primblock primblock; 446: } ; 447: 448: 449: 450: struct Dimblock 451: { 452: int ndim; 453: expptr nelt; 454: expptr baseoffset; 455: expptr basexpr; 456: struct 457: { 458: expptr dimsize; 459: expptr dimexpr; 460: expptr lb; 461: expptr lbaddr; 462: expptr ub; 463: expptr ubaddr; 464: } dims[1]; 465: }; 466: 467: 468: struct Impldoblock 469: { 470: field tag; 471: unsigned isactive:1; 472: unsigned isbusy:1; 473: Namep varnp; 474: Constp varvp; 475: chainp impdospec; 476: expptr implb; 477: expptr impub; 478: expptr impstep; 479: ftnint impdiff; 480: ftnint implim; 481: struct Chain *datalist; 482: }; 483: 484: 485: struct Rplblock /* name replacement block */ 486: { 487: struct Rplblock *rplnextp; 488: Namep rplnp; 489: expptr rplvp; 490: expptr rplxp; 491: int rpltag; 492: }; 493: 494: 495: 496: struct Equivblock 497: { 498: struct Eqvchain *equivs; 499: flag eqvinit; 500: long int eqvtop; 501: long int eqvbottom; 502: char inlcomm; 503: char init; 504: long initoffset; 505: } ; 506: #define eqvleng eqvtop 507: 508: extern struct Equivblock *eqvclass; 509: 510: 511: struct Eqvchain 512: { 513: struct Eqvchain *eqvnextp; 514: union 515: { 516: struct Primblock *eqvlhs; 517: Namep eqvname; 518: } eqvitem; 519: long int eqvoffset; 520: } ; 521: 522: 523: union Taggedblock 524: { 525: field tag; 526: struct Headblock headblock; 527: struct Nameblock nameblock; 528: struct Paramblock paramblock; 529: struct Exprblock exprblock; 530: struct Constblock constblock; 531: struct Listblock listblock; 532: struct Addrblock addrblock; 533: struct Tempblock tempblock; 534: struct Errorblock errorblock; 535: struct Primblock primblock; 536: struct Impldoblock impldoblock; 537: } ; 538: 539: 540: 541: 542: struct Literal 543: { 544: short littype; 545: short litnum; 546: union { 547: ftnint litival; 548: double litdval; 549: struct { 550: char litclen; /* small integer */ 551: char litcstr[XL]; 552: } litcval; 553: } litval; 554: }; 555: 556: extern struct Literal litpool[ ]; 557: extern int nliterals; 558: 559: 560: 561: /* popular functions with non integer return values */ 562: 563: 564: int *ckalloc(); 565: char *varstr(), *nounder(), *varunder(); 566: char *copyn(), *copys(); 567: chainp hookup(), mkchain(); 568: ftnint convci(); 569: char *convic(); 570: char *setdoto(); 571: double convcd(); 572: Namep mkname(); 573: struct Labelblock *mklabel(), *execlab(); 574: struct Extsym *mkext(), *newentry(); 575: expptr addrof(), call1(), call2(), call3(), call4(); 576: Tempp mktmpn(); 577: Addrp builtin(), mktemp(), altmpn(), mkaltemp(), mkaltmpn(), autovar(); 578: Addrp mkplace(), mkaddr(), putconst(), memversion(); 579: expptr mkprim(), mklhs(), mkexpr(), mkconv(), intrconv(), mkfunct(); 580: expptr fixexpr(), fixtype(); 581: expptr errnode(), mkintcon(); 582: tagptr cpexpr(); 583: ftnint lmin(), lmax(), iarrlen();