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