date and time created 88/10/19 11:45:49 by bostic
[unix-history] / usr / src / old / pcc / ccom.vax / INFO
CommitLineData
3ba9dbe1
DS
1Copyright (c) 1985 Regents of the University of California.
2All rights reserved. The Berkeley software License Agreement
3specifies the terms and conditions for redistribution.
4
5 @(#)INFO 5.1 (Berkeley) %G%
6
7HOW TO INTERPRET TEMPLATES:
8
9Goals (represented by 'visit' fields) indicate the shape of what is
10produced by using a template:
11
12 Goal Form of result
13
14 FOREFF Can be used for just side effects. Used for things
15 like initializing data, or gotos.
16 INAREG Result can end up in a register.
17 INTAREG Result can end up in a scratch register.
18 INBREG Result can end up in an index, address or floating
19 point register -- not used on the VAX.
20 INTBREG The same except for temporary index registers.
21 FORCC Condition codes are set.
22 INTEMP Computes into a temporary location.
23 FORARG Computes a function argument onto the stack.
24 FORREW Forces the code generator to rewrite the tree.
25
26Shapes are restrictions on operands:
27
28 Shape Form of operand
29
30 SANY Anything.
31
32 SAREG A register.
33 STAREG A temporary register (one that can be stomped on).
34 SBREG A secondary register -- not used on the VAX.
35 STBREG Ditto except this a temporary register.
36
37 SCON An int (32-bit or smaller) constant.
38 SCCON A short (16-bit) constant.
39 SSCON A char (8-bit) constant.
40 SZERO The constant 0.
41 SONE The constant 1.
42 SMONE The constant -1.
43
44 SCC Condition codes.
45
46 SNAME A constant address; not on the stack or indirect
47 through a pointer.
48
49 SFLD A bit field.
50
51 SOREG A value whose address is the sum of a register and an
52 offset. E.g. 8(ap).
53 SSOREG A 'simple' OREG: not a pointer (e.g. rules out *8(ap)).
54 SWADD A value with an offset that is larger than a byte.
55 STARNM A value whose address is at some known address.
56 An indirect value. E.g. *_a, *8(ap).
57 STARREG Indirect through a register with auto-increment or
58 -decrement.
59
60Types restrict the type of an operand. There are two ways of
61representing types in the compiler; one is a specific type that
62indicates things like indirection, and the other is used as a template
63for the first. To see whether a type matches a template, you call
64ttype(). The template variety is what you see in code templates, and
65has its own typedef, TWORD. Here are some things you can ask for in
66the way of type templates:
67
68 Name What it buys you
69
70 TANY Matches anything 'within reason'.
71
72 TCHAR Chars.
73 TUCHAR Unsigned chars.
74 TSHORT Shorts.
75 TUSHORT Unsigned shorts.
76 TINT Ints.
77 TLONG Longs. (VAX ints.)
78 TULONG Unsigned longs.
79 TUNSIGNED Any unsigned type.
80 TWORD An integral type the size of an int, or a pointer.
81
82 TFLOAT Floats.
83 TDOUBLE Doubles.
84
85 TSTRUCT Structures or unions.
86
87 TPTRTO A pointer. This must be or'ed in with other types;
88 e.g. TPTRTO|TFLOAT|TDOUBLE matches pointers to floats
89 or pointers to doubles. Can be multiply indirect.
90 TPOINT Complex types -- things with stars or brackets or etc.
91
92 WPTR Pointer to anything except structures/unions.
93 ANYSIGNED Pointers or signed integral types.
94 ANYUSIGNED Any unsigned integral type.
95 ANYFIXED Any integral type (excludes floating point or structs).
96
97The template may request special resources. These are indicated by
98things in the needs field of a template:
99
100 Needs Resource wanted
101
102 NAREG Needs a register. Can be multiplied up to 4 times
103 to get up to 4 registers.
104 NBREG Ditto for secondary registers (not used on the VAX).
105 NASL Can share a register with the left operand.
106 NASR Can share a register with the right operand.
107 NTEMP Needs stack space. Can be multiplied up to 8 times.
108 EITHER Don't settle for some of A and some of B.
109
110The template indicates where the results end up, too. The symbols in the
111rewrite field have the following meanings:
112
113 Result Where the result is
114
115 RNULL Don't care about the result -- clobber it.
116 RLEFT Register associated with the left operand.
117 RRIGHT Register associated with the right operand.
118 RESC1 First register requested by 'needs'.
119 RESC2 Second register requested by 'needs'.
120 RESC3 Third register requested by 'needs'.
121 RESCC The condition codes.
122 RNOP Doesn't make anything -- e.g. initializations, gotos.
123
124The assembly language templates contain capital letter abbreviations
125which are expanded in context to whatever is useful. These
126abbreviations may be 1, 2 or 3 characters long; the first character
127codes for the length and generally tells what to do. A standard second
128or third character often indicates the location of an object in the
129following way:
130
131 Modifier Meaning
132
133 L Left operand.
134 R Right operand
135 1, 2, 3 Nth requested register (from 'needs').
136
137Below are the various abbreviations; 'n' is used to indicate one of the
138standard modifiers:
139
140 Abbreviation Rewrites as
141
142 An Address of operand n -- the most common abbreviation.
143 Produces register names, externals, almost everything.
144 Bn Byte offset in a word (? -- not used on VAX).
145 Cn Only constants may be written this way.
146 F The rest of the line is ignored if this value is
147 only being computed for side effects.
148 H Field shift; used with masks and bit fields.
149 In Illegal -- not currently used.
150 L A label.
151 M Field mask.
152 N Field mask, complemented.
153 O[BWLFD] Opcode string; used to rewrite operands of templates
154 with generic opcodes like add, sub, mul. The modifier
155 is changed to lower case and appended. For example if
156 the template is OPFLOAT, the abbreviation is 'OD2' and
157 the current node's operand is OPMUL, you get 'muld2'.
158 S Field size.
159 T Rewriting of the register type is suppressed. I'm not
160 sure what's going on but here's the explanation: 'The C
161 language requires intermediate results to change type.
162 This is inefficient or impossible on some machines; the
163 "T" command in match supresses this type changing.'
164 Un Illegal -- not currently used.
165 Zx Local abbreviations (zzzcode()). The x's are spelled
166 out below:
167 ZA Used for straightforward conversions and assignments.
168 Clever perhaps to excess in its coding.
169 ZB Gets difficult shapes into register prior to a shift.
170 ZC Interpolates the argument count in a function call.
171 ZD Get the value of the operand, then increment or
172 decrement the original, depending on the opcode.
173 ZE Increment or decrement the operand.
174 ZF Produces 'd', 'f' or 'l' depending on whether the
175 right operand (the node itself, for unary operators)
176 is double, float or long; used for moves into register.
177 ZI Produces the appropriate conditional branch.
178 ZL Opcode type [bwlfd] for the left operand.
179 ZN Produces a jump and a clear to get logical values
180 converted into 0 or 1.
181 ZP Just like ZI.
182 ZR Opcode type [bwlfd] for the right operand.
183 ZS Generates a structure assignment.
184 ZT Rounds up structure lengths for struct arguments.
185 ZU Subtracts the value of the constant right operand from
186 32 and uses that for unsigned right shift offsets.
187 ZZ Complements the value of the constant right operand of
188 a bit instruction and produces it.