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