|
|
1.1 root 1: /*
2: * Copyright (c) 1983 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: * @(#)pcc.h 5.1 (Berkeley) 5/30/85
7: */
8:
9: /*
10: * This file contains definitions for all the constants and structures
11: * needed to use the intermediate code files generated and read by
12: * the Portable C Compiler and related compilers.
13: *
14: * Rules for changing this code:
15: * 1) All op values must be integer constants -- this permits us to run
16: * a 'sed' script on this file to create %term declarations for yacc.
17: * 2) Because the PCC uses fancy ASG and UNARY macros, assignment
18: * operators must have values 1 greater than corresponding normal
19: * operators, and unary operators must have values 2 greater ditto.
20: * 3) Ops used only by f1 must have values >= 150 (PCCF_FORTOPS).
21: * 4) Other language-dependent ops must have values >= 200.
22: */
23:
24: # ifndef PCC_TOKENS
25:
26: # define PCC_TOKENS 0
27:
28: # define PCC_ERROR 1 /* an error node */
29: # define PCC_FREE 2 /* an unused node */
30:
31: /*
32: * Constants.
33: */
34: # define PCC_STRING 3 /* a string constant */
35: # define PCC_ICON 4 /* an integer constant */
36: # define PCC_FCON 5 /* a floating point constant */
37: # define PCC_DCON 6 /* a double precision f.p. constant */
38:
39: /*
40: * Leaf types.
41: */
42: # define PCC_NAME 7 /* an identifier */
43: # define PCC_REG 8 /* a register */
44: # define PCC_OREG 9 /* register and offset */
45: # define PCC_CCODES 10 /* condition codes */
46: # define PCC_FLD 11 /* a bit field */
47:
48: /*
49: * Arithmetic operators.
50: */
51: # define PCC_PLUS 12 /* + */
52: # define PCC_PLUSEQ 13 /* += */
53: # define PCC_UPLUS 14 /* unary + (for completeness) */
54: # define PCC_MINUS 15 /* - */
55: # define PCC_MINUSEQ 16 /* -= */
56: # define PCC_UMINUS 17 /* unary - */
57: # define PCC_MUL 18 /* * */
58: # define PCC_MULEQ 19 /* *= */
59: /* Reserve a slot for 'unary *', which is PCC jargon for PCC_DEREF (yech) */
60: # define PCC_DIV 21 /* / */
61: # define PCC_DIVEQ 22 /* /= */
62: # define PCC_MOD 23 /* % */
63: # define PCC_MODEQ 24 /* %= */
64: # define PCC_INCR 25 /* ++ */
65: # define PCC_DECR 26 /* -- */
66: # define PCC_ASSIGN 27 /* = (these last 3 are stretching it) */
67:
68: /*
69: * Bit operators.
70: */
71: # define PCC_AND 28 /* & */
72: # define PCC_ANDEQ 29 /* &= */
73: /* Reserve a slot for 'unary &', jargon for PCC_ADDROF */
74: # define PCC_OR 31 /* | */
75: # define PCC_OREQ 32 /* |= */
76: # define PCC_ER 33 /* ^ */
77: # define PCC_EREQ 34 /* ^= */
78: # define PCC_LS 35 /* << */
79: # define PCC_LSEQ 36 /* <<= */
80: # define PCC_RS 37 /* >> */
81: # define PCC_RSEQ 38 /* >>= */
82: # define PCC_COMPL 39 /* ~ */
83:
84: /*
85: * Booleans.
86: */
87: # define PCC_EQ 40 /* == */
88: # define PCC_NE 41 /* != */
89: # define PCC_LE 42 /* <= */
90: # define PCC_LT 43 /* < */
91: # define PCC_GE 44 /* >= */
92: # define PCC_GT 45 /* > */
93: # define PCC_ULE 46 /* unsigned <= */
94: # define PCC_ULT 47 /* unsigned < */
95: # define PCC_UGE 48 /* unsigned >= */
96: # define PCC_UGT 49 /* unsigned > */
97: # define PCC_QUEST 50 /* ? (for conditional expressions) */
98: # define PCC_COLON 51 /* : (for conditional expressions) */
99: # define PCC_ANDAND 52 /* && */
100: # define PCC_OROR 53 /* || */
101: # define PCC_NOT 54 /* ! */
102:
103: /*
104: * Function calls.
105: */
106: # define PCC_CALL 55 /* call by value */
107: /* no ASG */
108: # define PCC_UCALL 57 /* call with no arguments */
109: # define PCC_FORTCALL 58 /* call by reference? */
110: /* no ASG */
111: # define PCC_UFORTCALL 60 /* ??? */
112: # ifdef INLINE
113: # define PCC_INLINE 61 /* inline function */
114: /* no ASG */
115: # define PCC_UINLINE 63 /* inline with no arguments */
116: # endif INLINE
117:
118: /*
119: * Referencing and dereferencing.
120: */
121: # define PCC_DEREF 20 /* * */
122: # define PCC_ADDROF 30 /* & */
123:
124: /*
125: * Special structure operators.
126: */
127: # define PCC_DOT 64 /* . */
128: # define PCC_STREF 65 /* -> */
129: # define PCC_STASG 66 /* structure assignment */
130: # define PCC_STARG 67 /* an argument of type structure */
131: # define PCC_STCALL 68 /* a function of type structure */
132: /* no ASG */
133: # define PCC_USTCALL 70 /* unary structure function */
134:
135: /*
136: * Conversions.
137: */
138: # define PCC_SCONV 71 /* scalar conversion */
139: # define PCC_PCONV 72 /* pointer conversion */
140: # define PCC_PMCONV 73 /* pointer multiply conversion */
141: # define PCC_PVCONV 74 /* pointer divide conversion */
142: # define PCC_CAST 75 /* redundant? */
143:
144: /*
145: * Bracket types.
146: */
147: # define PCC_LB 76 /* [ */
148: # define PCC_RB 77 /* ] */
149:
150: /*
151: * Comma nodes.
152: */
153: # define PCC_COMOP 78 /* , (in expressions) */
154: # define PCC_CM 79 /* , (in argument lists) */
155:
156: /*
157: * Miscellaneous.
158: */
159: # define PCC_FORCE 80 /* result of last expression goes in r0 */
160: # define PCC_GOTO 81 /* unconditional goto */
161: # define PCC_CBRANCH 82 /* goto label if !test */
162: # define PCC_RETURN 83 /* return from function */
163: # define PCC_INIT 84 /* initialized data */
164: # define PCC_TYPE 85 /* a type */
165: # define PCC_CLASS 86 /* a storage class */
166:
167: # define PCC_MAXOP 86 /* highest numbered PCC op */
168:
169: /*
170: * Special codes for interfacing to /lib/f1.
171: */
172: # define PCCF_FORTOPS 150
173: # define PCCF_FTEXT 150 /* pass literal assembler text */
174: # define PCCF_FEXPR 151 /* a statement */
175: # define PCCF_FSWITCH 152 /* not implemented */
176: # define PCCF_FLBRAC 153 /* beginning of subroutine */
177: # define PCCF_FRBRAC 154 /* end of subroutine */
178: # define PCCF_FEOF 155 /* end of file */
179: # define PCCF_FARIF 156 /* not implemented */
180: # define PCCF_FLABEL 157 /* an f77 label */
181:
182: # endif PCC_TOKENS
183:
184:
185: /*
186: * Types, as encoded in intermediate file cookies.
187: */
188: # define PCCT_UNDEF 0
189: # define PCCT_FARG 1 /* function argument */
190: # define PCCT_CHAR 2
191: # define PCCT_SHORT 3
192: # define PCCT_INT 4
193: # define PCCT_LONG 5
194: # define PCCT_FLOAT 6
195: # define PCCT_DOUBLE 7
196: # define PCCT_STRTY 8
197: # define PCCT_UNIONTY 9
198: # define PCCT_ENUMTY 10
199: # define PCCT_MOETY 11 /* member of enum */
200: # define PCCT_UCHAR 12
201: # define PCCT_USHORT 13
202: # define PCCT_UNSIGNED 14
203: # define PCCT_ULONG 15
204:
205: /*
206: * Type modifiers.
207: */
208: # define PCCTM_PTR 020
209: # define PCCTM_FTN 040
210: # define PCCTM_ARY 060
211: # define PCCTM_BASETYPE 017
212: # define PCCTM_TYPESHIFT 2
213:
214:
215: /*
216: * Useful macros. 'PCCOM' macros apply to ops.
217: */
218: # define PCCOM_ASG 1+
219: # define PCCOM_UNARY 2+
220: # define PCCOM_NOASG (-1)+
221: # define PCCOM_NOUNARY (-2)+
222:
223: # define PCCM_TRIPLE(op, var, type) \
224: ((op) | ((var) << 8) | (long) (type) << 16)
225: # define PCCM_TEXT(s) \
226: PCCM_TRIPLE(PCCF_FTEXT, (strlen(s) + 3) / 4, 0)
227: # define PCCM_ADDTYPE(t, m) \
228: ((((t) &~ PCCTM_BASETYPE) << PCCTM_TYPESHIFT) | \
229: (m) | ((t) & PCCTM_BASETYPE))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.