annotate src/share/vm/adlc/Doc/Syntax.doc @ 605:98cb887364d3

6810672: Comment typos Summary: I have collected some typos I have found while looking at the code. Reviewed-by: kvn, never
author twisti
date Fri, 27 Feb 2009 13:27:09 -0800
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 #
a61af66fc99e Initial load
duke
parents:
diff changeset
2 # Copyright 1997-1998 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 #
a61af66fc99e Initial load
duke
parents:
diff changeset
5 # This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 # under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 # published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 #
a61af66fc99e Initial load
duke
parents:
diff changeset
9 # This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 # version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 # accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 #
a61af66fc99e Initial load
duke
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 # 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 #
a61af66fc99e Initial load
duke
parents:
diff changeset
19 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 # CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 # have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 #
a61af66fc99e Initial load
duke
parents:
diff changeset
23 #
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 JavaSoft HotSpot Architecture Description Language Syntax Specification
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 Version 0.4 - September 19, 1997
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 A. Introduction
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 This document specifies the syntax and associated semantics for the JavaSoft
a61af66fc99e Initial load
duke
parents:
diff changeset
32 HotSpot Architecture Description Language. This language is used to describe
a61af66fc99e Initial load
duke
parents:
diff changeset
33 the architecture of a processor, and is the input to the ADL Compiler. The
a61af66fc99e Initial load
duke
parents:
diff changeset
34 ADL Compiler compiles an ADL file into code which is incorporated into the
a61af66fc99e Initial load
duke
parents:
diff changeset
35 Optimizing Just In Time Compiler (OJIT) to generate efficient and correct code
a61af66fc99e Initial load
duke
parents:
diff changeset
36 for the target architecture. The ADL describes three bassic different types
a61af66fc99e Initial load
duke
parents:
diff changeset
37 of architectural features. It describes the instruction set (and associated
a61af66fc99e Initial load
duke
parents:
diff changeset
38 operands) of the target architecture. It describes the register set of the
a61af66fc99e Initial load
duke
parents:
diff changeset
39 target architecture along with relevant information for the register allocator.
a61af66fc99e Initial load
duke
parents:
diff changeset
40 Finally, it describes the architecture's pipeline for scheduling purposes.
a61af66fc99e Initial load
duke
parents:
diff changeset
41 The ADL is used to create an architecture description file for a target
a61af66fc99e Initial load
duke
parents:
diff changeset
42 architecture. The architecture description file along with some additional
a61af66fc99e Initial load
duke
parents:
diff changeset
43 target specific oracles, written in C++, represent the principal effort in
a61af66fc99e Initial load
duke
parents:
diff changeset
44 porting the OJIT to a new target architecture.
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 B. Example Syntax
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 1. Instruction/Operand Syntax for Matching and Encoding
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Create a cost attribute for all operands, and specify the default value
a61af66fc99e Initial load
duke
parents:
diff changeset
52 op_attrib op_cost(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Create a cost attribute for all instruction, and specify a default value
a61af66fc99e Initial load
duke
parents:
diff changeset
55 ins_attrib ins_cost(100);
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // example operand form
a61af66fc99e Initial load
duke
parents:
diff changeset
58 operand x_reg(REG_NUM rnum)
a61af66fc99e Initial load
duke
parents:
diff changeset
59 %{
a61af66fc99e Initial load
duke
parents:
diff changeset
60 constraint(IS_RCLASS(rnum, RC_X_REG));
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 match(VREG) %{ rnum = new_VR(); %} // block after rule is constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 encode %{ return rnum; %} // encode rules are required
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // this operand has no op_cost entry because it uses the default value
a61af66fc99e Initial load
duke
parents:
diff changeset
67 %}
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // example instruction form
a61af66fc99e Initial load
duke
parents:
diff changeset
70 instruct add_accum_reg(x_reg dst, reg src)
a61af66fc99e Initial load
duke
parents:
diff changeset
71 %{
a61af66fc99e Initial load
duke
parents:
diff changeset
72 match(SET dst (PLUS dst src)); // no block = use default constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 encode // rule is body of a C++ function
a61af66fc99e Initial load
duke
parents:
diff changeset
75 %{
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return pentium_encode_add_accum_reg(rnum);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 %}
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 ins_cost(200); // this instruction is more costly than the default
a61af66fc99e Initial load
duke
parents:
diff changeset
80 %}
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 2. Register Set Description Syntax for Allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 reg_def AX(SOE, 1); // declare register AX, mark it save on entry with index 0
a61af66fc99e Initial load
duke
parents:
diff changeset
85 reg_def BX(SOC); // declare register BX, and mark it save on call
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 reg_class X_REG(AX, BX); // form a matcher register class of X_REG
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // these are used for constraints, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 alloc_class class1(AX, BX); // form an allocation class of registers
605
98cb887364d3 6810672: Comment typos
twisti
parents: 0
diff changeset
91 // used by the register allocator for separate
0
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // allocation of target register classes
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 3. Pipeline Syntax for Scheduling
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 C. Keywords
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 1. Matching/Encoding
a61af66fc99e Initial load
duke
parents:
diff changeset
100 a. instruct - indicates a machine instruction entry
a61af66fc99e Initial load
duke
parents:
diff changeset
101 b. operand - indicates a machine operand entry
a61af66fc99e Initial load
duke
parents:
diff changeset
102 c. opclass - indicates a class of machine operands
a61af66fc99e Initial load
duke
parents:
diff changeset
103 d. source - indicates a block of C++ source code
a61af66fc99e Initial load
duke
parents:
diff changeset
104 e. op_attrib - indicates an optional attribute for all operands
a61af66fc99e Initial load
duke
parents:
diff changeset
105 f. ins_attrib - indicates an optional attribute for all instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
106 g. match - indicates a matching rule for an operand/instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
107 h. encode - indicates an encoding rule for an operand/instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
108 i. predicate - indicates a predicate for matching operand/instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
109 *j. constraint - indicates a constraint on the value of an operand
a61af66fc99e Initial load
duke
parents:
diff changeset
110 *k. effect - describes the dataflow effect of an operand which
a61af66fc99e Initial load
duke
parents:
diff changeset
111 is not part of a match rule
a61af66fc99e Initial load
duke
parents:
diff changeset
112 *l. expand - indicates a single instruction for matching which
a61af66fc99e Initial load
duke
parents:
diff changeset
113 expands to multiple instructions for output
a61af66fc99e Initial load
duke
parents:
diff changeset
114 *m. rewrite - indicates a single instruction for matching which
a61af66fc99e Initial load
duke
parents:
diff changeset
115 gets rewritten to one or more instructions after
a61af66fc99e Initial load
duke
parents:
diff changeset
116 allocation depending upon the registers allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
117 *n. format - indicates a format rule for an operand/instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
118 o. construct - indicates a default constructor for an operand
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 [NOTE: * indicates a feature which will not be in first release ]
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 2. Register
a61af66fc99e Initial load
duke
parents:
diff changeset
123 *a. register - indicates an architecture register definition section
a61af66fc99e Initial load
duke
parents:
diff changeset
124 *b. reg_def - indicates a register declaration
a61af66fc99e Initial load
duke
parents:
diff changeset
125 *b. reg_class - indicates a class (list) of registers for matching
a61af66fc99e Initial load
duke
parents:
diff changeset
126 *c. alloc_class - indicates a class (list) of registers for allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 3. Pipeline
a61af66fc99e Initial load
duke
parents:
diff changeset
129 *a. pipeline - indicates an architecture pipeline definition section
a61af66fc99e Initial load
duke
parents:
diff changeset
130 *b. resource - indicates a pipeline resource used by instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
131 *c. pipe_desc - indicates the relevant stages of the pipeline
a61af66fc99e Initial load
duke
parents:
diff changeset
132 *d. pipe_class - indicates a description of the pipeline behavior
a61af66fc99e Initial load
duke
parents:
diff changeset
133 for a group of instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
134 *e. ins_pipe - indicates what pipeline class an instruction is in
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 D. Delimiters
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 1. Comments
a61af66fc99e Initial load
duke
parents:
diff changeset
140 a. /* ... */ (like C code)
a61af66fc99e Initial load
duke
parents:
diff changeset
141 b. // ... EOL (like C++ code)
a61af66fc99e Initial load
duke
parents:
diff changeset
142 c. Comments must be preceeded by whitespace
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 2. Blocks
a61af66fc99e Initial load
duke
parents:
diff changeset
145 a. %{ ... %} (% just distinguishes from C++ syntax)
a61af66fc99e Initial load
duke
parents:
diff changeset
146 b. Must be whitespace before and after block delimiters
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 3. Terminators
a61af66fc99e Initial load
duke
parents:
diff changeset
149 a. ; (standard statement terminator)
a61af66fc99e Initial load
duke
parents:
diff changeset
150 b. %} (block terminator)
a61af66fc99e Initial load
duke
parents:
diff changeset
151 c. EOF (file terminator)
a61af66fc99e Initial load
duke
parents:
diff changeset
152
605
98cb887364d3 6810672: Comment typos
twisti
parents: 0
diff changeset
153 4. Each statement must start on a separate line
0
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 5. Identifiers cannot contain: (){}%;,"/\
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 E. Instruction Form: instruct instr1(oper1 dst, oper2 src) %{ ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 1. Identifier (scope of all instruction names is global in ADL file)
a61af66fc99e Initial load
duke
parents:
diff changeset
160 2. Operands
a61af66fc99e Initial load
duke
parents:
diff changeset
161 a. Specified in argument style: (<type> <name>, ...)
a61af66fc99e Initial load
duke
parents:
diff changeset
162 b. Type must be the name of an Operand Form
a61af66fc99e Initial load
duke
parents:
diff changeset
163 c. Name is a locally scoped name, used for substitution, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
164 3. Match Rule: match(SET dst (PLUS dst src));
a61af66fc99e Initial load
duke
parents:
diff changeset
165 a. Parenthesized Inorder Binary Tree: [lft = left; rgh = right]
a61af66fc99e Initial load
duke
parents:
diff changeset
166 (root root->lft (root->rgh (root->rgh->lft root->rgh->rgh)))
a61af66fc99e Initial load
duke
parents:
diff changeset
167 b. Interior nodes in tree are operators (nodes) in abstract IR
a61af66fc99e Initial load
duke
parents:
diff changeset
168 c. Leaves are operands from instruction operand list
a61af66fc99e Initial load
duke
parents:
diff changeset
169 d. Assignment operation and destination, which are implicit
a61af66fc99e Initial load
duke
parents:
diff changeset
170 in the abstract IR, must be specified in the match rule.
a61af66fc99e Initial load
duke
parents:
diff changeset
171 4. Encode Rule: encode %{ return CONST; %}
a61af66fc99e Initial load
duke
parents:
diff changeset
172 a. Block form must contain C++ code which constitutes the
a61af66fc99e Initial load
duke
parents:
diff changeset
173 body of a C++ function which takes no arguments, and
a61af66fc99e Initial load
duke
parents:
diff changeset
174 returns an integer.
a61af66fc99e Initial load
duke
parents:
diff changeset
175 b. Local names (operand names) are can be used as substitution
a61af66fc99e Initial load
duke
parents:
diff changeset
176 symbols in the code.
a61af66fc99e Initial load
duke
parents:
diff changeset
177 5. Attribute (ins_attrib): ins_cost(37);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 a. Identifier (must be name defined as instruction attribute)
a61af66fc99e Initial load
duke
parents:
diff changeset
179 b. Argument must be a constant value or a C++ expression which
a61af66fc99e Initial load
duke
parents:
diff changeset
180 evaluates to a constant at compile time.
a61af66fc99e Initial load
duke
parents:
diff changeset
181 *6. Effect: effect(src, OP_KILL);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 a. Arguments must be the name of an operand and one of the
a61af66fc99e Initial load
duke
parents:
diff changeset
183 pre-defined effect type symbols:
a61af66fc99e Initial load
duke
parents:
diff changeset
184 OP_DEF, OP_USE, OP_KILL, OP_USE_DEF, OP_DEF_USE, OP_USE_KILL
a61af66fc99e Initial load
duke
parents:
diff changeset
185 *7. Expand:
a61af66fc99e Initial load
duke
parents:
diff changeset
186 a. Parameters for the new instructions must be the name of
a61af66fc99e Initial load
duke
parents:
diff changeset
187 an expand rule temporary operand or must match the local
a61af66fc99e Initial load
duke
parents:
diff changeset
188 operand name in both the instruction being expanded and
a61af66fc99e Initial load
duke
parents:
diff changeset
189 the new instruction being generated.
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 instruct convI2B( xRegI dst, eRegI src ) %{
a61af66fc99e Initial load
duke
parents:
diff changeset
192 match(Set dst (Conv2B src));
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 expand %{
a61af66fc99e Initial load
duke
parents:
diff changeset
195 eFlagsReg cr;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 loadZero(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 testI_zero(cr,src);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 set_nz(dst,cr);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 %}
a61af66fc99e Initial load
duke
parents:
diff changeset
200 %}
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Move zero into a register without setting flags
a61af66fc99e Initial load
duke
parents:
diff changeset
202 instruct loadZero(eRegI dst) %{
a61af66fc99e Initial load
duke
parents:
diff changeset
203 effect( DEF dst );
a61af66fc99e Initial load
duke
parents:
diff changeset
204 format %{ "MOV $dst,0" %}
a61af66fc99e Initial load
duke
parents:
diff changeset
205 opcode(0xB8); // +rd
a61af66fc99e Initial load
duke
parents:
diff changeset
206 ins_encode( LdI0(dst) );
a61af66fc99e Initial load
duke
parents:
diff changeset
207 %}
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 *8. Rewrite
a61af66fc99e Initial load
duke
parents:
diff changeset
210 9. Format: format(add_X $src, $dst); | format %{ ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
211 a. Argument form takes a text string, possibly containing
a61af66fc99e Initial load
duke
parents:
diff changeset
212 some substitution symbols, which will be printed out
a61af66fc99e Initial load
duke
parents:
diff changeset
213 to the assembly language file.
a61af66fc99e Initial load
duke
parents:
diff changeset
214 b. The block form takes valid C++ code which forms the body
a61af66fc99e Initial load
duke
parents:
diff changeset
215 of a function which takes no arguments, and returns a
a61af66fc99e Initial load
duke
parents:
diff changeset
216 pointer to a string to print out to the assembly file.
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 Mentions of a literal register r in a or b must be of
a61af66fc99e Initial load
duke
parents:
diff changeset
219 the form r_enc or r_num. The form r_enc refers to the
a61af66fc99e Initial load
duke
parents:
diff changeset
220 encoding of the register in an instruction. The form
a61af66fc99e Initial load
duke
parents:
diff changeset
221 r_num refers to the number of the register. While
a61af66fc99e Initial load
duke
parents:
diff changeset
222 r_num is unique, two different registers may have the
a61af66fc99e Initial load
duke
parents:
diff changeset
223 same r_enc, as, for example, an integer and a floating
a61af66fc99e Initial load
duke
parents:
diff changeset
224 point register.
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 F. Operand Form: operand x_reg(REG_T rall) %{ ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
228 1. Identifier (scope of all operand names is global in ADL file)
a61af66fc99e Initial load
duke
parents:
diff changeset
229 2. Components
a61af66fc99e Initial load
duke
parents:
diff changeset
230 a. Specified in argument style: (<type> <name>, ...)
a61af66fc99e Initial load
duke
parents:
diff changeset
231 b. Type must be a predefined Component Type
a61af66fc99e Initial load
duke
parents:
diff changeset
232 c. Name is a locally scoped name, used for substitution, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
233 3. Match: (VREG)
a61af66fc99e Initial load
duke
parents:
diff changeset
234 a. Parenthesized Inorder Binary Tree: [lft = left; rgh = right]
a61af66fc99e Initial load
duke
parents:
diff changeset
235 (root root->lft (root->rgh (root->rgh->lft root->rgh->rgh)))
a61af66fc99e Initial load
duke
parents:
diff changeset
236 b. Interior nodes in tree are operators (nodes) in abstract IR
a61af66fc99e Initial load
duke
parents:
diff changeset
237 c. Leaves are components from operand component list
a61af66fc99e Initial load
duke
parents:
diff changeset
238 d. Block following tree is the body of a C++ function taking
a61af66fc99e Initial load
duke
parents:
diff changeset
239 no arguments and returning no value, which assigns values
a61af66fc99e Initial load
duke
parents:
diff changeset
240 to the components of the operand at match time.
a61af66fc99e Initial load
duke
parents:
diff changeset
241 4. Encode: encode %{ return CONST; %}
a61af66fc99e Initial load
duke
parents:
diff changeset
242 a. Block form must contain C++ code which constitutes the
a61af66fc99e Initial load
duke
parents:
diff changeset
243 body of a C++ function which takes no arguments, and
a61af66fc99e Initial load
duke
parents:
diff changeset
244 returns an integer.
a61af66fc99e Initial load
duke
parents:
diff changeset
245 b. Local names (operand names) are can be used as substitution
a61af66fc99e Initial load
duke
parents:
diff changeset
246 symbols in the code.
a61af66fc99e Initial load
duke
parents:
diff changeset
247 5. Attribute (op_attrib): op_cost(5);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 a. Identifier (must be name defined as operand attribute)
a61af66fc99e Initial load
duke
parents:
diff changeset
249 b. Argument must be a constant value or a C++ expression which
a61af66fc99e Initial load
duke
parents:
diff changeset
250 evaluates to a constant at compile time.
a61af66fc99e Initial load
duke
parents:
diff changeset
251 6. Predicate: predicate(0 <= src < 256);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 a. Argument must be a valid C++ expression which evaluates
a61af66fc99e Initial load
duke
parents:
diff changeset
253 to either TRUE of FALSE at run time.
a61af66fc99e Initial load
duke
parents:
diff changeset
254 *7. Constraint: constraint(IS_RCLASS(dst, RC_X_CLASS));
a61af66fc99e Initial load
duke
parents:
diff changeset
255 a. Arguments must contain only predefined constraint
a61af66fc99e Initial load
duke
parents:
diff changeset
256 functions on values defined in the AD file.
a61af66fc99e Initial load
duke
parents:
diff changeset
257 b. Multiple arguments can be chained together logically
a61af66fc99e Initial load
duke
parents:
diff changeset
258 with "&&".
a61af66fc99e Initial load
duke
parents:
diff changeset
259 8. Construct: construct %{ ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
260 a. Block must be a valid C++ function body which takes no
a61af66fc99e Initial load
duke
parents:
diff changeset
261 arguments, and returns no values.
a61af66fc99e Initial load
duke
parents:
diff changeset
262 b. Purpose of block is to assign values to the elements
a61af66fc99e Initial load
duke
parents:
diff changeset
263 of an operand which is constructed outside the matching
a61af66fc99e Initial load
duke
parents:
diff changeset
264 process.
a61af66fc99e Initial load
duke
parents:
diff changeset
265 c. This block is logically identical to the constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
266 block in a match rule.
a61af66fc99e Initial load
duke
parents:
diff changeset
267 9. Format: format(add_X $src, $dst); | format %{ ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
268 a. Argument form takes a text string, possibly containing
a61af66fc99e Initial load
duke
parents:
diff changeset
269 some substitution symbols, which will be printed out
a61af66fc99e Initial load
duke
parents:
diff changeset
270 to the assembly language file.
a61af66fc99e Initial load
duke
parents:
diff changeset
271 b. The block form takes valid C++ code which forms the body
a61af66fc99e Initial load
duke
parents:
diff changeset
272 of a function which takes no arguments, and returns a
a61af66fc99e Initial load
duke
parents:
diff changeset
273 pointer to a string to print out to the assembly file.
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 Mentions of a literal register r in a or b must be of
a61af66fc99e Initial load
duke
parents:
diff changeset
276 the form r_enc or r_num. The form r_enc refers to the
a61af66fc99e Initial load
duke
parents:
diff changeset
277 encoding of the register in an instruction. The form
a61af66fc99e Initial load
duke
parents:
diff changeset
278 r_num refers to the number of the register. While
a61af66fc99e Initial load
duke
parents:
diff changeset
279 r_num is unique, two different registers may have the
a61af66fc99e Initial load
duke
parents:
diff changeset
280 same r_enc, as, for example, an integer and a floating
a61af66fc99e Initial load
duke
parents:
diff changeset
281 point register.
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 G. Operand Class Form: opclass memory( direct, indirect, ind_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 H. Attribute Form (keywords ins_atrib & op_attrib): ins_attrib ins_cost(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 1. Identifier (scope of all attribute names is global in ADL file)
a61af66fc99e Initial load
duke
parents:
diff changeset
287 2. Argument must be a valid C++ expression which evaluates to a
a61af66fc99e Initial load
duke
parents:
diff changeset
288 constant at compile time, and specifies the default value of
a61af66fc99e Initial load
duke
parents:
diff changeset
289 this attribute if attribute definition is not included in an
a61af66fc99e Initial load
duke
parents:
diff changeset
290 operand/instruction.
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 I. Source Form: source %{ ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
293 1. Source Block
a61af66fc99e Initial load
duke
parents:
diff changeset
294 a. All source blocks are delimited by "%{" and "%}".
a61af66fc99e Initial load
duke
parents:
diff changeset
295 b. All source blocks are copied verbatim into the
a61af66fc99e Initial load
duke
parents:
diff changeset
296 C++ output file, and must be valid C++ code.
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 Mentions of a literal register r in this code must
a61af66fc99e Initial load
duke
parents:
diff changeset
299 be of the form r_enc or r_num. The form r_enc
a61af66fc99e Initial load
duke
parents:
diff changeset
300 refers to the encoding of the register in an
a61af66fc99e Initial load
duke
parents:
diff changeset
301 instruction. The form r_num refers to the number of
a61af66fc99e Initial load
duke
parents:
diff changeset
302 the register. While r_num is unique, two different
a61af66fc99e Initial load
duke
parents:
diff changeset
303 registers may have the same r_enc, as, for example,
a61af66fc99e Initial load
duke
parents:
diff changeset
304 an integer and a floating point register.
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 J. *Register Form: register %{ ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
308 1. Block contains architecture specific information for allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
309 2. Reg_def: reg_def reg_AX(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 a. Identifier is name by which register will be referenced
a61af66fc99e Initial load
duke
parents:
diff changeset
311 throughout the rest of the AD, and the allocator and
a61af66fc99e Initial load
duke
parents:
diff changeset
312 back-end.
a61af66fc99e Initial load
duke
parents:
diff changeset
313 b. Argument is the Save on Entry index (where 0 means that
a61af66fc99e Initial load
duke
parents:
diff changeset
314 the register is Save on Call). This is used by the
a61af66fc99e Initial load
duke
parents:
diff changeset
315 frame management routines for generating register saves
a61af66fc99e Initial load
duke
parents:
diff changeset
316 and restores.
a61af66fc99e Initial load
duke
parents:
diff changeset
317 3. Reg_class: reg_class x_regs(reg_AX, reg_BX, reg_CX, reg_DX);
a61af66fc99e Initial load
duke
parents:
diff changeset
318 a. Identifier is the name of the class used throughout the
a61af66fc99e Initial load
duke
parents:
diff changeset
319 instruction selector.
a61af66fc99e Initial load
duke
parents:
diff changeset
320 b. Arguments are a list of register names in the class.
a61af66fc99e Initial load
duke
parents:
diff changeset
321 4. Alloc_class: alloc_class x_alloc(reg_AX, reg_BX, reg_CX, reg_DX);
a61af66fc99e Initial load
duke
parents:
diff changeset
322 a. Identifier is the name of the class used throughout the
a61af66fc99e Initial load
duke
parents:
diff changeset
323 register allocator.
a61af66fc99e Initial load
duke
parents:
diff changeset
324 b. Arguments are a list of register names in the class.
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 K. *Pipeline Form: pipeline %{ ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
328 1. Block contains architecture specific information for scheduling
a61af66fc99e Initial load
duke
parents:
diff changeset
329 2. Resource: resource(ialu1);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 a. Argument is the name of the resource.
a61af66fc99e Initial load
duke
parents:
diff changeset
331 3. Pipe_desc: pipe_desc(Address, Access, Read, Execute);
a61af66fc99e Initial load
duke
parents:
diff changeset
332 a. Arguments are names of relevant phases of the pipeline.
a61af66fc99e Initial load
duke
parents:
diff changeset
333 b. If ALL instructions behave identically in a pipeline
a61af66fc99e Initial load
duke
parents:
diff changeset
334 phase, it does not need to be specified. (This is typically
a61af66fc99e Initial load
duke
parents:
diff changeset
335 true for pre-fetch, fetch, and decode pipeline stages.)
a61af66fc99e Initial load
duke
parents:
diff changeset
336 c. There must be one name per cycle consumed in the
a61af66fc99e Initial load
duke
parents:
diff changeset
337 pipeline, even if there is no instruction which has
a61af66fc99e Initial load
duke
parents:
diff changeset
338 significant behavior in that stage (for instance, extra
a61af66fc99e Initial load
duke
parents:
diff changeset
339 stages inserted for load and store instructions which
a61af66fc99e Initial load
duke
parents:
diff changeset
340 are just cycles which pass waiting for the completion
a61af66fc99e Initial load
duke
parents:
diff changeset
341 of the memory operation).
a61af66fc99e Initial load
duke
parents:
diff changeset
342 4. Pipe_class: pipe_class pipe_normal(dagen; ; membus; ialu1, ialu2);
a61af66fc99e Initial load
duke
parents:
diff changeset
343 a. Identifier names the class for use in ins_pipe statements
a61af66fc99e Initial load
duke
parents:
diff changeset
344 b. Arguments are a list of stages, separated by ;'s which
a61af66fc99e Initial load
duke
parents:
diff changeset
345 contain comma separated lists of resource names.
a61af66fc99e Initial load
duke
parents:
diff changeset
346 c. There must be an entry for each stage defined in the
a61af66fc99e Initial load
duke
parents:
diff changeset
347 pipe_desc statement, (even if it is empty as in the example)
a61af66fc99e Initial load
duke
parents:
diff changeset
348 and entries are associated with stages by the order of
a61af66fc99e Initial load
duke
parents:
diff changeset
349 stage declarations in the pipe_desc statement.
a61af66fc99e Initial load
duke
parents:
diff changeset
350