1: /*
   2:  * C code generator header
   3:  */
   4: 
   5: #include <stdio.h>
   6: #include <setjmp.h>
   7: 
   8: #define LTYPE   long    /* change to int for no long consts */
   9: #define NULL    0
  10: #define TNULL   (union tree *)NULL
  11: #define UNS(x)  ((unsigned short)(x))
  12: 
  13: /*
  14:  *  Tree node for unary and binary
  15:  */
  16: struct  tnode {
  17:     int op;
  18:     int type;
  19:     int degree;
  20:     union   tree *tr1;
  21:     union   tree *tr2;
  22: };
  23: 
  24: /*
  25:  * tree names for locals
  26:  */
  27: struct  tname {
  28:     int op;
  29:     int type;
  30:     char    class;
  31:     char    regno;
  32:     int offset;
  33:     int nloc;
  34: };
  35: 
  36: /*
  37:  * tree names for externals
  38:  */
  39: struct  xtname {
  40:     int op;
  41:     int type;
  42:     char    class;
  43:     char    regno;
  44:     int offset;
  45:     char    *name;
  46: };
  47: 
  48: /*
  49:  * short constants
  50:  */
  51: struct  tconst {
  52:     int op;
  53:     int type;
  54:     int value;
  55: };
  56: 
  57: /*
  58:  * long constants
  59:  */
  60: struct  lconst {
  61:     int op;
  62:     int type;
  63:     LTYPE   lvalue;
  64: };
  65: 
  66: /*
  67:  * Floating constants
  68:  */
  69: struct  ftconst {
  70:     int op;
  71:     int type;
  72:     int value;
  73:     double  fvalue;
  74: };
  75: 
  76: /*
  77:  * Node used for field assignments
  78:  */
  79: struct  fasgn {
  80:     int op;
  81:     int type;
  82:     int degree;
  83:     union   tree *tr1;
  84:     union   tree *tr2;
  85:     int mask;
  86: };
  87: 
  88: union   tree {
  89:     struct  tnode t;
  90:     struct tname n;
  91:     struct  xtname x;
  92:     struct  tconst c;
  93:     struct  lconst l;
  94:     struct  ftconst f;
  95:     struct  fasgn F;
  96: };
  97: 
  98: struct  optab {
  99:     char    tabdeg1;
 100:     char    tabtyp1;
 101:     char    tabdeg2;
 102:     char    tabtyp2;
 103:     char    *tabstring;
 104: };
 105: 
 106: struct  table {
 107:     int tabop;
 108:     struct  optab *tabp;
 109: };
 110: 
 111: struct  instab {
 112:     int iop;
 113:     char    *str1;
 114:     char    *str2;
 115: };
 116: 
 117: struct  swtab {
 118:     int swlab;
 119:     int swval;
 120: };
 121: 
 122: char    maprel[];
 123: char    notrel[];
 124: int nreg;
 125: int isn;
 126: int line;
 127: int nerror;         /* number of hard errors */
 128: struct  table   cctab[];
 129: struct  table   efftab[];
 130: struct  table   regtab[];
 131: struct  table   sptab[];
 132: struct  table   lsptab[1];
 133: struct  instab  instab[];
 134: struct  instab  branchtab[];
 135: int opdope[];
 136: char    *opntab[];
 137: int nstack;
 138: int nfloat;
 139: struct  tname   sfuncr;
 140: char    *funcbase;
 141: char    *curbase;
 142: char    *coremax;
 143: struct  tconst czero, cone;
 144: long    totspace;
 145: int regpanic;       /* set when SU register alg. fails */
 146: int panicposs;      /* set when there might be need for regpanic */
 147: jmp_buf jmpbuf;
 148: long    ftell();
 149: char    *sbrk();
 150: struct  optab *match();
 151: union   tree *optim();
 152: union   tree *unoptim();
 153: union   tree *pow2();
 154: union   tree *tnode();
 155: union   tree *sdelay();
 156: union   tree *ncopy();
 157: union   tree *getblk();
 158: union   tree *strfunc();
 159: union   tree *isconstant();
 160: union   tree *tconst();
 161: union   tree *hardlongs();
 162: union   tree *lconst();
 163: union   tree *acommute();
 164: union   tree *lvfield();
 165: union   tree *paint();
 166: long    ftell();
 167: 
 168: /*
 169:  * Some special stuff for long comparisons
 170:  */
 171: int xlab1, xlab2, xop, xzero;
 172: 
 173: /*
 174: 	operators
 175: */
 176: #define EOFC    0
 177: #define SEMI    1
 178: #define LBRACE  2
 179: #define RBRACE  3
 180: #define LBRACK  4
 181: #define RBRACK  5
 182: #define LPARN   6
 183: #define RPARN   7
 184: #define COLON   8
 185: #define COMMA   9
 186: #define FSEL    10
 187: #define FSELR   11
 188: #define FSELT   12
 189: #define FSELA   16
 190: #define ULSH    17
 191: #define ASULSH  18
 192: 
 193: #define KEYW    19
 194: #define NAME    20
 195: #define CON 21
 196: #define STRING  22
 197: #define FCON    23
 198: #define SFCON   24
 199: #define LCON    25
 200: #define SLCON   26
 201: 
 202: #define AUTOI   27
 203: #define AUTOD   28
 204: #define NULLOP  218
 205: #define INCBEF  30
 206: #define DECBEF  31
 207: #define INCAFT  32
 208: #define DECAFT  33
 209: #define EXCLA   34
 210: #define AMPER   35
 211: #define STAR    36
 212: #define NEG 37
 213: #define COMPL   38
 214: 
 215: #define DOT 39
 216: #define PLUS    40
 217: #define MINUS   41
 218: #define TIMES   42
 219: #define DIVIDE  43
 220: #define MOD 44
 221: #define RSHIFT  45
 222: #define LSHIFT  46
 223: #define AND 47
 224: #define ANDN    55
 225: #define OR  48
 226: #define EXOR    49
 227: #define ARROW   50
 228: #define ITOF    51
 229: #define FTOI    52
 230: #define LOGAND  53
 231: #define LOGOR   54
 232: #define FTOL    56
 233: #define LTOF    57
 234: #define ITOL    58
 235: #define LTOI    59
 236: #define ITOP    13
 237: #define PTOI    14
 238: #define LTOP    15
 239: 
 240: #define EQUAL   60
 241: #define NEQUAL  61
 242: #define LESSEQ  62
 243: #define LESS    63
 244: #define GREATEQ 64
 245: #define GREAT   65
 246: #define LESSEQP 66
 247: #define LESSP   67
 248: #define GREATQP 68
 249: #define GREATP  69
 250: 
 251: #define ASPLUS  70
 252: #define ASMINUS 71
 253: #define ASTIMES 72
 254: #define ASDIV   73
 255: #define ASMOD   74
 256: #define ASRSH   75
 257: #define ASLSH   76
 258: #define ASAND   77
 259: #define ASOR    78
 260: #define ASXOR   79
 261: #define ASSIGN  80
 262: #define TAND    81
 263: #define LTIMES  82
 264: #define LDIV    83
 265: #define LMOD    84
 266: #define ASANDN  85
 267: #define LASTIMES 86
 268: #define LASDIV  87
 269: #define LASMOD  88
 270: 
 271: #define QUEST   90
 272: /* #define	MAX	93	/* not used; wanted macros in param.h */
 273: #define MAXP    94
 274: /* #define	MIN	95	/* not used; wanted macros in param.h */
 275: #define MINP    96
 276: #define LLSHIFT 91
 277: #define ASLSHL  92
 278: #define SEQNC   97
 279: #define CALL1   98
 280: #define CALL2   99
 281: #define CALL    100
 282: #define MCALL   101
 283: #define JUMP    102
 284: #define CBRANCH 103
 285: #define INIT    104
 286: #define SETREG  105
 287: #define LOAD    106
 288: #define PTOI1   107
 289: #define ITOC    109
 290: #define RFORCE  110
 291: 
 292: /*
 293:  * Intermediate code operators
 294:  */
 295: #define BRANCH  111
 296: #define LABEL   112
 297: #define NLABEL  113
 298: #define RLABEL  114
 299: #define STRASG  115
 300: #define STRSET  116
 301: #define UDIV    117
 302: #define UMOD    118
 303: #define ASUDIV  119
 304: #define ASUMOD  120
 305: #define ULTIMES 121 /* present for symmetry */
 306: #define ULDIV   122
 307: #define ULMOD   123
 308: #define ULASTIMES 124   /* present for symmetry */
 309: #define ULASDIV 125
 310: #define ULASMOD 126
 311: #define ULTOF   127
 312: #define ULLSHIFT 128    /* << for unsigned long */
 313: #define UASLSHL 129 /* <<= for unsigned long */
 314: 
 315: #define BDATA   200
 316: #define PROG    202
 317: #define DATA    203
 318: #define BSS 204
 319: #define CSPACE  205
 320: #define SSPACE  206
 321: #define SYMDEF  207
 322: #define SAVE    208
 323: #define RETRN   209
 324: #define EVEN    210
 325: #define PROFIL  212
 326: #define SWIT    213
 327: #define EXPR    214
 328: #define SNAME   215
 329: #define RNAME   216
 330: #define ANAME   217
 331: #define SETSTK  219
 332: #define SINIT   220
 333: #define GLOBAL  221
 334: #define C3BRANCH    222
 335: #define ASSEM   223
 336: 
 337: /*
 338:  *	types
 339:  */
 340: #define INT 0
 341: #define CHAR    1
 342: #define FLOAT   2
 343: #define DOUBLE  3
 344: #define STRUCT  4
 345: #define RSTRUCT 5
 346: #define LONG    6
 347: #define UNSIGN  7
 348: #define UNCHAR  8
 349: #define UNLONG  9
 350: #define VOID    10
 351: 
 352: #define TYLEN   2
 353: #define TYPE    017
 354: #define XTYPE   (03<<4)
 355: #define PTR 020
 356: #define FUNC    040
 357: #define ARRAY   060
 358: 
 359: /*
 360: 	storage	classes
 361: */
 362: #define KEYWC   1
 363: #define MOS 10
 364: #define AUTO    11
 365: #define EXTERN  12
 366: #define STATIC  13
 367: #define REG 14
 368: #define STRTAG  15
 369: #define ARG 16
 370: #define OFFS    20
 371: #define XOFFS   21
 372: #define SOFFS   22
 373: 
 374: /*
 375: 	Flag	bits
 376: */
 377: 
 378: #define BINARY  01
 379: #define LVALUE  02
 380: #define RELAT   04
 381: #define ASSGOP  010
 382: #define LWORD   020
 383: #define RWORD   040
 384: #define COMMUTE 0100
 385: #define RASSOC  0200
 386: #define LEAF    0400
 387: #define CNVRT   01000

Defined variables

branchtab defined in line 134; used 1 times
cctab defined in line 128; used 17 times
cone defined in line 143; used 2 times
coremax defined in line 142; used 3 times
curbase defined in line 141; used 6 times
czero defined in line 143; used 2 times
efftab defined in line 129; used 16 times
funcbase defined in line 140; used 5 times
instab defined in line 133; used 1 times
isn defined in line 125; used 29 times
jmpbuf defined in line 147; used 2 times
line defined in line 126; used 4 times
lsptab defined in line 132; used 6 times
maprel defined in line 122; used 2 times
nerror defined in line 127; used 2 times
nfloat defined in line 138; used 2 times
notrel defined in line 123; used 3 times
nreg defined in line 124; used 10 times
nstack defined in line 137; used 13 times
opdope defined in line 135; used 34 times
opntab defined in line 136; used 3 times
panicposs defined in line 146; used 4 times
regpanic defined in line 145; used 7 times
regtab defined in line 130; used 15 times
sfuncr defined in line 139; used 6 times
sptab defined in line 131; used 7 times
totspace defined in line 144; used 2 times
xlab1 defined in line 171; used 6 times
xlab2 defined in line 171; used 7 times
xop defined in line 171; used 4 times
xzero defined in line 171; used 7 times

Defined struct's

fasgn defined in line 79; used 6 times
ftconst defined in line 69; used 8 times
instab defined in line 111; used 12 times
lconst defined in line 60; used 12 times
optab defined in line 98; used 10 times
swtab defined in line 117; used 14 times
table defined in line 106; used 30 times
tconst defined in line 51; used 10 times
tname defined in line 27; used 8 times
tnode defined in line 16; used 6 times
xtname defined in line 39; used 6 times

Defined union's

tree defined in line 88; used 224 times

Defined macros

AMPER defined in line 210; used 14 times
ANAME defined in line 330; never used
AND defined in line 223; used 6 times
ANDN defined in line 224; used 4 times
ARG defined in line 369; never used
ARRAY defined in line 357; never used
ARROW defined in line 227; never used
ASAND defined in line 258; used 2 times
ASANDN defined in line 266; used 2 times
ASDIV defined in line 254; used 6 times
ASLSHL defined in line 277; used 2 times
ASMINUS defined in line 252; used 1 times
ASMOD defined in line 255; used 4 times
ASOR defined in line 259; used 2 times
ASPLUS defined in line 251; used 3 times
ASRSH defined in line 256; used 2 times
ASSEM defined in line 335; never used
ASSGOP defined in line 381; used 2 times
ASSIGN defined in line 261; used 7 times
ASTIMES defined in line 253; used 3 times
ASUDIV defined in line 303; used 2 times
ASUMOD defined in line 304; used 1 times
ASXOR defined in line 260; used 1 times
AUTO defined in line 364; used 1 times
AUTOD defined in line 203; used 4 times
AUTOI defined in line 202; used 4 times
BDATA defined in line 315; never used
BINARY defined in line 378; used 9 times
BRANCH defined in line 295; never used
BSS defined in line 318; never used
C3BRANCH defined in line 334; never used
CALL defined in line 281; used 2 times
CALL1 defined in line 279; used 2 times
CALL2 defined in line 280; used 2 times
CBRANCH defined in line 284; used 1 times
CHAR defined in line 341; used 22 times
CNVRT defined in line 387; used 4 times
COLON defined in line 184; used 2 times
COMMA defined in line 185; used 3 times
COMMUTE defined in line 384; used 1 times
CON defined in line 195; used 53 times
CSPACE defined in line 319; never used
DATA defined in line 317; never used
DECAFT defined in line 208; used 5 times
DECBEF defined in line 206; used 2 times
DIVIDE defined in line 219; used 8 times
DOT defined in line 215; never used
DOUBLE defined in line 343; used 7 times
EOFC defined in line 176; never used
EQUAL defined in line 240; used 18 times
EVEN defined in line 324; never used
EXCLA defined in line 209; used 1 times
EXOR defined in line 226; used 2 times
EXPR defined in line 327; used 1 times
EXTERN defined in line 365; used 6 times
FCON defined in line 197; used 11 times
FLOAT defined in line 342; used 5 times
FSEL defined in line 186; used 3 times
FSELA defined in line 189; used 1 times
FSELR defined in line 187; used 1 times
FSELT defined in line 188; used 2 times
FTOI defined in line 229; used 1 times
FTOL defined in line 232; used 2 times
FUNC defined in line 356; never used
GLOBAL defined in line 333; never used
GREAT defined in line 245; used 12 times
GREATEQ defined in line 244; used 6 times
GREATP defined in line 249; used 13 times
GREATQP defined in line 248; used 8 times
INCAFT defined in line 207; used 7 times
INCBEF defined in line 205; used 1 times
INIT defined in line 285; never used
INT defined in line 340; used 38 times
ITOC defined in line 289; never used
ITOF defined in line 228; used 1 times
ITOL defined in line 234; used 19 times
ITOP defined in line 236; used 1 times
JUMP defined in line 283; never used
KEYW defined in line 193; never used
KEYWC defined in line 362; never used
LABEL defined in line 296; never used
LASDIV defined in line 268; used 1 times
LASMOD defined in line 269; used 1 times
LASTIMES defined in line 267; used 2 times
LBRACE defined in line 178; never used
LBRACK defined in line 180; never used
LCON defined in line 199; used 16 times
LDIV defined in line 264; used 1 times
LEAF defined in line 386; used 12 times
LESS defined in line 243; used 12 times
LESSEQ defined in line 242; used 7 times
LESSEQP defined in line 246; used 8 times
LESSP defined in line 247; used 14 times
LLSHIFT defined in line 276; used 3 times
LMOD defined in line 265; used 1 times
LOAD defined in line 287; used 9 times
LOGAND defined in line 230; used 3 times
LOGOR defined in line 231; used 3 times
LONG defined in line 346; used 42 times
LPARN defined in line 182; never used
LSHIFT defined in line 222; used 7 times
LTIMES defined in line 263; used 2 times
LTOF defined in line 233; used 2 times
LTOI defined in line 235; used 12 times
LTOP defined in line 238; never used
LTYPE defined in line 8; used 1 times
  • in line 63
LVALUE defined in line 379; used 1 times
LWORD defined in line 382; never used
MAXP defined in line 273; never used
MCALL defined in line 282; never used
MINP defined in line 275; never used
MOD defined in line 220; used 4 times
MOS defined in line 363; never used
NAME defined in line 194; used 27 times
NEG defined in line 212; used 2 times
NEQUAL defined in line 241; used 15 times
NLABEL defined in line 297; never used
NULL defined in line 9; used 1 times
  • in line 10
NULLOP defined in line 204; never used
OFFS defined in line 370; used 7 times
OR defined in line 225; used 2 times
PLUS defined in line 216; used 23 times
PROFIL defined in line 325; never used
PROG defined in line 316; never used
PTOI defined in line 237; used 3 times
PTOI1 defined in line 288; used 1 times
PTR defined in line 355; used 15 times
QUEST defined in line 271; used 3 times
RASSOC defined in line 385; never used
RBRACE defined in line 179; never used
RBRACK defined in line 181; never used
REG defined in line 367; used 12 times
RELAT defined in line 380; used 14 times
RETRN defined in line 323; never used
RFORCE defined in line 290; used 2 times
RLABEL defined in line 298; never used
RNAME defined in line 329; never used
RPARN defined in line 183; never used
RSHIFT defined in line 221; used 3 times
RSTRUCT defined in line 345; never used
RWORD defined in line 383; never used
SAVE defined in line 322; never used
SEMI defined in line 177; never used
SEQNC defined in line 278; used 3 times
SETREG defined in line 286; never used
SETSTK defined in line 331; never used
SFCON defined in line 198; used 7 times
SINIT defined in line 332; never used
SLCON defined in line 200; never used
SNAME defined in line 328; never used
SOFFS defined in line 372; used 1 times
SSPACE defined in line 320; never used
STAR defined in line 211; used 16 times
STATIC defined in line 366; used 3 times
STRASG defined in line 299; used 2 times
STRING defined in line 196; never used
STRSET defined in line 300; used 1 times
STRTAG defined in line 368; never used
STRUCT defined in line 344; used 11 times
SWIT defined in line 326; never used
SYMDEF defined in line 321; never used
TAND defined in line 262; used 3 times
TIMES defined in line 218; used 14 times
TNULL defined in line 10; used 37 times
TYLEN defined in line 352; used 2 times
TYPE defined in line 353; used 8 times
UASLSHL defined in line 313; used 3 times
UDIV defined in line 301; used 5 times
ULASDIV defined in line 309; used 1 times
ULASMOD defined in line 310; used 1 times
ULASTIMES defined in line 308; used 2 times
ULDIV defined in line 306; used 1 times
ULLSHIFT defined in line 312; used 2 times
ULMOD defined in line 307; used 1 times
ULSH defined in line 190; used 3 times
ULTIMES defined in line 305; used 2 times
ULTOF defined in line 311; used 2 times
UMOD defined in line 302; used 1 times
UNCHAR defined in line 348; used 16 times
UNLONG defined in line 349; used 29 times
UNS defined in line 11; used 21 times
UNSIGN defined in line 347; used 19 times
VOID defined in line 350; used 1 times
XOFFS defined in line 371; used 2 times
XTYPE defined in line 354; used 6 times

Usage of this include

Last modified: 1993-07-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 6632
Valid CSS Valid XHTML 1.0 Strict