annotate src/share/vm/adlc/output_h.cpp @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents 4ca6dc0799b6
children 52b4284cb496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17524
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14909
diff changeset
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1541
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1541
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1541
diff changeset
21 * questions.
0
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 // output_h.cpp - Class HPP file output routines for architecture definition
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "adlc.hpp"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
28 // The comment delimiter used in format statements after assembler instructions.
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
29 #define commentSeperator "!"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // Generate the #define that describes the number of registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
32 static void defineRegCount(FILE *fp, RegisterForm *registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
33 if (registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 int regCount = AdlcVMDeps::Physical + registers->_rdefs.count();
a61af66fc99e Initial load
duke
parents:
diff changeset
35 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
36 fprintf(fp,"// the number of reserved registers + machine registers.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
37 fprintf(fp,"#define REG_COUNT %d\n", regCount);
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Output enumeration of machine register numbers
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // (1)
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // // Enumerate machine registers starting after reserved regs.
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // // in the order of occurrence in the register block.
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // enum MachRegisterNumbers {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // EAX_num = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // _last_Mach_Reg
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void ArchDesc::buildMachRegisterNumbers(FILE *fp_hpp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if (_register) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 RegDef *reg_def = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Output a #define for the number of machine registers
a61af66fc99e Initial load
duke
parents:
diff changeset
55 defineRegCount(fp_hpp, _register);
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Count all the Save_On_Entry and Always_Save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
58 int saved_on_entry = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 int c_saved_on_entry = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _register->reset_RegDefs();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 while( (reg_def = _register->iter_RegDefs()) != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if( strcmp(reg_def->_callconv,"SOE") == 0 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
63 strcmp(reg_def->_callconv,"AS") == 0 ) ++saved_on_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 if( strcmp(reg_def->_c_conv,"SOE") == 0 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
65 strcmp(reg_def->_c_conv,"AS") == 0 ) ++c_saved_on_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
68 fprintf(fp_hpp, "// the number of save_on_entry + always_saved registers.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 fprintf(fp_hpp, "#define MAX_SAVED_ON_ENTRY_REG_COUNT %d\n", max(saved_on_entry,c_saved_on_entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
70 fprintf(fp_hpp, "#define SAVED_ON_ENTRY_REG_COUNT %d\n", saved_on_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 fprintf(fp_hpp, "#define C_SAVED_ON_ENTRY_REG_COUNT %d\n", c_saved_on_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // (1)
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Build definition for enumeration of register numbers
a61af66fc99e Initial load
duke
parents:
diff changeset
75 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 fprintf(fp_hpp, "// Enumerate machine register numbers starting after reserved regs.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
77 fprintf(fp_hpp, "// in the order of occurrence in the register block.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
78 fprintf(fp_hpp, "enum MachRegisterNumbers {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Output the register number for each register in the allocation classes
a61af66fc99e Initial load
duke
parents:
diff changeset
81 _register->reset_RegDefs();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 int i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 while( (reg_def = _register->iter_RegDefs()) != NULL ) {
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
84 fprintf(fp_hpp," %s_num,", reg_def->_regname);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
85 for (int j = 0; j < 20-(int)strlen(reg_def->_regname); j++) fprintf(fp_hpp, " ");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
86 fprintf(fp_hpp," // enum %3d, regnum %3d, reg encode %3s\n",
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
87 i++,
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
88 reg_def->register_num(),
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
89 reg_def->register_encode());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Finish defining enumeration
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
92 fprintf(fp_hpp, " _last_Mach_Reg // %d\n", i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
93 fprintf(fp_hpp, "};\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 fprintf(fp_hpp, "\n// Size of register-mask in ints\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 fprintf(fp_hpp, "#define RM_SIZE %d\n",RegisterForm::RegMask_Size());
a61af66fc99e Initial load
duke
parents:
diff changeset
98 fprintf(fp_hpp, "// Unroll factor for loops over the data in a RegMask\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
99 fprintf(fp_hpp, "#define FORALL_BODY ");
a61af66fc99e Initial load
duke
parents:
diff changeset
100 int len = RegisterForm::RegMask_Size();
a61af66fc99e Initial load
duke
parents:
diff changeset
101 for( int i = 0; i < len; i++ )
a61af66fc99e Initial load
duke
parents:
diff changeset
102 fprintf(fp_hpp, "BODY(%d) ",i);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 fprintf(fp_hpp, "\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 fprintf(fp_hpp,"class RegMask;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // All RegMasks are declared "extern const ..." in ad_<arch>.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // fprintf(fp_hpp,"extern RegMask STACK_OR_STACK_SLOTS_mask;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Output enumeration of machine register encodings
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // (2)
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // // Enumerate machine registers starting after reserved regs.
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // // in the order of occurrence in the alloc_class(es).
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // enum MachRegisterEncodes {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // EAX_enc = 0x00,
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void ArchDesc::buildMachRegisterEncodes(FILE *fp_hpp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if (_register) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 RegDef *reg_def = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 RegDef *reg_def_next = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // (2)
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Build definition for enumeration of encode values
a61af66fc99e Initial load
duke
parents:
diff changeset
126 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
127 fprintf(fp_hpp, "// Enumerate machine registers starting after reserved regs.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 fprintf(fp_hpp, "// in the order of occurrence in the alloc_class(es).\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 fprintf(fp_hpp, "enum MachRegisterEncodes {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
130
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
131 // Find max enum string length.
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
132 size_t maxlen = 0;
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
133 _register->reset_RegDefs();
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
134 reg_def = _register->iter_RegDefs();
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
135 while (reg_def != NULL) {
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
136 size_t len = strlen(reg_def->_regname);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
137 if (len > maxlen) maxlen = len;
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
138 reg_def = _register->iter_RegDefs();
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
139 }
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
140
0
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Output the register encoding for each register in the allocation classes
a61af66fc99e Initial load
duke
parents:
diff changeset
142 _register->reset_RegDefs();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 reg_def_next = _register->iter_RegDefs();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 while( (reg_def = reg_def_next) != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 reg_def_next = _register->iter_RegDefs();
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
146 fprintf(fp_hpp," %s_enc", reg_def->_regname);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
147 for (size_t i = strlen(reg_def->_regname); i < maxlen; i++) fprintf(fp_hpp, " ");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
148 fprintf(fp_hpp," = %3s%s\n", reg_def->register_encode(), reg_def_next == NULL? "" : "," );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Finish defining enumeration
a61af66fc99e Initial load
duke
parents:
diff changeset
151 fprintf(fp_hpp, "};\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 } // Done with register form
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // Declare an array containing the machine register names, strings.
a61af66fc99e Initial load
duke
parents:
diff changeset
158 static void declareRegNames(FILE *fp, RegisterForm *registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if (registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // fprintf(fp,"// An array of character pointers to machine register names.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // fprintf(fp,"extern const char *regName[];\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Declare an array containing the machine register sizes in 32-bit words.
a61af66fc99e Initial load
duke
parents:
diff changeset
167 void ArchDesc::declareRegSizes(FILE *fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // regSize[] is not used
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Declare an array containing the machine register encoding values
a61af66fc99e Initial load
duke
parents:
diff changeset
172 static void declareRegEncodes(FILE *fp, RegisterForm *registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // // //
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // fprintf(fp,"// An array containing the machine register encode values\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // fprintf(fp,"extern const char regEncode[];\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // ---------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
183 //------------------------------Utilities to build Instruction Classes--------
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // ---------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
185 static void out_RegMask(FILE *fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 fprintf(fp," virtual const RegMask &out_RegMask() const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // ---------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
190 //--------Utilities to build MachOper and MachNode derived Classes------------
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // ---------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 //------------------------------Utilities to build Operand Classes------------
a61af66fc99e Initial load
duke
parents:
diff changeset
194 static void in_RegMask(FILE *fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 fprintf(fp," virtual const RegMask *in_RegMask(int index) const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 static void declareConstStorage(FILE *fp, FormDict &globals, OperandForm *oper) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 int i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 Component *comp;
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 if (oper->num_consts(globals) == 0) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // Iterate over the component list looking for constants
a61af66fc99e Initial load
duke
parents:
diff changeset
204 oper->_components.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if ((comp = oper->_components.iter()) == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(oper->num_consts(globals) == 1, "Bad component list detected.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 const char *type = oper->ideal_type(globals);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if (!strcmp(type, "ConI")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
210 fprintf(fp," int32 _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 else if (!strcmp(type, "ConP")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
214 fprintf(fp," const TypePtr *_c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
216 else if (!strcmp(type, "ConN")) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
217 if (i > 0) fprintf(fp,", ");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
218 fprintf(fp," const TypeNarrowOop *_c%d;\n", i);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
219 }
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
220 else if (!strcmp(type, "ConNKlass")) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
221 if (i > 0) fprintf(fp,", ");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
222 fprintf(fp," const TypeNarrowKlass *_c%d;\n", i);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
223 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
224 else if (!strcmp(type, "ConL")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
226 fprintf(fp," jlong _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228 else if (!strcmp(type, "ConF")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
230 fprintf(fp," jfloat _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 else if (!strcmp(type, "ConD")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
234 fprintf(fp," jdouble _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 else if (!strcmp(type, "Bool")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 fprintf(fp,"private:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
238 fprintf(fp," BoolTest::mask _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 fprintf(fp,"public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 assert(0, "Non-constant operand lacks component list.");
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 } // end if NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
245 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 oper->_components.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
247 while ((comp = oper->_components.iter()) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (!strcmp(comp->base_type(globals), "ConI")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 fprintf(fp," jint _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 else if (!strcmp(comp->base_type(globals), "ConP")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 fprintf(fp," const TypePtr *_c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
256 else if (!strcmp(comp->base_type(globals), "ConN")) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
257 fprintf(fp," const TypePtr *_c%d;\n", i);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
258 i++;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
259 }
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
260 else if (!strcmp(comp->base_type(globals), "ConNKlass")) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
261 fprintf(fp," const TypePtr *_c%d;\n", i);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
262 i++;
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
263 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
264 else if (!strcmp(comp->base_type(globals), "ConL")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 fprintf(fp," jlong _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 else if (!strcmp(comp->base_type(globals), "ConF")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 fprintf(fp," jfloat _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 else if (!strcmp(comp->base_type(globals), "ConD")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 fprintf(fp," jdouble _c%d;\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // Declare constructor.
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // Parameters start with condition code, then all other constants
a61af66fc99e Initial load
duke
parents:
diff changeset
282 //
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // (0) public:
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // (1) MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn)
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // (2) : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
286 //
a61af66fc99e Initial load
duke
parents:
diff changeset
287 static void defineConstructor(FILE *fp, const char *name, uint num_consts,
a61af66fc99e Initial load
duke
parents:
diff changeset
288 ComponentList &lst, bool is_ideal_bool,
a61af66fc99e Initial load
duke
parents:
diff changeset
289 Form::DataType constant_type, FormDict &globals) {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 fprintf(fp,"public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // generate line (1)
a61af66fc99e Initial load
duke
parents:
diff changeset
292 fprintf(fp," %sOper(", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 if( num_consts == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 fprintf(fp,") {}\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
295 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // generate parameters for constants
a61af66fc99e Initial load
duke
parents:
diff changeset
299 uint i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
300 Component *comp;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 lst.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
302 if ((comp = lst.iter()) == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 assert(num_consts == 1, "Bad component list detected.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
304 switch( constant_type ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 case Form::idealI : {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 fprintf(fp,is_ideal_bool ? "BoolTest::mask c%d" : "int32 c%d", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
307 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
309 case Form::idealN : { fprintf(fp,"const TypeNarrowOop *c%d", i); break; }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
310 case Form::idealNKlass : { fprintf(fp,"const TypeNarrowKlass *c%d", i); break; }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
311 case Form::idealP : { fprintf(fp,"const TypePtr *c%d", i); break; }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
312 case Form::idealL : { fprintf(fp,"jlong c%d", i); break; }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
313 case Form::idealF : { fprintf(fp,"jfloat c%d", i); break; }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
314 case Form::idealD : { fprintf(fp,"jdouble c%d", i); break; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
315 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
316 assert(!is_ideal_bool, "Non-constant operand lacks component list.");
a61af66fc99e Initial load
duke
parents:
diff changeset
317 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319 } // end if NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
320 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 lst.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 while((comp = lst.iter()) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 if (!strcmp(comp->base_type(globals), "ConI")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
325 fprintf(fp,"int32 c%d", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328 else if (!strcmp(comp->base_type(globals), "ConP")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
330 fprintf(fp,"const TypePtr *c%d", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
331 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
333 else if (!strcmp(comp->base_type(globals), "ConN")) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
334 if (i > 0) fprintf(fp,", ");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
335 fprintf(fp,"const TypePtr *c%d", i);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
336 i++;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
337 }
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
338 else if (!strcmp(comp->base_type(globals), "ConNKlass")) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
339 if (i > 0) fprintf(fp,", ");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
340 fprintf(fp,"const TypePtr *c%d", i);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
341 i++;
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
342 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
343 else if (!strcmp(comp->base_type(globals), "ConL")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
345 fprintf(fp,"jlong c%d", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
346 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348 else if (!strcmp(comp->base_type(globals), "ConF")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
350 fprintf(fp,"jfloat c%d", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
351 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 else if (!strcmp(comp->base_type(globals), "ConD")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
355 fprintf(fp,"jdouble c%d", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
356 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358 else if (!strcmp(comp->base_type(globals), "Bool")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 if (i > 0) fprintf(fp,", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 fprintf(fp,"BoolTest::mask c%d", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // finish line (1) and start line (2)
a61af66fc99e Initial load
duke
parents:
diff changeset
366 fprintf(fp,") : ");
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // generate initializers for constants
a61af66fc99e Initial load
duke
parents:
diff changeset
368 i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
369 fprintf(fp,"_c%d(c%d)", i, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 for( i = 1; i < num_consts; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 fprintf(fp,", _c%d(c%d)", i, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // The body for the constructor is empty
a61af66fc99e Initial load
duke
parents:
diff changeset
374 fprintf(fp," {}\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // ---------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // Utilities to generate format rules for machine operands and instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // ---------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // Generate the format rule for condition codes
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
382 static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
383 assert(oper != NULL, "what");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
384 CondInterface* cond = oper->_interface->is_CondInterface();
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
385 fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
386 fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
387 fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
388 fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
389 fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
390 fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format);
12323
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
391 fprintf(fp, " else if( _c%d == BoolTest::overflow ) st->print(\"%s\");\n",i,cond->_overflow_format);
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
392 fprintf(fp, " else if( _c%d == BoolTest::no_overflow ) st->print(\"%s\");\n",i,cond->_no_overflow_format);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
393 }
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 // Output code that dumps constant values, increment "i" if type is constant
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
396 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
397 if (!strcmp(ideal_type, "ConI")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 fprintf(fp," st->print(\"#%%d\", _c%d);\n", i);
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
399 fprintf(fp," st->print(\"/0x%%08x\", _c%d);\n", i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
400 ++i;
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402 else if (!strcmp(ideal_type, "ConP")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
403 fprintf(fp," _c%d->dump_on(st);\n", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
404 ++i;
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
406 else if (!strcmp(ideal_type, "ConN")) {
417
f4fe12e429a4 6764622: IdealGraphVisualizer fixes
never
parents: 415
diff changeset
407 fprintf(fp," _c%d->dump_on(st);\n", i);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
408 ++i;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
409 }
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
410 else if (!strcmp(ideal_type, "ConNKlass")) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
411 fprintf(fp," _c%d->dump_on(st);\n", i);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
412 ++i;
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
413 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
414 else if (!strcmp(ideal_type, "ConL")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
415 fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i);
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
416 fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%d);\n", i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
417 ++i;
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419 else if (!strcmp(ideal_type, "ConF")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
421 fprintf(fp," jint _c%di = JavaValue(_c%d).get_jint();\n", i, i);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
422 fprintf(fp," st->print(\"/0x%%x/\", _c%di);\n", i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
423 ++i;
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425 else if (!strcmp(ideal_type, "ConD")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
426 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
427 fprintf(fp," jlong _c%dl = JavaValue(_c%d).get_jlong();\n", i, i);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
428 fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%dl);\n", i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
429 ++i;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 }
a61af66fc99e Initial load
duke
parents:
diff changeset
431 else if (!strcmp(ideal_type, "Bool")) {
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
432 defineCCodeDump(oper, fp,i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
433 ++i;
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 return i;
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // Generate the format rule for an operand
a61af66fc99e Initial load
duke
parents:
diff changeset
440 void gen_oper_format(FILE *fp, FormDict &globals, OperandForm &oper, bool for_c_file = false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 if (!for_c_file) {
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // invoked after output #ifndef PRODUCT to ad_<arch>.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
443 // compile the bodies separately, to cut down on recompilations
a61af66fc99e Initial load
duke
parents:
diff changeset
444 fprintf(fp," virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
445 fprintf(fp," virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
446 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // Local pointer indicates remaining part of format rule
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
450 int idx = 0; // position of operand in match rule
0
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // Generate internal format function, used when stored locally
a61af66fc99e Initial load
duke
parents:
diff changeset
453 fprintf(fp, "\n#ifndef PRODUCT\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
454 fprintf(fp,"void %sOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {\n", oper._ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // Generate the user-defined portion of the format
a61af66fc99e Initial load
duke
parents:
diff changeset
456 if (oper._format) {
a61af66fc99e Initial load
duke
parents:
diff changeset
457 if ( oper._format->_strings.count() != 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // No initialization code for int_format
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460 // Build the format from the entries in strings and rep_vars
a61af66fc99e Initial load
duke
parents:
diff changeset
461 const char *string = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
462 oper._format->_rep_vars.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
463 oper._format->_strings.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
464 while ( (string = oper._format->_strings.iter()) != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // Check if this is a standard string or a replacement variable
a61af66fc99e Initial load
duke
parents:
diff changeset
467 if ( string != NameList::_signal ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
468 // Normal string
a61af66fc99e Initial load
duke
parents:
diff changeset
469 // Pass through to st->print
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
470 fprintf(fp," st->print(\"%s\");\n", string);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
471 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
472 // Replacement variable
a61af66fc99e Initial load
duke
parents:
diff changeset
473 const char *rep_var = oper._format->_rep_vars.iter();
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // Check that it is a local name, and an operand
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
475 const Form* form = oper._localNames[rep_var];
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
476 if (form == NULL) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
477 globalAD->syntax_err(oper._linenum,
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
478 "\'%s\' not found in format for %s\n", rep_var, oper._ident);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
479 assert(form, "replacement variable was not found in local names");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
480 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
481 OperandForm *op = form->is_operand();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
482 // Get index if register or constant
a61af66fc99e Initial load
duke
parents:
diff changeset
483 if ( op->_matrule && op->_matrule->is_base_register(globals) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
484 idx = oper.register_position( globals, rep_var);
a61af66fc99e Initial load
duke
parents:
diff changeset
485 }
a61af66fc99e Initial load
duke
parents:
diff changeset
486 else if (op->_matrule && op->_matrule->is_base_constant(globals)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
487 idx = oper.constant_position( globals, rep_var);
a61af66fc99e Initial load
duke
parents:
diff changeset
488 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
489 idx = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
490 }
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 // output invocation of "$..."s format function
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
493 if ( op != NULL ) op->int_format(fp, globals, idx);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 if ( idx == -1 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
496 fprintf(stderr,
a61af66fc99e Initial load
duke
parents:
diff changeset
497 "Using a name, %s, that isn't in match rule\n", rep_var);
a61af66fc99e Initial load
duke
parents:
diff changeset
498 assert( strcmp(op->_ident,"label")==0, "Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
500 } // Done with a replacement variable
a61af66fc99e Initial load
duke
parents:
diff changeset
501 } // Done with all format strings
a61af66fc99e Initial load
duke
parents:
diff changeset
502 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
503 // Default formats for base operands (RegI, RegP, ConI, ConP, ...)
a61af66fc99e Initial load
duke
parents:
diff changeset
504 oper.int_format(fp, globals, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 } else { // oper._format == NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // Provide a few special case formats where the AD writer cannot.
a61af66fc99e Initial load
duke
parents:
diff changeset
509 if ( strcmp(oper._ident,"Universe")==0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
510 fprintf(fp, " st->print(\"$$univ\");\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512 // labelOper::int_format is defined in ad_<...>.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
513 }
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // ALWAYS! Provide a special case output for condition codes.
a61af66fc99e Initial load
duke
parents:
diff changeset
515 if( oper.is_ideal_bool() ) {
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
516 defineCCodeDump(&oper, fp,0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
518 fprintf(fp,"}\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
519
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // Generate external format function, when data is stored externally
a61af66fc99e Initial load
duke
parents:
diff changeset
521 fprintf(fp,"void %sOper::ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const {\n", oper._ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // Generate the user-defined portion of the format
a61af66fc99e Initial load
duke
parents:
diff changeset
523 if (oper._format) {
a61af66fc99e Initial load
duke
parents:
diff changeset
524 if ( oper._format->_strings.count() != 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 // Check for a replacement string "$..."
a61af66fc99e Initial load
duke
parents:
diff changeset
527 if ( oper._format->_rep_vars.count() != 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
528 // Initialization code for ext_format
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530
a61af66fc99e Initial load
duke
parents:
diff changeset
531 // Build the format from the entries in strings and rep_vars
a61af66fc99e Initial load
duke
parents:
diff changeset
532 const char *string = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
533 oper._format->_rep_vars.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
534 oper._format->_strings.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
535 while ( (string = oper._format->_strings.iter()) != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // Check if this is a standard string or a replacement variable
a61af66fc99e Initial load
duke
parents:
diff changeset
538 if ( string != NameList::_signal ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // Normal string
a61af66fc99e Initial load
duke
parents:
diff changeset
540 // Pass through to st->print
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
541 fprintf(fp," st->print(\"%s\");\n", string);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
542 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
543 // Replacement variable
a61af66fc99e Initial load
duke
parents:
diff changeset
544 const char *rep_var = oper._format->_rep_vars.iter();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
545 // Check that it is a local name, and an operand
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
546 const Form* form = oper._localNames[rep_var];
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
547 if (form == NULL) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
548 globalAD->syntax_err(oper._linenum,
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
549 "\'%s\' not found in format for %s\n", rep_var, oper._ident);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
550 assert(form, "replacement variable was not found in local names");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
551 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
552 OperandForm *op = form->is_operand();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // Get index if register or constant
a61af66fc99e Initial load
duke
parents:
diff changeset
554 if ( op->_matrule && op->_matrule->is_base_register(globals) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
555 idx = oper.register_position( globals, rep_var);
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557 else if (op->_matrule && op->_matrule->is_base_constant(globals)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
558 idx = oper.constant_position( globals, rep_var);
a61af66fc99e Initial load
duke
parents:
diff changeset
559 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
560 idx = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
562 // output invocation of "$..."s format function
a61af66fc99e Initial load
duke
parents:
diff changeset
563 if ( op != NULL ) op->ext_format(fp, globals, idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 // Lookup the index position of the replacement variable
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
566 idx = oper._components.operand_position_format(rep_var, &oper);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
567 if ( idx == -1 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
568 fprintf(stderr,
a61af66fc99e Initial load
duke
parents:
diff changeset
569 "Using a name, %s, that isn't in match rule\n", rep_var);
a61af66fc99e Initial load
duke
parents:
diff changeset
570 assert( strcmp(op->_ident,"label")==0, "Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
572 } // Done with a replacement variable
a61af66fc99e Initial load
duke
parents:
diff changeset
573 } // Done with all format strings
a61af66fc99e Initial load
duke
parents:
diff changeset
574
a61af66fc99e Initial load
duke
parents:
diff changeset
575 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
576 // Default formats for base operands (RegI, RegP, ConI, ConP, ...)
a61af66fc99e Initial load
duke
parents:
diff changeset
577 oper.ext_format(fp, globals, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
578 }
a61af66fc99e Initial load
duke
parents:
diff changeset
579 } else { // oper._format == NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
580 // Provide a few special case formats where the AD writer cannot.
a61af66fc99e Initial load
duke
parents:
diff changeset
581 if ( strcmp(oper._ident,"Universe")==0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
582 fprintf(fp, " st->print(\"$$univ\");\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
583 }
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // labelOper::ext_format is defined in ad_<...>.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
586 // ALWAYS! Provide a special case output for condition codes.
a61af66fc99e Initial load
duke
parents:
diff changeset
587 if( oper.is_ideal_bool() ) {
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
588 defineCCodeDump(&oper, fp,0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
590 fprintf(fp, "}\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
591 fprintf(fp, "#endif\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
592 }
a61af66fc99e Initial load
duke
parents:
diff changeset
593
a61af66fc99e Initial load
duke
parents:
diff changeset
594
a61af66fc99e Initial load
duke
parents:
diff changeset
595 // Generate the format rule for an instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
596 void gen_inst_format(FILE *fp, FormDict &globals, InstructForm &inst, bool for_c_file = false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
597 if (!for_c_file) {
a61af66fc99e Initial load
duke
parents:
diff changeset
598 // compile the bodies separately, to cut down on recompilations
a61af66fc99e Initial load
duke
parents:
diff changeset
599 // #ifndef PRODUCT region generated by caller
a61af66fc99e Initial load
duke
parents:
diff changeset
600 fprintf(fp," virtual void format(PhaseRegAlloc *ra, outputStream *st) const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
601 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
602 }
a61af66fc99e Initial load
duke
parents:
diff changeset
603
a61af66fc99e Initial load
duke
parents:
diff changeset
604 // Define the format function
a61af66fc99e Initial load
duke
parents:
diff changeset
605 fprintf(fp, "#ifndef PRODUCT\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
606 fprintf(fp, "void %sNode::format(PhaseRegAlloc *ra, outputStream *st) const {\n", inst._ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
607
a61af66fc99e Initial load
duke
parents:
diff changeset
608 // Generate the user-defined portion of the format
a61af66fc99e Initial load
duke
parents:
diff changeset
609 if( inst._format ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
610 // If there are replacement variables,
605
98cb887364d3 6810672: Comment typos
twisti
parents: 603
diff changeset
611 // Generate index values needed for determining the operand position
0
a61af66fc99e Initial load
duke
parents:
diff changeset
612 if( inst._format->_rep_vars.count() )
a61af66fc99e Initial load
duke
parents:
diff changeset
613 inst.index_temps(fp, globals);
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615 // Build the format from the entries in strings and rep_vars
a61af66fc99e Initial load
duke
parents:
diff changeset
616 const char *string = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
617 inst._format->_rep_vars.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
618 inst._format->_strings.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
619 while( (string = inst._format->_strings.iter()) != NULL ) {
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
620 fprintf(fp," ");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
621 // Check if this is a standard string or a replacement variable
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
622 if( string == NameList::_signal ) { // Replacement variable
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
623 const char* rep_var = inst._format->_rep_vars.iter();
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
624 inst.rep_var_format( fp, rep_var);
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
625 } else if( string == NameList::_signal3 ) { // Replacement variable in raw text
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
626 const char* rep_var = inst._format->_rep_vars.iter();
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
627 const Form *form = inst._localNames[rep_var];
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
628 if (form == NULL) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
629 fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var);
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
630 assert(false, "ShouldNotReachHere()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
631 }
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
632 OpClassForm *opc = form->is_opclass();
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
633 assert( opc, "replacement variable was not found in local names");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
634 // Lookup the index position of the replacement variable
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
635 int idx = inst.operand_position_format(rep_var);
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
636 if ( idx == -1 ) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
637 assert( strcmp(opc->_ident,"label")==0, "Unimplemented");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
638 assert( false, "ShouldNotReachHere()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
639 }
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
640
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
641 if (inst.is_noninput_operand(idx)) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
642 assert( false, "ShouldNotReachHere()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
643 } else {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
644 // Output the format call for this operand
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
645 fprintf(fp,"opnd_array(%d)",idx);
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
646 }
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
647 rep_var = inst._format->_rep_vars.iter();
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
648 inst._format->_strings.iter();
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
649 if ( strcmp(rep_var,"$constant") == 0 && opc->is_operand()) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
650 Form::DataType constant_type = form->is_operand()->is_base_constant(globals);
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
651 if ( constant_type == Form::idealD ) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
652 fprintf(fp,"->constantD()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
653 } else if ( constant_type == Form::idealF ) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
654 fprintf(fp,"->constantF()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
655 } else if ( constant_type == Form::idealL ) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
656 fprintf(fp,"->constantL()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
657 } else {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
658 fprintf(fp,"->constant()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
659 }
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
660 } else if ( strcmp(rep_var,"$cmpcode") == 0) {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
661 fprintf(fp,"->ccode()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
662 } else {
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
663 assert( false, "ShouldNotReachHere()");
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
664 }
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
665 } else if( string == NameList::_signal2 ) // Raw program text
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
666 fputs(inst._format->_strings.iter(), fp);
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
667 else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
668 fprintf(fp,"st->print(\"%s\");\n", string);
a61af66fc99e Initial load
duke
parents:
diff changeset
669 } // Done with all format strings
a61af66fc99e Initial load
duke
parents:
diff changeset
670 } // Done generating the user-defined portion of the format
a61af66fc99e Initial load
duke
parents:
diff changeset
671
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // Add call debug info automatically
a61af66fc99e Initial load
duke
parents:
diff changeset
673 Form::CallType call_type = inst.is_ideal_call();
a61af66fc99e Initial load
duke
parents:
diff changeset
674 if( call_type != Form::invalid_type ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
675 switch( call_type ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
676 case Form::JAVA_DYNAMIC:
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
677 fprintf(fp," _method->print_short_name(st);\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
678 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
679 case Form::JAVA_STATIC:
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
680 fprintf(fp," if( _method ) _method->print_short_name(st);\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
681 fprintf(fp," else st->print(\" wrapper for: %%s\", _name);\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
682 fprintf(fp," if( !_method ) dump_trap_args(st);\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
683 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
684 case Form::JAVA_COMPILED:
a61af66fc99e Initial load
duke
parents:
diff changeset
685 case Form::JAVA_INTERP:
a61af66fc99e Initial load
duke
parents:
diff changeset
686 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
687 case Form::JAVA_RUNTIME:
a61af66fc99e Initial load
duke
parents:
diff changeset
688 case Form::JAVA_LEAF:
a61af66fc99e Initial load
duke
parents:
diff changeset
689 case Form::JAVA_NATIVE:
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
690 fprintf(fp," st->print(\" %%s\", _name);");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
691 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
692 default:
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
693 assert(0,"ShouldNotReachHere");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
694 }
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
695 fprintf(fp, " st->print_cr(\"\");\n" );
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
696 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" );
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
697 fprintf(fp, " st->print(\" # \");\n" );
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
698 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
699 }
a61af66fc99e Initial load
duke
parents:
diff changeset
700 else if(inst.is_ideal_safepoint()) {
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
701 fprintf(fp, " st->print(\"\");\n" );
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
702 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" );
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
703 fprintf(fp, " st->print(\" # \");\n" );
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
704 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
705 }
a61af66fc99e Initial load
duke
parents:
diff changeset
706 else if( inst.is_ideal_if() ) {
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
707 fprintf(fp, " st->print(\" P=%%f C=%%f\",_prob,_fcnt);\n" );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
708 }
a61af66fc99e Initial load
duke
parents:
diff changeset
709 else if( inst.is_ideal_mem() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
710 // Print out the field name if available to improve readability
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
711 fprintf(fp, " if (ra->C->alias_type(adr_type())->field() != NULL) {\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
712 fprintf(fp, " ciField* f = ra->C->alias_type(adr_type())->field();\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
713 fprintf(fp, " st->print(\" %s Field: \");\n", commentSeperator);
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
714 fprintf(fp, " if (f->is_volatile())\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
715 fprintf(fp, " st->print(\"volatile \");\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
716 fprintf(fp, " f->holder()->name()->print_symbol_on(st);\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
717 fprintf(fp, " st->print(\".\");\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
718 fprintf(fp, " f->name()->print_symbol_on(st);\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
719 fprintf(fp, " if (f->is_constant())\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
720 fprintf(fp, " st->print(\" (constant)\");\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
721 fprintf(fp, " } else {\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
722 // Make sure 'Volatile' gets printed out
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 4120
diff changeset
723 fprintf(fp, " if (ra->C->alias_type(adr_type())->is_volatile())\n");
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 4120
diff changeset
724 fprintf(fp, " st->print(\" volatile!\");\n");
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
725 fprintf(fp, " }\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
726 }
a61af66fc99e Initial load
duke
parents:
diff changeset
727
a61af66fc99e Initial load
duke
parents:
diff changeset
728 // Complete the definition of the format function
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
729 fprintf(fp, "}\n#endif\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
730 }
a61af66fc99e Initial load
duke
parents:
diff changeset
731
a61af66fc99e Initial load
duke
parents:
diff changeset
732 void ArchDesc::declare_pipe_classes(FILE *fp_hpp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
733 if (!_pipeline)
a61af66fc99e Initial load
duke
parents:
diff changeset
734 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
735
a61af66fc99e Initial load
duke
parents:
diff changeset
736 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
737 fprintf(fp_hpp, "// Pipeline_Use_Cycle_Mask Class\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
738 fprintf(fp_hpp, "class Pipeline_Use_Cycle_Mask {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
739
a61af66fc99e Initial load
duke
parents:
diff changeset
740 if (_pipeline->_maxcycleused <=
a61af66fc99e Initial load
duke
parents:
diff changeset
741 #ifdef SPARC
a61af66fc99e Initial load
duke
parents:
diff changeset
742 64
a61af66fc99e Initial load
duke
parents:
diff changeset
743 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
744 32
a61af66fc99e Initial load
duke
parents:
diff changeset
745 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
746 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
747 fprintf(fp_hpp, "protected:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
748 fprintf(fp_hpp, " %s _mask;\n\n", _pipeline->_maxcycleused <= 32 ? "uint" : "uint64_t" );
a61af66fc99e Initial load
duke
parents:
diff changeset
749 fprintf(fp_hpp, "public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
750 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask() : _mask(0) {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
751 if (_pipeline->_maxcycleused <= 32)
a61af66fc99e Initial load
duke
parents:
diff changeset
752 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask) : _mask(mask) {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
753 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
754 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask1, uint mask2) : _mask((((uint64_t)mask1) << 32) | mask2) {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
755 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint64_t mask) : _mask(mask) {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
756 }
a61af66fc99e Initial load
duke
parents:
diff changeset
757 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
758 fprintf(fp_hpp, " _mask = in._mask;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
759 fprintf(fp_hpp, " return *this;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
760 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
761 fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
762 fprintf(fp_hpp, " return ((_mask & in2._mask) != 0);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
763 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
764 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
765 fprintf(fp_hpp, " _mask <<= n;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
766 fprintf(fp_hpp, " return *this;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
767 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
768 fprintf(fp_hpp, " void Or(const Pipeline_Use_Cycle_Mask &in2) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
769 fprintf(fp_hpp, " _mask |= in2._mask;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
770 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
771 fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
772 fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
773 }
a61af66fc99e Initial load
duke
parents:
diff changeset
774 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
775 fprintf(fp_hpp, "protected:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
776 uint masklen = (_pipeline->_maxcycleused + 31) >> 5;
a61af66fc99e Initial load
duke
parents:
diff changeset
777 uint l;
a61af66fc99e Initial load
duke
parents:
diff changeset
778 fprintf(fp_hpp, " uint ");
a61af66fc99e Initial load
duke
parents:
diff changeset
779 for (l = 1; l <= masklen; l++)
a61af66fc99e Initial load
duke
parents:
diff changeset
780 fprintf(fp_hpp, "_mask%d%s", l, l < masklen ? ", " : ";\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
781 fprintf(fp_hpp, "public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
782 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask() : ");
a61af66fc99e Initial load
duke
parents:
diff changeset
783 for (l = 1; l <= masklen; l++)
a61af66fc99e Initial load
duke
parents:
diff changeset
784 fprintf(fp_hpp, "_mask%d(0)%s", l, l < masklen ? ", " : " {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
785 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(");
a61af66fc99e Initial load
duke
parents:
diff changeset
786 for (l = 1; l <= masklen; l++)
a61af66fc99e Initial load
duke
parents:
diff changeset
787 fprintf(fp_hpp, "uint mask%d%s", l, l < masklen ? ", " : ") : ");
a61af66fc99e Initial load
duke
parents:
diff changeset
788 for (l = 1; l <= masklen; l++)
a61af66fc99e Initial load
duke
parents:
diff changeset
789 fprintf(fp_hpp, "_mask%d(mask%d)%s", l, l, l < masklen ? ", " : " {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
790
a61af66fc99e Initial load
duke
parents:
diff changeset
791 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
792 for (l = 1; l <= masklen; l++)
a61af66fc99e Initial load
duke
parents:
diff changeset
793 fprintf(fp_hpp, " _mask%d = in._mask%d;\n", l, l);
a61af66fc99e Initial load
duke
parents:
diff changeset
794 fprintf(fp_hpp, " return *this;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
795 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
796 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask intersect(const Pipeline_Use_Cycle_Mask &in2) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
797 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask out;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
798 for (l = 1; l <= masklen; l++)
a61af66fc99e Initial load
duke
parents:
diff changeset
799 fprintf(fp_hpp, " out._mask%d = _mask%d & in2._mask%d;\n", l, l, l);
a61af66fc99e Initial load
duke
parents:
diff changeset
800 fprintf(fp_hpp, " return out;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
801 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
802 fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
803 fprintf(fp_hpp, " return (");
a61af66fc99e Initial load
duke
parents:
diff changeset
804 for (l = 1; l <= masklen; l++)
a61af66fc99e Initial load
duke
parents:
diff changeset
805 fprintf(fp_hpp, "((_mask%d & in2._mask%d) != 0)%s", l, l, l < masklen ? " || " : "");
a61af66fc99e Initial load
duke
parents:
diff changeset
806 fprintf(fp_hpp, ") ? true : false;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
807 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
808 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
809 fprintf(fp_hpp, " if (n >= 32)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
810 fprintf(fp_hpp, " do {\n ");
a61af66fc99e Initial load
duke
parents:
diff changeset
811 for (l = masklen; l > 1; l--)
a61af66fc99e Initial load
duke
parents:
diff changeset
812 fprintf(fp_hpp, " _mask%d = _mask%d;", l, l-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
813 fprintf(fp_hpp, " _mask%d = 0;\n", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
814 fprintf(fp_hpp, " } while ((n -= 32) >= 32);\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
815 fprintf(fp_hpp, " if (n > 0) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
816 fprintf(fp_hpp, " uint m = 32 - n;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
817 fprintf(fp_hpp, " uint mask = (1 << n) - 1;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
818 fprintf(fp_hpp, " uint temp%d = mask & (_mask%d >> m); _mask%d <<= n;\n", 2, 1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
819 for (l = 2; l < masklen; l++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
820 fprintf(fp_hpp, " uint temp%d = mask & (_mask%d >> m); _mask%d <<= n; _mask%d |= temp%d;\n", l+1, l, l, l, l);
a61af66fc99e Initial load
duke
parents:
diff changeset
821 }
a61af66fc99e Initial load
duke
parents:
diff changeset
822 fprintf(fp_hpp, " _mask%d <<= n; _mask%d |= temp%d;\n", masklen, masklen, masklen);
a61af66fc99e Initial load
duke
parents:
diff changeset
823 fprintf(fp_hpp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
824
a61af66fc99e Initial load
duke
parents:
diff changeset
825 fprintf(fp_hpp, " return *this;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
826 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
827 fprintf(fp_hpp, " void Or(const Pipeline_Use_Cycle_Mask &);\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
828 fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
829 fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
830 }
a61af66fc99e Initial load
duke
parents:
diff changeset
831
a61af66fc99e Initial load
duke
parents:
diff changeset
832 fprintf(fp_hpp, " friend class Pipeline_Use;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
833 fprintf(fp_hpp, " friend class Pipeline_Use_Element;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
834 fprintf(fp_hpp, "};\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
835
a61af66fc99e Initial load
duke
parents:
diff changeset
836 uint rescount = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
837 const char *resource;
a61af66fc99e Initial load
duke
parents:
diff changeset
838
a61af66fc99e Initial load
duke
parents:
diff changeset
839 for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
840 int mask = _pipeline->_resdict[resource]->is_resource()->mask();
a61af66fc99e Initial load
duke
parents:
diff changeset
841 if ((mask & (mask-1)) == 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
842 rescount++;
a61af66fc99e Initial load
duke
parents:
diff changeset
843 }
a61af66fc99e Initial load
duke
parents:
diff changeset
844
a61af66fc99e Initial load
duke
parents:
diff changeset
845 fprintf(fp_hpp, "// Pipeline_Use_Element Class\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
846 fprintf(fp_hpp, "class Pipeline_Use_Element {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
847 fprintf(fp_hpp, "protected:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
848 fprintf(fp_hpp, " // Mask of used functional units\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
849 fprintf(fp_hpp, " uint _used;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
850 fprintf(fp_hpp, " // Lower and upper bound of functional unit number range\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
851 fprintf(fp_hpp, " uint _lb, _ub;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
852 fprintf(fp_hpp, " // Indicates multiple functionals units available\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
853 fprintf(fp_hpp, " bool _multiple;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
854 fprintf(fp_hpp, " // Mask of specific used cycles\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
855 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask _mask;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
856 fprintf(fp_hpp, "public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
857 fprintf(fp_hpp, " Pipeline_Use_Element() {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
858 fprintf(fp_hpp, " Pipeline_Use_Element(uint used, uint lb, uint ub, bool multiple, Pipeline_Use_Cycle_Mask mask)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
859 fprintf(fp_hpp, " : _used(used), _lb(lb), _ub(ub), _multiple(multiple), _mask(mask) {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
860 fprintf(fp_hpp, " uint used() const { return _used; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
861 fprintf(fp_hpp, " uint lowerBound() const { return _lb; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
862 fprintf(fp_hpp, " uint upperBound() const { return _ub; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
863 fprintf(fp_hpp, " bool multiple() const { return _multiple; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
864 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask mask() const { return _mask; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
865 fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Element &in2) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
866 fprintf(fp_hpp, " return ((_used & in2._used) != 0 && _mask.overlaps(in2._mask));\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
867 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
868 fprintf(fp_hpp, " void step(uint cycles) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
869 fprintf(fp_hpp, " _used = 0;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
870 fprintf(fp_hpp, " _mask <<= cycles;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
871 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
872 fprintf(fp_hpp, " friend class Pipeline_Use;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
873 fprintf(fp_hpp, "};\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
874
a61af66fc99e Initial load
duke
parents:
diff changeset
875 fprintf(fp_hpp, "// Pipeline_Use Class\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
876 fprintf(fp_hpp, "class Pipeline_Use {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
877 fprintf(fp_hpp, "protected:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
878 fprintf(fp_hpp, " // These resources can be used\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
879 fprintf(fp_hpp, " uint _resources_used;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
880 fprintf(fp_hpp, " // These resources are used; excludes multiple choice functional units\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
881 fprintf(fp_hpp, " uint _resources_used_exclusively;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
882 fprintf(fp_hpp, " // Number of elements\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
883 fprintf(fp_hpp, " uint _count;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
884 fprintf(fp_hpp, " // This is the array of Pipeline_Use_Elements\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
885 fprintf(fp_hpp, " Pipeline_Use_Element * _elements;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
886 fprintf(fp_hpp, "public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
887 fprintf(fp_hpp, " Pipeline_Use(uint resources_used, uint resources_used_exclusively, uint count, Pipeline_Use_Element *elements)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
888 fprintf(fp_hpp, " : _resources_used(resources_used)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
889 fprintf(fp_hpp, " , _resources_used_exclusively(resources_used_exclusively)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
890 fprintf(fp_hpp, " , _count(count)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
891 fprintf(fp_hpp, " , _elements(elements)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
892 fprintf(fp_hpp, " {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
893 fprintf(fp_hpp, " uint resourcesUsed() const { return _resources_used; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
894 fprintf(fp_hpp, " uint resourcesUsedExclusively() const { return _resources_used_exclusively; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
895 fprintf(fp_hpp, " uint count() const { return _count; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
896 fprintf(fp_hpp, " Pipeline_Use_Element * element(uint i) const { return &_elements[i]; }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
897 fprintf(fp_hpp, " uint full_latency(uint delay, const Pipeline_Use &pred) const;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
898 fprintf(fp_hpp, " void add_usage(const Pipeline_Use &pred);\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
899 fprintf(fp_hpp, " void reset() {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
900 fprintf(fp_hpp, " _resources_used = _resources_used_exclusively = 0;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
901 fprintf(fp_hpp, " };\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
902 fprintf(fp_hpp, " void step(uint cycles) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
903 fprintf(fp_hpp, " reset();\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
904 fprintf(fp_hpp, " for (uint i = 0; i < %d; i++)\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
905 rescount);
a61af66fc99e Initial load
duke
parents:
diff changeset
906 fprintf(fp_hpp, " (&_elements[i])->step(cycles);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
907 fprintf(fp_hpp, " };\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
908 fprintf(fp_hpp, " static const Pipeline_Use elaborated_use;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
909 fprintf(fp_hpp, " static const Pipeline_Use_Element elaborated_elements[%d];\n\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
910 rescount);
a61af66fc99e Initial load
duke
parents:
diff changeset
911 fprintf(fp_hpp, " friend class Pipeline;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
912 fprintf(fp_hpp, "};\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
913
a61af66fc99e Initial load
duke
parents:
diff changeset
914 fprintf(fp_hpp, "// Pipeline Class\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
915 fprintf(fp_hpp, "class Pipeline {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
916 fprintf(fp_hpp, "public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
917
a61af66fc99e Initial load
duke
parents:
diff changeset
918 fprintf(fp_hpp, " static bool enabled() { return %s; }\n\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
919 _pipeline ? "true" : "false" );
a61af66fc99e Initial load
duke
parents:
diff changeset
920
a61af66fc99e Initial load
duke
parents:
diff changeset
921 assert( _pipeline->_maxInstrsPerBundle &&
a61af66fc99e Initial load
duke
parents:
diff changeset
922 ( _pipeline->_instrUnitSize || _pipeline->_bundleUnitSize) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
923 _pipeline->_instrFetchUnitSize &&
a61af66fc99e Initial load
duke
parents:
diff changeset
924 _pipeline->_instrFetchUnits,
a61af66fc99e Initial load
duke
parents:
diff changeset
925 "unspecified pipeline architecture units");
a61af66fc99e Initial load
duke
parents:
diff changeset
926
a61af66fc99e Initial load
duke
parents:
diff changeset
927 uint unitSize = _pipeline->_instrUnitSize ? _pipeline->_instrUnitSize : _pipeline->_bundleUnitSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
928
a61af66fc99e Initial load
duke
parents:
diff changeset
929 fprintf(fp_hpp, " enum {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
930 fprintf(fp_hpp, " _variable_size_instructions = %d,\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
931 _pipeline->_variableSizeInstrs ? 1 : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
932 fprintf(fp_hpp, " _fixed_size_instructions = %d,\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
933 _pipeline->_variableSizeInstrs ? 0 : 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
934 fprintf(fp_hpp, " _branch_has_delay_slot = %d,\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
935 _pipeline->_branchHasDelaySlot ? 1 : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
936 fprintf(fp_hpp, " _max_instrs_per_bundle = %d,\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
937 _pipeline->_maxInstrsPerBundle);
a61af66fc99e Initial load
duke
parents:
diff changeset
938 fprintf(fp_hpp, " _max_bundles_per_cycle = %d,\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
939 _pipeline->_maxBundlesPerCycle);
a61af66fc99e Initial load
duke
parents:
diff changeset
940 fprintf(fp_hpp, " _max_instrs_per_cycle = %d\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
941 _pipeline->_maxBundlesPerCycle * _pipeline->_maxInstrsPerBundle);
a61af66fc99e Initial load
duke
parents:
diff changeset
942 fprintf(fp_hpp, " };\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
943
a61af66fc99e Initial load
duke
parents:
diff changeset
944 fprintf(fp_hpp, " static bool instr_has_unit_size() { return %s; }\n\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
945 _pipeline->_instrUnitSize != 0 ? "true" : "false" );
a61af66fc99e Initial load
duke
parents:
diff changeset
946 if( _pipeline->_bundleUnitSize != 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
947 if( _pipeline->_instrUnitSize != 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
948 fprintf(fp_hpp, "// Individual Instructions may be bundled together by the hardware\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
949 else
a61af66fc99e Initial load
duke
parents:
diff changeset
950 fprintf(fp_hpp, "// Instructions exist only in bundles\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
951 else
a61af66fc99e Initial load
duke
parents:
diff changeset
952 fprintf(fp_hpp, "// Bundling is not supported\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
953 if( _pipeline->_instrUnitSize != 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
954 fprintf(fp_hpp, " // Size of an instruction\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
955 else
a61af66fc99e Initial load
duke
parents:
diff changeset
956 fprintf(fp_hpp, " // Size of an individual instruction does not exist - unsupported\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
957 fprintf(fp_hpp, " static uint instr_unit_size() {");
a61af66fc99e Initial load
duke
parents:
diff changeset
958 if( _pipeline->_instrUnitSize == 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
959 fprintf(fp_hpp, " assert( false, \"Instructions are only in bundles\" );");
a61af66fc99e Initial load
duke
parents:
diff changeset
960 fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_instrUnitSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
961
a61af66fc99e Initial load
duke
parents:
diff changeset
962 if( _pipeline->_bundleUnitSize != 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
963 fprintf(fp_hpp, " // Size of a bundle\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
964 else
a61af66fc99e Initial load
duke
parents:
diff changeset
965 fprintf(fp_hpp, " // Bundles do not exist - unsupported\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
966 fprintf(fp_hpp, " static uint bundle_unit_size() {");
a61af66fc99e Initial load
duke
parents:
diff changeset
967 if( _pipeline->_bundleUnitSize == 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
968 fprintf(fp_hpp, " assert( false, \"Bundles are not supported\" );");
a61af66fc99e Initial load
duke
parents:
diff changeset
969 fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_bundleUnitSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
970
a61af66fc99e Initial load
duke
parents:
diff changeset
971 fprintf(fp_hpp, " static bool requires_bundling() { return %s; }\n\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
972 _pipeline->_bundleUnitSize != 0 && _pipeline->_instrUnitSize == 0 ? "true" : "false" );
a61af66fc99e Initial load
duke
parents:
diff changeset
973
a61af66fc99e Initial load
duke
parents:
diff changeset
974 fprintf(fp_hpp, "private:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
975 fprintf(fp_hpp, " Pipeline(); // Not a legal constructor\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
976 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
977 fprintf(fp_hpp, " const unsigned char _read_stage_count;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
978 fprintf(fp_hpp, " const unsigned char _write_stage;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
979 fprintf(fp_hpp, " const unsigned char _fixed_latency;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
980 fprintf(fp_hpp, " const unsigned char _instruction_count;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
981 fprintf(fp_hpp, " const bool _has_fixed_latency;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
982 fprintf(fp_hpp, " const bool _has_branch_delay;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
983 fprintf(fp_hpp, " const bool _has_multiple_bundles;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
984 fprintf(fp_hpp, " const bool _force_serialization;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
985 fprintf(fp_hpp, " const bool _may_have_no_code;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
986 fprintf(fp_hpp, " const enum machPipelineStages * const _read_stages;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
987 fprintf(fp_hpp, " const enum machPipelineStages * const _resource_stage;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
988 fprintf(fp_hpp, " const uint * const _resource_cycles;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
989 fprintf(fp_hpp, " const Pipeline_Use _resource_use;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
990 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
991 fprintf(fp_hpp, "public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
992 fprintf(fp_hpp, " Pipeline(uint write_stage,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
993 fprintf(fp_hpp, " uint count,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
994 fprintf(fp_hpp, " bool has_fixed_latency,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
995 fprintf(fp_hpp, " uint fixed_latency,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
996 fprintf(fp_hpp, " uint instruction_count,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
997 fprintf(fp_hpp, " bool has_branch_delay,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
998 fprintf(fp_hpp, " bool has_multiple_bundles,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
999 fprintf(fp_hpp, " bool force_serialization,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 fprintf(fp_hpp, " bool may_have_no_code,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 fprintf(fp_hpp, " enum machPipelineStages * const dst,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 fprintf(fp_hpp, " enum machPipelineStages * const stage,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 fprintf(fp_hpp, " uint * const cycles,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 fprintf(fp_hpp, " Pipeline_Use resource_use)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 fprintf(fp_hpp, " : _write_stage(write_stage)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 fprintf(fp_hpp, " , _read_stage_count(count)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 fprintf(fp_hpp, " , _has_fixed_latency(has_fixed_latency)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 fprintf(fp_hpp, " , _fixed_latency(fixed_latency)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 fprintf(fp_hpp, " , _read_stages(dst)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 fprintf(fp_hpp, " , _resource_stage(stage)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 fprintf(fp_hpp, " , _resource_cycles(cycles)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 fprintf(fp_hpp, " , _resource_use(resource_use)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 fprintf(fp_hpp, " , _instruction_count(instruction_count)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 fprintf(fp_hpp, " , _has_branch_delay(has_branch_delay)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 fprintf(fp_hpp, " , _has_multiple_bundles(has_multiple_bundles)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 fprintf(fp_hpp, " , _force_serialization(force_serialization)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 fprintf(fp_hpp, " , _may_have_no_code(may_have_no_code)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 fprintf(fp_hpp, " {};\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 fprintf(fp_hpp, " uint writeStage() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 fprintf(fp_hpp, " return (_write_stage);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 fprintf(fp_hpp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 fprintf(fp_hpp, " enum machPipelineStages readStage(int ndx) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 fprintf(fp_hpp, " return (ndx < _read_stage_count ? _read_stages[ndx] : stage_undefined);");
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 fprintf(fp_hpp, " }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 fprintf(fp_hpp, " uint resourcesUsed() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 fprintf(fp_hpp, " return _resource_use.resourcesUsed();\n }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 fprintf(fp_hpp, " uint resourcesUsedExclusively() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 fprintf(fp_hpp, " return _resource_use.resourcesUsedExclusively();\n }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 fprintf(fp_hpp, " bool hasFixedLatency() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 fprintf(fp_hpp, " return (_has_fixed_latency);\n }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 fprintf(fp_hpp, " uint fixedLatency() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 fprintf(fp_hpp, " return (_fixed_latency);\n }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 fprintf(fp_hpp, " uint functional_unit_latency(uint start, const Pipeline *pred) const;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 fprintf(fp_hpp, " uint operand_latency(uint opnd, const Pipeline *pred) const;\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 fprintf(fp_hpp, " const Pipeline_Use& resourceUse() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 fprintf(fp_hpp, " return (_resource_use); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 fprintf(fp_hpp, " const Pipeline_Use_Element * resourceUseElement(uint i) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 fprintf(fp_hpp, " return (&_resource_use._elements[i]); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 fprintf(fp_hpp, " uint resourceUseCount() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 fprintf(fp_hpp, " return (_resource_use._count); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 fprintf(fp_hpp, " uint instructionCount() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 fprintf(fp_hpp, " return (_instruction_count); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 fprintf(fp_hpp, " bool hasBranchDelay() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 fprintf(fp_hpp, " return (_has_branch_delay); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 fprintf(fp_hpp, " bool hasMultipleBundles() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 fprintf(fp_hpp, " return (_has_multiple_bundles); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 fprintf(fp_hpp, " bool forceSerialization() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 fprintf(fp_hpp, " return (_force_serialization); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 fprintf(fp_hpp, " bool mayHaveNoCode() const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 fprintf(fp_hpp, " return (_may_have_no_code); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 fprintf(fp_hpp, "//const Pipeline_Use_Cycle_Mask& resourceUseMask(int resource) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 fprintf(fp_hpp, "// return (_resource_use_masks[resource]); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 fprintf(fp_hpp, "\n#ifndef PRODUCT\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 fprintf(fp_hpp, " static const char * stageName(uint i);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 fprintf(fp_hpp, "#endif\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 fprintf(fp_hpp, "};\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1059
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 fprintf(fp_hpp, "// Bundle class\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 fprintf(fp_hpp, "class Bundle {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1062
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 uint mshift = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 for (uint msize = _pipeline->_maxInstrsPerBundle * _pipeline->_maxBundlesPerCycle; msize != 0; msize >>= 1)
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 mshift++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1066
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 uint rshift = rescount;
a61af66fc99e Initial load
duke
parents:
diff changeset
1068
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 fprintf(fp_hpp, "protected:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 fprintf(fp_hpp, " enum {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 fprintf(fp_hpp, " _unused_delay = 0x%x,\n", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 fprintf(fp_hpp, " _use_nop_delay = 0x%x,\n", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 fprintf(fp_hpp, " _use_unconditional_delay = 0x%x,\n", 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 fprintf(fp_hpp, " _use_conditional_delay = 0x%x,\n", 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 fprintf(fp_hpp, " _used_in_conditional_delay = 0x%x,\n", 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 fprintf(fp_hpp, " _used_in_unconditional_delay = 0x%x,\n", 5);
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 fprintf(fp_hpp, " _used_in_all_conditional_delays = 0x%x,\n", 6);
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 fprintf(fp_hpp, " _use_delay = 0x%x,\n", 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 fprintf(fp_hpp, " _used_in_delay = 0x%x\n", 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 fprintf(fp_hpp, " };\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 fprintf(fp_hpp, " uint _flags : 3,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 fprintf(fp_hpp, " _starts_bundle : 1,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 fprintf(fp_hpp, " _instr_count : %d,\n", mshift);
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 fprintf(fp_hpp, " _resources_used : %d;\n", rshift);
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 fprintf(fp_hpp, "public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 fprintf(fp_hpp, " Bundle() : _flags(_unused_delay), _starts_bundle(0), _instr_count(0), _resources_used(0) {}\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 fprintf(fp_hpp, " void set_instr_count(uint i) { _instr_count = i; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 fprintf(fp_hpp, " void set_resources_used(uint i) { _resources_used = i; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 fprintf(fp_hpp, " void clear_usage() { _flags = _unused_delay; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 fprintf(fp_hpp, " void set_starts_bundle() { _starts_bundle = true; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1092
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 fprintf(fp_hpp, " uint flags() const { return (_flags); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 fprintf(fp_hpp, " uint instr_count() const { return (_instr_count); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 fprintf(fp_hpp, " uint resources_used() const { return (_resources_used); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 fprintf(fp_hpp, " bool starts_bundle() const { return (_starts_bundle != 0); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1097
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 fprintf(fp_hpp, " void set_use_nop_delay() { _flags = _use_nop_delay; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 fprintf(fp_hpp, " void set_use_unconditional_delay() { _flags = _use_unconditional_delay; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 fprintf(fp_hpp, " void set_use_conditional_delay() { _flags = _use_conditional_delay; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 fprintf(fp_hpp, " void set_used_in_unconditional_delay() { _flags = _used_in_unconditional_delay; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 fprintf(fp_hpp, " void set_used_in_conditional_delay() { _flags = _used_in_conditional_delay; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 fprintf(fp_hpp, " void set_used_in_all_conditional_delays() { _flags = _used_in_all_conditional_delays; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1104
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 fprintf(fp_hpp, " bool use_nop_delay() { return (_flags == _use_nop_delay); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 fprintf(fp_hpp, " bool use_unconditional_delay() { return (_flags == _use_unconditional_delay); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 fprintf(fp_hpp, " bool use_conditional_delay() { return (_flags == _use_conditional_delay); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 fprintf(fp_hpp, " bool used_in_unconditional_delay() { return (_flags == _used_in_unconditional_delay); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 fprintf(fp_hpp, " bool used_in_conditional_delay() { return (_flags == _used_in_conditional_delay); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 fprintf(fp_hpp, " bool used_in_all_conditional_delays() { return (_flags == _used_in_all_conditional_delays); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 fprintf(fp_hpp, " bool use_delay() { return ((_flags & _use_delay) != 0); }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 fprintf(fp_hpp, " bool used_in_delay() { return ((_flags & _used_in_delay) != 0); }\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1113
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 fprintf(fp_hpp, " enum {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 fprintf(fp_hpp, " _nop_count = %d\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 _pipeline->_nopcnt);
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 fprintf(fp_hpp, " };\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 fprintf(fp_hpp, " static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 _pipeline->_nopcnt);
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 fprintf(fp_hpp, "#ifndef PRODUCT\n");
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1121 fprintf(fp_hpp, " void dump(outputStream *st = tty) const;\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 fprintf(fp_hpp, "#endif\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 fprintf(fp_hpp, "};\n\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1124
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 // const char *classname;
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 // for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 // PipeClassForm *pipeclass = _pipeline->_classdict[classname]->is_pipeclass();
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 // fprintf(fp_hpp, "// Pipeline Class Instance for \"%s\"\n", classname);
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1131
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 //------------------------------declareClasses---------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 // Construct the class hierarchy of MachNode classes from the instruction &
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 // operand lists
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 void ArchDesc::declareClasses(FILE *fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1136
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 // Declare an array containing the machine register names, strings.
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 declareRegNames(fp, _register);
a61af66fc99e Initial load
duke
parents:
diff changeset
1139
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 // Declare an array containing the machine register encoding values
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 declareRegEncodes(fp, _register);
a61af66fc99e Initial load
duke
parents:
diff changeset
1142
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 // Generate declarations for the total number of operands
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 fprintf(fp,"// Total number of operands defined in architecture definition\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 int num_operands = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 OperandForm *op;
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 for (_operands.reset(); (op = (OperandForm*)_operands.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 // Ensure this is a machine-world instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 if (op->ideal_only()) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1151
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 ++num_operands;
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 int first_operand_class = num_operands;
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 OpClassForm *opc;
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 for (_opclass.reset(); (opc = (OpClassForm*)_opclass.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 // Ensure this is a machine-world instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 if (opc->ideal_only()) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1159
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 ++num_operands;
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 fprintf(fp,"#define FIRST_OPERAND_CLASS %d\n", first_operand_class);
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 fprintf(fp,"#define NUM_OPERANDS %d\n", num_operands);
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 // Generate declarations for the total number of instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 fprintf(fp,"// Total number of instructions defined in architecture definition\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 fprintf(fp,"#define NUM_INSTRUCTIONS %d\n",instructFormCount());
a61af66fc99e Initial load
duke
parents:
diff changeset
1168
a61af66fc99e Initial load
duke
parents:
diff changeset
1169
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 // Generate Machine Classes for each operand defined in AD file
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 fprintf(fp,"//----------------------------Declare classes derived from MachOper----------\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 // Iterate through all operands
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 _operands.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 OperandForm *oper;
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 for( ; (oper = (OperandForm*)_operands.iter()) != NULL;) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 // Ensure this is a machine-world instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 if (oper->ideal_only() ) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 // The declaration of labelOper is in machine-independent file: machnode
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 if ( strcmp(oper->_ident,"label") == 0 ) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 // The declaration of methodOper is in machine-independent file: machnode
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 if ( strcmp(oper->_ident,"method") == 0 ) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1183
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 // Build class definition for this operand
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 fprintf(fp,"class %sOper : public MachOper { \n",oper->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 fprintf(fp,"private:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 // Operand definitions that depend upon number of input edges
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 uint num_edges = oper->num_edges(_globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 if( num_edges != 1 ) { // Use MachOper::num_edges() {return 1;}
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 fprintf(fp," virtual uint num_edges() const { return %d; }\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 num_edges );
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 if( num_edges > 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 in_RegMask(fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1199
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 // Support storing constants inside the MachOper
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 declareConstStorage(fp,_globalNames,oper);
a61af66fc99e Initial load
duke
parents:
diff changeset
1202
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 // Support storage of the condition codes
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 if( oper->is_ideal_bool() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 fprintf(fp," virtual int ccode() const { \n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 fprintf(fp," switch (_c0) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 fprintf(fp," case BoolTest::eq : return equal();\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 fprintf(fp," case BoolTest::gt : return greater();\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 fprintf(fp," case BoolTest::lt : return less();\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 fprintf(fp," case BoolTest::ne : return not_equal();\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 fprintf(fp," case BoolTest::le : return less_equal();\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 fprintf(fp," case BoolTest::ge : return greater_equal();\n");
12323
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1213 fprintf(fp," case BoolTest::overflow : return overflow();\n");
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1214 fprintf(fp," case BoolTest::no_overflow: return no_overflow();\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 fprintf(fp," default : ShouldNotReachHere(); return 0;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 fprintf(fp," };\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1219
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 // Support storage of the condition codes
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 if( oper->is_ideal_bool() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 fprintf(fp," virtual void negate() { \n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 fprintf(fp," _c0 = (BoolTest::mask)((int)_c0^0x4); \n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 fprintf(fp," };\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1226
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 // Declare constructor.
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 // Parameters start with condition code, then all other constants
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 // (1) MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn)
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 // (2) : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 Form::DataType constant_type = oper->simple_type(_globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 defineConstructor(fp, oper->_ident, oper->num_consts(_globalNames),
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 oper->_components, oper->is_ideal_bool(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 constant_type, _globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1237
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 // Clone function
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 fprintf(fp," virtual MachOper *clone(Compile* C) const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1240
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 // Support setting a spill offset into a constant operand.
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 // We only support setting an 'int' offset, while in the
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 // LP64 build spill offsets are added with an AddP which
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 // requires a long constant. Thus we don't support spilling
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 // in frames larger than 4Gig.
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 if( oper->has_conI(_globalNames) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 oper->has_conL(_globalNames) )
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 fprintf(fp, " virtual void set_con( jint c0 ) { _c0 = c0; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1249
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 // virtual functions for encoding and format
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 // fprintf(fp," virtual void encode() const {\n %s }\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 // (oper->_encrule)?(oper->_encrule->_encrule):"");
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 // Check the interface type, and generate the correct query functions
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 // encoding queries based upon MEMORY_INTER, REG_INTER, CONST_INTER.
a61af66fc99e Initial load
duke
parents:
diff changeset
1255
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 fprintf(fp," virtual uint opcode() const { return %s; }\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 machOperEnum(oper->_ident));
a61af66fc99e Initial load
duke
parents:
diff changeset
1258
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 // virtual function to look up ideal return type of machine instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 // (1) virtual const Type *type() const { return .....; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 (oper->_matrule->_rChild == NULL)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 unsigned int position = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 const char *opret, *opname, *optype;
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 oper->_matrule->base_operand(position,_globalNames,opret,opname,optype);
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1268 fprintf(fp," virtual const Type *type() const {");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 const char *type = getIdealType(optype);
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 if( type != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 Form::DataType data_type = oper->is_base_constant(_globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 // Check if we are an ideal pointer type
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1273 if( data_type == Form::idealP || data_type == Form::idealN || data_type == Form::idealNKlass ) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 // Return the ideal type we already have: <TypePtr *>
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 fprintf(fp," return _c0;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 // Return the appropriate bottom type
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 fprintf(fp," return %s;", getIdealType(optype));
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 fprintf(fp," ShouldNotCallThis(); return Type::BOTTOM;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 // Check for user-defined stack slots, based upon sRegX
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 Form::DataType data_type = oper->is_user_name_for_sReg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 if( data_type != Form::none ){
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 const char *type = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 switch( data_type ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 case Form::idealI: type = "TypeInt::INT"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 case Form::idealP: type = "TypePtr::BOTTOM";break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 case Form::idealF: type = "Type::FLOAT"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 case Form::idealD: type = "Type::DOUBLE"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 case Form::idealL: type = "TypeLong::LONG"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 case Form::none: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 assert( false, "No support for this type of stackSlot");
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 fprintf(fp," virtual const Type *type() const { return %s; } // stackSlotX\n", type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1302
a61af66fc99e Initial load
duke
parents:
diff changeset
1303
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 // virtual functions for defining the encoding interface.
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 // Access the linearized ideal register mask,
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 // map to physical register encoding
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 if ( oper->_matrule && oper->_matrule->is_base_register(_globalNames) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 // Just use the default virtual 'reg' call
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 } else if ( oper->ideal_to_sReg_type(oper->_ident) != Form::none ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 // Special handling for operand 'sReg', a Stack Slot Register.
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 // Map linearized ideal register mask to stack slot number
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 fprintf(fp," virtual int reg(PhaseRegAlloc *ra_, const Node *node) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 fprintf(fp," return (int)OptoReg::reg2stack(ra_->get_reg_first(node));/* sReg */\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 fprintf(fp," virtual int reg(PhaseRegAlloc *ra_, const Node *node, int idx) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 fprintf(fp," return (int)OptoReg::reg2stack(ra_->get_reg_first(node->in(idx)));/* sReg */\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1321
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 // Output the operand specific access functions used by an enc_class
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 // These are only defined when we want to override the default virtual func
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 if (oper->_interface != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 // Check if it is a Memory Interface
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 if ( oper->_interface->is_MemInterface() != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 MemInterface *mem_interface = oper->_interface->is_MemInterface();
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 const char *base = mem_interface->_base;
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 if( base != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 define_oper_interface(fp, *oper, _globalNames, "base", base);
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 char *index = mem_interface->_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 if( index != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 define_oper_interface(fp, *oper, _globalNames, "index", index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 const char *scale = mem_interface->_scale;
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 if( scale != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 define_oper_interface(fp, *oper, _globalNames, "scale", scale);
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 const char *disp = mem_interface->_disp;
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 if( disp != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 define_oper_interface(fp, *oper, _globalNames, "disp", disp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 oper->disp_is_oop(fp, _globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 if( oper->stack_slots_only(_globalNames) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 // should not call this:
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 fprintf(fp," virtual int constant_disp() const { return Type::OffsetBot; }");
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 } else if ( disp != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 define_oper_interface(fp, *oper, _globalNames, "constant_disp", disp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 } // end Memory Interface
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 // Check if it is a Conditional Interface
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 else if (oper->_interface->is_CondInterface() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 CondInterface *cInterface = oper->_interface->is_CondInterface();
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 const char *equal = cInterface->_equal;
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 if( equal != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 define_oper_interface(fp, *oper, _globalNames, "equal", equal);
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 const char *not_equal = cInterface->_not_equal;
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 if( not_equal != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 define_oper_interface(fp, *oper, _globalNames, "not_equal", not_equal);
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 const char *less = cInterface->_less;
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 if( less != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 define_oper_interface(fp, *oper, _globalNames, "less", less);
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 const char *greater_equal = cInterface->_greater_equal;
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 if( greater_equal != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 define_oper_interface(fp, *oper, _globalNames, "greater_equal", greater_equal);
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 const char *less_equal = cInterface->_less_equal;
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 if( less_equal != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 define_oper_interface(fp, *oper, _globalNames, "less_equal", less_equal);
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 const char *greater = cInterface->_greater;
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 if( greater != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 define_oper_interface(fp, *oper, _globalNames, "greater", greater);
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 }
12323
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1380 const char *overflow = cInterface->_overflow;
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1381 if( overflow != NULL ) {
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1382 define_oper_interface(fp, *oper, _globalNames, "overflow", overflow);
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1383 }
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1384 const char *no_overflow = cInterface->_no_overflow;
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1385 if( no_overflow != NULL ) {
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1386 define_oper_interface(fp, *oper, _globalNames, "no_overflow", no_overflow);
c9ccd7b85f20 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 9078
diff changeset
1387 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 } // end Conditional Interface
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 // Check if it is a Constant Interface
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 else if (oper->_interface->is_ConstInterface() != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 assert( oper->num_consts(_globalNames) == 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 "Must have one constant when using CONST_INTER encoding");
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 if (!strcmp(oper->ideal_type(_globalNames), "ConI")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 // Access the locally stored constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 fprintf(fp," virtual intptr_t constant() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 fprintf(fp, " return (intptr_t)_c0;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 else if (!strcmp(oper->ideal_type(_globalNames), "ConP")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 // Access the locally stored constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 fprintf(fp," virtual intptr_t constant() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 fprintf(fp, " return _c0->get_con();");
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 // Generate query to determine if this pointer is an oop
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1405 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1406 fprintf(fp, " return _c0->reloc();");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1409 else if (!strcmp(oper->ideal_type(_globalNames), "ConN")) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1410 // Access the locally stored constant
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1411 fprintf(fp," virtual intptr_t constant() const {");
827
bf3489cc0aa0 6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents: 605
diff changeset
1412 fprintf(fp, " return _c0->get_ptrtype()->get_con();");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1413 fprintf(fp, " }\n");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1414 // Generate query to determine if this pointer is an oop
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1415 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
1416 fprintf(fp, " return _c0->get_ptrtype()->reloc();");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1417 fprintf(fp, " }\n");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1418 }
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1419 else if (!strcmp(oper->ideal_type(_globalNames), "ConNKlass")) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1420 // Access the locally stored constant
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1421 fprintf(fp," virtual intptr_t constant() const {");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1422 fprintf(fp, " return _c0->get_ptrtype()->get_con();");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1423 fprintf(fp, " }\n");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1424 // Generate query to determine if this pointer is an oop
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1425 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1426 fprintf(fp, " return _c0->get_ptrtype()->reloc();");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1427 fprintf(fp, " }\n");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1428 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 else if (!strcmp(oper->ideal_type(_globalNames), "ConL")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 fprintf(fp," virtual intptr_t constant() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 // We don't support addressing modes with > 4Gig offsets.
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 // Truncate to int.
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 fprintf(fp, " return (intptr_t)_c0;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1434 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 fprintf(fp," virtual jlong constantL() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 fprintf(fp, " return _c0;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 else if (!strcmp(oper->ideal_type(_globalNames), "ConF")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 fprintf(fp," virtual intptr_t constant() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 fprintf(fp, " ShouldNotReachHere(); return 0; ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 fprintf(fp," virtual jfloat constantF() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 fprintf(fp, " return (jfloat)_c0;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 else if (!strcmp(oper->ideal_type(_globalNames), "ConD")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 fprintf(fp," virtual intptr_t constant() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 fprintf(fp, " ShouldNotReachHere(); return 0; ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 fprintf(fp," virtual jdouble constantD() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 fprintf(fp, " return _c0;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 else if (oper->_interface->is_RegInterface() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 // make sure that a fixed format string isn't used for an
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 // operand which might be assiged to multiple registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 // Otherwise the opto assembly output could be misleading.
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 if (oper->_format->_strings.count() != 0 && !oper->is_bound_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 syntax_err(oper->_linenum,
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 "Only bound registers can have fixed formats: %s\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 oper->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 assert( false, "ShouldNotReachHere();");
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1470
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 // // Currently all XXXOper::hash() methods are identical (990820)
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 // declare_hash(fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1474 // // Currently all XXXOper::Cmp() methods are identical (990820)
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 // declare_cmp(fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1476
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 // Do not place dump_spec() and Name() into PRODUCT code
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 // int_format and ext_format are not needed in PRODUCT code either
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 fprintf(fp, "#ifndef PRODUCT\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1480
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 // Declare int_format() and ext_format()
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 gen_oper_format(fp, _globalNames, *oper);
a61af66fc99e Initial load
duke
parents:
diff changeset
1483
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 // Machine independent print functionality for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 // IF we have constants, create a dump_spec function for the derived class
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 // (1) virtual void dump_spec() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 // (2) st->print("#%d", _c#); // Constant != ConP
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 // OR _c#->dump_on(st); // Type ConP
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 // (3) }
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 uint num_consts = oper->num_consts(_globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 if( num_consts > 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 // line (1)
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 fprintf(fp, " virtual void dump_spec(outputStream *st) const {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 // generate format string for st->print
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 // Iterate over the component list & spit out the right thing
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 uint i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 const char *type = oper->ideal_type(_globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 Component *comp;
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 oper->_components.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 if ((comp = oper->_components.iter()) == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 assert(num_consts == 1, "Bad component list detected.\n");
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
1504 i = dump_spec_constant( fp, type, i, oper );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 // Check that type actually matched
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 assert( i != 0, "Non-constant operand lacks component list.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 } // end if NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 // line (2)
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 // dump all components
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 oper->_components.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 while((comp = oper->_components.iter()) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 type = comp->base_type(_globalNames);
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 293
diff changeset
1514 i = dump_spec_constant( fp, type, i, NULL );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1517 // finish line (3)
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1520
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 fprintf(fp," virtual const char *Name() const { return \"%s\";}\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1522 oper->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1523
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 fprintf(fp,"#endif\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1525
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 // Close definition of this XxxMachOper
a61af66fc99e Initial load
duke
parents:
diff changeset
1527 fprintf(fp,"};\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1529
a61af66fc99e Initial load
duke
parents:
diff changeset
1530
a61af66fc99e Initial load
duke
parents:
diff changeset
1531 // Generate Machine Classes for each instruction defined in AD file
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 fprintf(fp,"//----------------------------Declare classes for Pipelines-----------------\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 declare_pipe_classes(fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1535
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 // Generate Machine Classes for each instruction defined in AD file
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 fprintf(fp,"//----------------------------Declare classes derived from MachNode----------\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 _instructions.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 InstructForm *instr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 for( ; (instr = (InstructForm*)_instructions.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 // Ensure this is a machine-world instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 if ( instr->ideal_only() ) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1544
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 // Build class definition for this instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 fprintf(fp,"class %sNode : public %s { \n",
1541
b5fdf39b9749 6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents: 1203
diff changeset
1548 instr->_ident, instr->mach_base_class(_globalNames) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 fprintf(fp,"private:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() );
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 if ( instr->is_ideal_jump() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 fprintf(fp, " GrowableArray<Label*> _index2label;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 }
14909
4ca6dc0799b6 Backout jdk9 merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14456
diff changeset
1554 fprintf(fp,"public:\n");
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1555 fprintf(fp," MachOper *opnd_array(uint operand_index) const {\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1556 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1557 fprintf(fp," return _opnd_array[operand_index];\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1558 fprintf(fp," }\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1559 fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) {\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1560 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1561 fprintf(fp," _opnd_array[operand_index] = operand;\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1562 fprintf(fp," }\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 fprintf(fp,"private:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 if ( instr->is_ideal_jump() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 fprintf(fp," virtual void add_case_label(int index_num, Label* blockLabel) {\n");
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1566 fprintf(fp," _index2label.at_put_grow(index_num, blockLabel);\n");
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1567 fprintf(fp," }\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 fprintf(fp," const RegMask *_cisc_RegMask;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1572
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 out_RegMask(fp); // output register mask
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 fprintf(fp," virtual uint rule() const { return %s_rule; }\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 instr->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1576
a61af66fc99e Initial load
duke
parents:
diff changeset
1577 // If this instruction contains a labelOper
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 // Declare Node::methods that set operand Label's contents
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 int label_position = instr->label_position();
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 if( label_position != -1 ) {
3853
11211f7cb5a0 7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents: 3851
diff changeset
1581 // Set/Save the label, stored in labelOper::_branch_label
3839
3d42f82cd811 7063628: Use cbcond on T4
kvn
parents: 2008
diff changeset
1582 fprintf(fp," virtual void label_set( Label* label, uint block_num );\n");
3853
11211f7cb5a0 7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents: 3851
diff changeset
1583 fprintf(fp," virtual void save_label( Label** label, uint* block_num );\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1585
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 // If this instruction contains a methodOper
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 // Declare Node::methods that set operand method's contents
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 int method_position = instr->method_position();
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 if( method_position != -1 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 // Set the address method, stored in methodOper::_method
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 fprintf(fp," virtual void method_set( intptr_t method );\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1593
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 // virtual functions for attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 // Each instruction attribute results in a virtual call of same name.
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 // The ins_cost is not handled here.
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 Attribute *attr = instr->_attribs;
3851
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1599 bool avoid_back_to_back = false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1600 while (attr != NULL) {
14909
4ca6dc0799b6 Backout jdk9 merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14456
diff changeset
1601 if (strcmp(attr->_ident,"ins_cost") &&
4ca6dc0799b6 Backout jdk9 merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14456
diff changeset
1602 strcmp(attr->_ident,"ins_short_branch")) {
4ca6dc0799b6 Backout jdk9 merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14456
diff changeset
1603 fprintf(fp," int %s() const { return %s; }\n",
4ca6dc0799b6 Backout jdk9 merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14456
diff changeset
1604 attr->_ident, attr->_val);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 }
3851
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1606 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag
14909
4ca6dc0799b6 Backout jdk9 merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14456
diff changeset
1607 if (!strcmp(attr->_ident,"ins_avoid_back_to_back") && attr->int_val(*this) != 0)
3851
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1608 avoid_back_to_back = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 attr = (Attribute *)attr->_next;
a61af66fc99e Initial load
duke
parents:
diff changeset
1610 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1611
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 // virtual functions for encode and format
2008
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1552
diff changeset
1613
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1552
diff changeset
1614 // Virtual function for evaluating the constant.
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1552
diff changeset
1615 if (instr->is_mach_constant()) {
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1552
diff changeset
1616 fprintf(fp," virtual void eval_constant(Compile* C);\n");
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1552
diff changeset
1617 }
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1552
diff changeset
1618
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 // Output the opcode function and the encode function here using the
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 // encoding class information in the _insencode slot.
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 if ( instr->_insencode ) {
14909
4ca6dc0799b6 Backout jdk9 merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14456
diff changeset
1622 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1624
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 // virtual function for getting the size of an instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 if ( instr->_size ) {
2008
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1552
diff changeset
1627 fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1629
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 // Return the top-level ideal opcode.
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 // Use MachNode::ideal_Opcode() for nodes based on MachNode class
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 // if the ideal_Opcode == Op_Node.
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 ||
1541
b5fdf39b9749 6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents: 1203
diff changeset
1634 strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 fprintf(fp," virtual int ideal_Opcode() const { return Op_%s; }\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 instr->ideal_Opcode(_globalNames) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1638
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 // Allow machine-independent optimization, invert the sense of the IF test
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 if( instr->is_ideal_if() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 fprintf(fp," virtual void negate() { \n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 // Identify which operand contains the negate(able) ideal condition code
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 int idx = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 instr->_components.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 for( Component *comp; (comp = instr->_components.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 // Check that component is an operand
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 Form *form = (Form*)_globalNames[comp->_type];
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 OperandForm *opForm = form ? form->is_operand() : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 if( opForm == NULL ) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1650
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 // Lookup the position of the operand in the instruction.
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 if( opForm->is_ideal_bool() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 idx = instr->operand_position(comp->_name, comp->_usedef);
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 assert( idx != NameList::Not_in_list, "Did not find component in list that contained it.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 fprintf(fp," opnd_array(%d)->negate();\n", idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 fprintf(fp," _prob = 1.0f - _prob;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 fprintf(fp," };\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1662
a61af66fc99e Initial load
duke
parents:
diff changeset
1663
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 // Identify which input register matches the input register.
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 uint matching_input = instr->two_address(_globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1666
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 // Generate the method if it returns != 0 otherwise use MachNode::two_adr()
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 if( matching_input != 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 fprintf(fp," virtual uint two_adr() const ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 fprintf(fp,"{ return oper_input_base()");
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 for( uint i = 2; i <= matching_input; i++ )
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 fprintf(fp," + opnd_array(%d)->num_edges()",i-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 fprintf(fp,"; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1675
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 // Declare cisc_version, if applicable
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 // MachNode *cisc_version( int offset /* ,... */ );
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 instr->declare_cisc_version(*this, fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1679
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 // If there is an explicit peephole rule, build it
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 if ( instr->peepholes() != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1682 fprintf(fp," virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile *C);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1684
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 // Output the declaration for number of relocation entries
a61af66fc99e Initial load
duke
parents:
diff changeset
1686 if ( instr->reloc(_globalNames) != 0 ) {
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1687 fprintf(fp," virtual int reloc() const;\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1689
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 if (instr->alignment() != 1) {
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1691 fprintf(fp," virtual int alignment_required() const { return %d; }\n", instr->alignment());
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1692 fprintf(fp," virtual int compute_padding(int current_offset) const;\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1694
a61af66fc99e Initial load
duke
parents:
diff changeset
1695 // Starting point for inputs matcher wants.
a61af66fc99e Initial load
duke
parents:
diff changeset
1696 // Use MachNode::oper_input_base() for nodes based on MachNode class
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 // if the base == 1.
a61af66fc99e Initial load
duke
parents:
diff changeset
1698 if ( instr->oper_input_base(_globalNames) != 1 ||
1541
b5fdf39b9749 6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents: 1203
diff changeset
1699 strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 fprintf(fp," virtual uint oper_input_base() const { return %d; }\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 instr->oper_input_base(_globalNames));
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1703
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 // Make the constructor and following methods 'public:'
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 fprintf(fp,"public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1706
a61af66fc99e Initial load
duke
parents:
diff changeset
1707 // Constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 if ( instr->is_ideal_jump() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 fprintf(fp," %sNode() : _index2label(MinJumpTableSize*2) { ", instr->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 fprintf(fp," %sNode() { ", instr->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1713 fprintf(fp,"_cisc_RegMask = NULL; ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1716
a61af66fc99e Initial load
duke
parents:
diff changeset
1717 fprintf(fp," _num_opnds = %d; _opnds = _opnd_array; ", instr->num_opnds());
a61af66fc99e Initial load
duke
parents:
diff changeset
1718
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 bool node_flags_set = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 // flag: if this instruction matches an ideal 'Copy*' node
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 if ( instr->is_ideal_copy() != 0 ) {
3842
c7b60b601eb4 7069452: Cleanup NodeFlags
kvn
parents: 3839
diff changeset
1722 fprintf(fp,"init_flags(Flag_is_Copy");
c7b60b601eb4 7069452: Cleanup NodeFlags
kvn
parents: 3839
diff changeset
1723 node_flags_set = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1725
a61af66fc99e Initial load
duke
parents:
diff changeset
1726 // Is an instruction is a constant? If so, get its type
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 Form::DataType data_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 const char *opType = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 const char *result = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 data_type = instr->is_chain_of_constant(_globalNames, opType, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 // Check if this instruction is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 if ( data_type != Form::none ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1733 if ( node_flags_set ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 fprintf(fp," | Flag_is_Con");
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 fprintf(fp,"init_flags(Flag_is_Con");
a61af66fc99e Initial load
duke
parents:
diff changeset
1737 node_flags_set = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1739 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1740
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 // flag: if this instruction is cisc alternate
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 if ( can_cisc_spill() && instr->is_cisc_alternate() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 if ( node_flags_set ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 fprintf(fp," | Flag_is_cisc_alternate");
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 fprintf(fp,"init_flags(Flag_is_cisc_alternate");
a61af66fc99e Initial load
duke
parents:
diff changeset
1747 node_flags_set = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1750
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 // flag: if this instruction has short branch form
a61af66fc99e Initial load
duke
parents:
diff changeset
1752 if ( instr->has_short_branch_form() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 if ( node_flags_set ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 fprintf(fp," | Flag_may_be_short_branch");
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 fprintf(fp,"init_flags(Flag_may_be_short_branch");
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 node_flags_set = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1759 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1760
3851
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1761 // flag: if this instruction should not be generated back to back.
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1762 if ( avoid_back_to_back ) {
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1763 if ( node_flags_set ) {
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1764 fprintf(fp," | Flag_avoid_back_to_back");
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1765 } else {
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1766 fprintf(fp,"init_flags(Flag_avoid_back_to_back");
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1767 node_flags_set = true;
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1768 }
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1769 }
95134e034042 7063629: use cbcond in C2 generated code on T4
kvn
parents: 3842
diff changeset
1770
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1771 // Check if machine instructions that USE memory, but do not DEF memory,
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 // depend upon a node that defines memory in machine-independent graph.
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 if ( instr->needs_anti_dependence_check(_globalNames) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1774 if ( node_flags_set ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 fprintf(fp," | Flag_needs_anti_dependence_check");
a61af66fc99e Initial load
duke
parents:
diff changeset
1776 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 fprintf(fp,"init_flags(Flag_needs_anti_dependence_check");
a61af66fc99e Initial load
duke
parents:
diff changeset
1778 node_flags_set = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1781
4120
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1782 // flag: if this instruction is implemented with a call
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1783 if ( instr->_has_call ) {
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1784 if ( node_flags_set ) {
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1785 fprintf(fp," | Flag_has_call");
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1786 } else {
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1787 fprintf(fp,"init_flags(Flag_has_call");
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1788 node_flags_set = true;
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1789 }
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1790 }
f03a3c8bd5e5 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 3853
diff changeset
1791
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 if ( node_flags_set ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 fprintf(fp,"); ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1795
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 fprintf(fp,"}\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1797
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 // size_of, used by base class's clone to obtain the correct size.
a61af66fc99e Initial load
duke
parents:
diff changeset
1799 fprintf(fp," virtual uint size_of() const {");
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 fprintf(fp, " return sizeof(%sNode);", instr->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 fprintf(fp, " }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1802
a61af66fc99e Initial load
duke
parents:
diff changeset
1803 // Virtual methods which are only generated to override base class
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 if( instr->expands() || instr->needs_projections() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 instr->has_temps() ||
2008
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1552
diff changeset
1806 instr->is_mach_constant() ||
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 instr->_matrule != NULL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 instr->num_opnds() != instr->num_unique_opnds() ) {
1203
844a9d73ec22 6916644: C2 compiler crash on x86
never
parents: 827
diff changeset
1809 fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1811
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 if (instr->is_pinned(_globalNames)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 fprintf(fp," virtual bool pinned() const { return ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 if (instr->is_parm(_globalNames)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1815 fprintf(fp,"_in[0]->pinned();");
a61af66fc99e Initial load
duke
parents:
diff changeset
1816 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1817 fprintf(fp,"true;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1819 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 if (instr->is_projection(_globalNames)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 fprintf(fp," virtual const Node *is_block_proj() const { return this; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 if ( instr->num_post_match_opnds() != 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1825 || instr->is_chain_of_constant(_globalNames) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 fprintf(fp," friend MachNode *State::MachNodeGenerator(int opcode, Compile* C);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 if ( instr->rematerialize(_globalNames, get_registers()) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 fprintf(fp," // Rematerialize %s\n", instr->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1831
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 // Declare short branch methods, if applicable
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 instr->declare_short_branch_methods(fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1834
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 // See if there is an "ins_pipe" declaration for this instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 if (instr->_ins_pipe) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 fprintf(fp," static const Pipeline *pipeline_class();\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1838 fprintf(fp," virtual const Pipeline *pipeline() const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1840
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 // Generate virtual function for MachNodeX::bottom_type when necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
1842 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 // Note on accuracy: Pointer-types of machine nodes need to be accurate,
a61af66fc99e Initial load
duke
parents:
diff changeset
1844 // or else alias analysis on the matched graph may produce bad code.
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 // Moreover, the aliasing decisions made on machine-node graph must be
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 // no less accurate than those made on the ideal graph, or else the graph
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 // may fail to schedule. (Reason: Memory ops which are reordered in
a61af66fc99e Initial load
duke
parents:
diff changeset
1848 // the ideal graph might look interdependent in the machine graph,
a61af66fc99e Initial load
duke
parents:
diff changeset
1849 // thereby removing degrees of scheduling freedom that the optimizer
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 // assumed would be available.)
a61af66fc99e Initial load
duke
parents:
diff changeset
1851 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1852 // %%% We should handle many of these cases with an explicit ADL clause:
a61af66fc99e Initial load
duke
parents:
diff changeset
1853 // instruct foo() %{ ... bottom_type(TypeRawPtr::BOTTOM); ... %}
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 if( data_type != Form::none ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1855 // A constant's bottom_type returns a Type containing its constant value
a61af66fc99e Initial load
duke
parents:
diff changeset
1856
a61af66fc99e Initial load
duke
parents:
diff changeset
1857 // !!!!!
a61af66fc99e Initial load
duke
parents:
diff changeset
1858 // Convert all ints, floats, ... to machine-independent TypeXs
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 // as is done for pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 // Construct appropriate constant type containing the constant value.
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1862 fprintf(fp," virtual const class Type *bottom_type() const {\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1863 switch( data_type ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 case Form::idealI:
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 fprintf(fp," return TypeInt::make(opnd_array(1)->constant());\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 case Form::idealP:
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1868 case Form::idealN:
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
1869 case Form::idealNKlass:
603
dbbe28fc66b5 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 417
diff changeset
1870 fprintf(fp," return opnd_array(1)->type();\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 case Form::idealD:
a61af66fc99e Initial load
duke
parents:
diff changeset
1873 fprintf(fp," return TypeD::make(opnd_array(1)->constantD());\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1875 case Form::idealF:
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 fprintf(fp," return TypeF::make(opnd_array(1)->constantF());\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 case Form::idealL:
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 fprintf(fp," return TypeLong::make(opnd_array(1)->constantL());\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1881 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1882 assert( false, "Unimplemented()" );
a61af66fc99e Initial load
duke
parents:
diff changeset
1883 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1884 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 fprintf(fp," };\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1887 /* else if ( instr->_matrule && instr->_matrule->_rChild &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 // !!!!! !!!!!
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 // Provide explicit bottom type for conversions to int
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 // On Intel the result operand is a stackSlot, untyped.
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1893 fprintf(fp," virtual const class Type *bottom_type() const {");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 fprintf(fp, " return TypeInt::INT;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1895 fprintf(fp, " };\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1896 }*/
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 else if( instr->is_ideal_copy() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 !strcmp(instr->_matrule->_lChild->_opType,"stackSlotP") ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 // !!!!!
a61af66fc99e Initial load
duke
parents:
diff changeset
1900 // Special hack for ideal Copy of pointer. Bottom type is oop or not depending on input.
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 fprintf(fp," const Type *bottom_type() const { return in(1)->bottom_type(); } // Copy?\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 else if( instr->is_ideal_loadPC() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 // LoadPCNode provides the return address of a call to native code.
a61af66fc99e Initial load
duke
parents:
diff changeset
1905 // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 // since it is a pointer to an internal VM location and must have a zero offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 // Allocation detects derived pointers, in part, by their non-zero offsets.
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // LoadPC?\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1909 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1910 else if( instr->is_ideal_box() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1911 // BoxNode provides the address of a stack slot.
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 // This prevent s insert_anti_dependencies from complaining. It will
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
1914 // complain if it sees that the pointer base is TypePtr::BOTTOM since
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 // it doesn't understand what that might alias.
a61af66fc99e Initial load
duke
parents:
diff changeset
1916 fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // Box?\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1917 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveP") ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 int offset = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1920 // Special special hack to see if the Cmp? has been incorporated in the conditional move
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 MatchNode *rl = instr->_matrule->_rChild->_lChild;
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 if( rl && !strcmp(rl->_opType, "Binary") ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1923 MatchNode *rlr = rl->_rChild;
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 if (rlr && strncmp(rlr->_opType, "Cmp", 3) == 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 offset = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 // Special hack for ideal CMoveP; ideal type depends on inputs
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 fprintf(fp," const Type *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveP\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1929 offset, offset+1, offset+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1930 }
293
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1931 else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveN") ) {
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1932 int offset = 1;
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1933 // Special special hack to see if the Cmp? has been incorporated in the conditional move
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1934 MatchNode *rl = instr->_matrule->_rChild->_lChild;
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1935 if( rl && !strcmp(rl->_opType, "Binary") ) {
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1936 MatchNode *rlr = rl->_rChild;
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1937 if (rlr && strncmp(rlr->_opType, "Cmp", 3) == 0)
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1938 offset = 2;
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1939 }
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1940 // Special hack for ideal CMoveN; ideal type depends on inputs
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1941 fprintf(fp," const Type *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveN\n",
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1942 offset, offset+1, offset+1);
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
1943 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1944 else if (instr->is_tls_instruction()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1945 // Special hack for tlsLoadP
a61af66fc99e Initial load
duke
parents:
diff changeset
1946 fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // tlsLoadP\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1947 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1948 else if ( instr->is_ideal_if() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1949 fprintf(fp," const Type *bottom_type() const { return TypeTuple::IFBOTH; } // matched IfNode\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1951 else if ( instr->is_ideal_membar() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 fprintf(fp," const Type *bottom_type() const { return TypeTuple::MEMBAR; } // matched MemBar\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1954
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 // Check where 'ideal_type' must be customized
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 if ( instr->_matrule && instr->_matrule->_rChild &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1958 ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 fprintf(fp," virtual uint ideal_reg() const { return Compile::current()->matcher()->base2reg[Type::Int]; }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1961 }*/
a61af66fc99e Initial load
duke
parents:
diff changeset
1962
a61af66fc99e Initial load
duke
parents:
diff changeset
1963 // Analyze machine instructions that either USE or DEF memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
1964 int memory_operand = instr->memory_operand(_globalNames);
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 // Some guys kill all of memory
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 if ( instr->is_wide_memory_kill(_globalNames) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 memory_operand = InstructForm::MANY_MEMORY_OPERANDS;
a61af66fc99e Initial load
duke
parents:
diff changeset
1968 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 if ( memory_operand != InstructForm::NO_MEMORY_OPERAND ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1970 if( memory_operand == InstructForm::MANY_MEMORY_OPERANDS ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1971 fprintf(fp," virtual const TypePtr *adr_type() const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 fprintf(fp," virtual const MachOper *memory_operand() const;\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1975
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 fprintf(fp, "#ifndef PRODUCT\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1977
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 // virtual function for generating the user's assembler output
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 gen_inst_format(fp, _globalNames,*instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1980
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 // Machine independent print functionality for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 fprintf(fp," virtual const char *Name() const { return \"%s\";}\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
1983 instr->_ident);
a61af66fc99e Initial load
duke
parents:
diff changeset
1984
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 fprintf(fp, "#endif\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1986
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 // Close definition of this XxxMachNode
a61af66fc99e Initial load
duke
parents:
diff changeset
1988 fprintf(fp,"};\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1989 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1990
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1992
a61af66fc99e Initial load
duke
parents:
diff changeset
1993 void ArchDesc::defineStateClass(FILE *fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1994 static const char *state__valid = "_valid[((uint)index) >> 5] & (0x1 << (((uint)index) & 0x0001F))";
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 static const char *state__set_valid= "_valid[((uint)index) >> 5] |= (0x1 << (((uint)index) & 0x0001F))";
a61af66fc99e Initial load
duke
parents:
diff changeset
1996
a61af66fc99e Initial load
duke
parents:
diff changeset
1997 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1998 fprintf(fp,"// MACROS to inline and constant fold State::valid(index)...\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1999 fprintf(fp,"// when given a constant 'index' in dfa_<arch>.cpp\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2000 fprintf(fp,"// uint word = index >> 5; // Shift out bit position\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2001 fprintf(fp,"// uint bitpos = index & 0x0001F; // Mask off word bits\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2002 fprintf(fp,"#define STATE__VALID(index) ");
a61af66fc99e Initial load
duke
parents:
diff changeset
2003 fprintf(fp," (%s)\n", state__valid);
a61af66fc99e Initial load
duke
parents:
diff changeset
2004 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 fprintf(fp,"#define STATE__NOT_YET_VALID(index) ");
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 fprintf(fp," ( (%s) == 0 )\n", state__valid);
a61af66fc99e Initial load
duke
parents:
diff changeset
2007 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2008 fprintf(fp,"#define STATE__VALID_CHILD(state,index) ");
a61af66fc99e Initial load
duke
parents:
diff changeset
2009 fprintf(fp," ( state && (state->%s) )\n", state__valid);
a61af66fc99e Initial load
duke
parents:
diff changeset
2010 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 fprintf(fp,"#define STATE__SET_VALID(index) ");
a61af66fc99e Initial load
duke
parents:
diff changeset
2012 fprintf(fp," (%s)\n", state__set_valid);
a61af66fc99e Initial load
duke
parents:
diff changeset
2013 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 fprintf(fp,
a61af66fc99e Initial load
duke
parents:
diff changeset
2015 "//---------------------------State-------------------------------------------\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2016 fprintf(fp,"// State contains an integral cost vector, indexed by machine operand opcodes,\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2017 fprintf(fp,"// a rule vector consisting of machine operand/instruction opcodes, and also\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 fprintf(fp,"// indexed by machine operand opcodes, pointers to the children in the label\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2019 fprintf(fp,"// tree generated by the Label routines in ideal nodes (currently limited to\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2020 fprintf(fp,"// two for convenience, but this could change).\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2021 fprintf(fp,"class State : public ResourceObj {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2022 fprintf(fp,"public:\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2023 fprintf(fp," int _id; // State identifier\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2024 fprintf(fp," Node *_leaf; // Ideal (non-machine-node) leaf of match tree\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2025 fprintf(fp," State *_kids[2]; // Children of state node in label tree\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2026 fprintf(fp," unsigned int _cost[_LAST_MACH_OPER]; // Cost vector, indexed by operand opcodes\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2027 fprintf(fp," unsigned int _rule[_LAST_MACH_OPER]; // Rule vector, indexed by operand opcodes\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2028 fprintf(fp," unsigned int _valid[(_LAST_MACH_OPER/32)+1]; // Bit Map of valid Cost/Rule entries\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2029 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2030 fprintf(fp," State(void); // Constructor\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2031 fprintf(fp," DEBUG_ONLY( ~State(void); ) // Destructor\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2032 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2033 fprintf(fp," // Methods created by ADLC and invoked by Reduce\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 fprintf(fp," MachOper *MachOperGenerator( int opcode, Compile* C );\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2035 fprintf(fp," MachNode *MachNodeGenerator( int opcode, Compile* C );\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2037 fprintf(fp," // Assign a state to a node, definition of method produced by ADLC\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2038 fprintf(fp," bool DFA( int opcode, const Node *ideal );\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 fprintf(fp," // Access function for _valid bit vector\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 fprintf(fp," bool valid(uint index) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 fprintf(fp," return( STATE__VALID(index) != 0 );\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2044 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2045 fprintf(fp," // Set function for _valid bit vector\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 fprintf(fp," void set_valid(uint index) {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2047 fprintf(fp," STATE__SET_VALID(index);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 fprintf(fp," }\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2050 fprintf(fp,"#ifndef PRODUCT\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 fprintf(fp," void dump(); // Debugging prints\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 fprintf(fp," void dump(int depth);\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 fprintf(fp,"#endif\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2054 if (_dfa_small) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 // Generate the routine name we'll need
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 for (int i = 1; i < _last_opcode; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 if (_mlistab[i] == NULL) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 fprintf(fp, " void _sub_Op_%s(const Node *n);\n", NodeClassNames[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2061 fprintf(fp,"};\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 fprintf(fp,"\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2064
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2066
a61af66fc99e Initial load
duke
parents:
diff changeset
2067
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 //---------------------------buildMachOperEnum---------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
2069 // Build enumeration for densely packed operands.
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 // This enumeration is used to index into the arrays in the State objects
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 // that indicate cost and a successfull rule match.
a61af66fc99e Initial load
duke
parents:
diff changeset
2072
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 // Information needed to generate the ReduceOp mapping for the DFA
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 class OutputMachOperands : public OutputMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
2076 OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
2077 : OutputMap(hpp, cpp, globals, AD, "MachOperands") {};
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2078
a61af66fc99e Initial load
duke
parents:
diff changeset
2079 void declaration() { }
a61af66fc99e Initial load
duke
parents:
diff changeset
2080 void definition() { fprintf(_cpp, "enum MachOperands {\n"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
2081 void closing() { fprintf(_cpp, " _LAST_MACH_OPER\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2082 OutputMap::closing();
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 }
9078
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2084 void map(OpClassForm &opc) {
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2085 const char* opc_ident_to_upper = _AD.machOperEnum(opc._ident);
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2086 fprintf(_cpp, " %s", opc_ident_to_upper);
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2087 delete[] opc_ident_to_upper;
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2088 }
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2089 void map(OperandForm &oper) {
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2090 const char* oper_ident_to_upper = _AD.machOperEnum(oper._ident);
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2091 fprintf(_cpp, " %s", oper_ident_to_upper);
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2092 delete[] oper_ident_to_upper;
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2093 }
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2094 void map(char *name) {
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2095 const char* name_to_upper = _AD.machOperEnum(name);
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2096 fprintf(_cpp, " %s", name_to_upper);
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2097 delete[] name_to_upper;
705ef39fcaa9 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 6850
diff changeset
2098 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2099
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 bool do_instructions() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 void map(InstructForm &inst){ assert( false, "ShouldNotCallThis()"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
2102 };
a61af66fc99e Initial load
duke
parents:
diff changeset
2103
a61af66fc99e Initial load
duke
parents:
diff changeset
2104
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 void ArchDesc::buildMachOperEnum(FILE *fp_hpp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2106 // Construct the table for MachOpcodes
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 OutputMachOperands output_mach_operands(fp_hpp, fp_hpp, _globalNames, *this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 build_map(output_mach_operands);
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2110
a61af66fc99e Initial load
duke
parents:
diff changeset
2111
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 //---------------------------buildMachEnum----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 // Build enumeration for all MachOpers and all MachNodes
a61af66fc99e Initial load
duke
parents:
diff changeset
2114
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 // Information needed to generate the ReduceOp mapping for the DFA
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 class OutputMachOpcodes : public OutputMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 int begin_inst_chain_rule;
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 int end_inst_chain_rule;
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 int begin_rematerialize;
a61af66fc99e Initial load
duke
parents:
diff changeset
2120 int end_rematerialize;
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 int end_instructions;
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
2123 OutputMachOpcodes(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
2124 : OutputMap(hpp, cpp, globals, AD, "MachOpcodes"),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 begin_inst_chain_rule(-1), end_inst_chain_rule(-1), end_instructions(-1)
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 {};
a61af66fc99e Initial load
duke
parents:
diff changeset
2127
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 void declaration() { }
a61af66fc99e Initial load
duke
parents:
diff changeset
2129 void definition() { fprintf(_cpp, "enum MachOpcodes {\n"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
2130 void closing() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 if( begin_inst_chain_rule != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 fprintf(_cpp, " _BEGIN_INST_CHAIN_RULE = %d,\n", begin_inst_chain_rule);
a61af66fc99e Initial load
duke
parents:
diff changeset
2133 if( end_inst_chain_rule != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 fprintf(_cpp, " _END_INST_CHAIN_RULE = %d,\n", end_inst_chain_rule);
a61af66fc99e Initial load
duke
parents:
diff changeset
2135 if( begin_rematerialize != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 fprintf(_cpp, " _BEGIN_REMATERIALIZE = %d,\n", begin_rematerialize);
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 if( end_rematerialize != -1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
2138 fprintf(_cpp, " _END_REMATERIALIZE = %d,\n", end_rematerialize);
a61af66fc99e Initial load
duke
parents:
diff changeset
2139 // always execute since do_instructions() is true, and avoids trailing comma
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 fprintf(_cpp, " _last_Mach_Node = %d \n", end_instructions);
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 OutputMap::closing();
a61af66fc99e Initial load
duke
parents:
diff changeset
2142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2143 void map(OpClassForm &opc) { fprintf(_cpp, " %s_rule", opc._ident ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
2144 void map(OperandForm &oper) { fprintf(_cpp, " %s_rule", oper._ident ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 void map(char *name) { if (name) fprintf(_cpp, " %s_rule", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 else fprintf(_cpp, " 0"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
2147 void map(InstructForm &inst) {fprintf(_cpp, " %s_rule", inst._ident ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
2148
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 void record_position(OutputMap::position place, int idx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2150 switch(place) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 case OutputMap::BEGIN_INST_CHAIN_RULES :
a61af66fc99e Initial load
duke
parents:
diff changeset
2152 begin_inst_chain_rule = idx;
a61af66fc99e Initial load
duke
parents:
diff changeset
2153 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2154 case OutputMap::END_INST_CHAIN_RULES :
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 end_inst_chain_rule = idx;
a61af66fc99e Initial load
duke
parents:
diff changeset
2156 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2157 case OutputMap::BEGIN_REMATERIALIZE :
a61af66fc99e Initial load
duke
parents:
diff changeset
2158 begin_rematerialize = idx;
a61af66fc99e Initial load
duke
parents:
diff changeset
2159 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2160 case OutputMap::END_REMATERIALIZE :
a61af66fc99e Initial load
duke
parents:
diff changeset
2161 end_rematerialize = idx;
a61af66fc99e Initial load
duke
parents:
diff changeset
2162 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 case OutputMap::END_INSTRUCTIONS :
a61af66fc99e Initial load
duke
parents:
diff changeset
2164 end_instructions = idx;
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2166 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
2167 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2170 };
a61af66fc99e Initial load
duke
parents:
diff changeset
2171
a61af66fc99e Initial load
duke
parents:
diff changeset
2172
a61af66fc99e Initial load
duke
parents:
diff changeset
2173 void ArchDesc::buildMachOpcodesEnum(FILE *fp_hpp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2174 // Construct the table for MachOpcodes
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 OutputMachOpcodes output_mach_opcodes(fp_hpp, fp_hpp, _globalNames, *this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 build_map(output_mach_opcodes);
a61af66fc99e Initial load
duke
parents:
diff changeset
2177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2178
a61af66fc99e Initial load
duke
parents:
diff changeset
2179
a61af66fc99e Initial load
duke
parents:
diff changeset
2180 // Generate an enumeration of the pipeline states, and both
a61af66fc99e Initial load
duke
parents:
diff changeset
2181 // the functional units (resources) and the masks for
a61af66fc99e Initial load
duke
parents:
diff changeset
2182 // specifying resources
a61af66fc99e Initial load
duke
parents:
diff changeset
2183 void ArchDesc::build_pipeline_enums(FILE *fp_hpp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2184 int stagelen = (int)strlen("undefined");
a61af66fc99e Initial load
duke
parents:
diff changeset
2185 int stagenum = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2186
a61af66fc99e Initial load
duke
parents:
diff changeset
2187 if (_pipeline) { // Find max enum string length
a61af66fc99e Initial load
duke
parents:
diff changeset
2188 const char *stage;
a61af66fc99e Initial load
duke
parents:
diff changeset
2189 for ( _pipeline->_stages.reset(); (stage = _pipeline->_stages.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2190 int len = (int)strlen(stage);
a61af66fc99e Initial load
duke
parents:
diff changeset
2191 if (stagelen < len) stagelen = len;
a61af66fc99e Initial load
duke
parents:
diff changeset
2192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2194
a61af66fc99e Initial load
duke
parents:
diff changeset
2195 // Generate a list of stages
a61af66fc99e Initial load
duke
parents:
diff changeset
2196 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2197 fprintf(fp_hpp, "// Pipeline Stages\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2198 fprintf(fp_hpp, "enum machPipelineStages {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2199 fprintf(fp_hpp, " stage_%-*s = 0,\n", stagelen, "undefined");
a61af66fc99e Initial load
duke
parents:
diff changeset
2200
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 if( _pipeline ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2202 const char *stage;
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 for ( _pipeline->_stages.reset(); (stage = _pipeline->_stages.iter()) != NULL; )
a61af66fc99e Initial load
duke
parents:
diff changeset
2204 fprintf(fp_hpp, " stage_%-*s = %d,\n", stagelen, stage, ++stagenum);
a61af66fc99e Initial load
duke
parents:
diff changeset
2205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2206
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 fprintf(fp_hpp, " stage_%-*s = %d\n", stagelen, "count", stagenum);
a61af66fc99e Initial load
duke
parents:
diff changeset
2208 fprintf(fp_hpp, "};\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2209
a61af66fc99e Initial load
duke
parents:
diff changeset
2210 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 fprintf(fp_hpp, "// Pipeline Resources\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 fprintf(fp_hpp, "enum machPipelineResources {\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 int rescount = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2214
a61af66fc99e Initial load
duke
parents:
diff changeset
2215 if( _pipeline ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2216 const char *resource;
a61af66fc99e Initial load
duke
parents:
diff changeset
2217 int reslen = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2218
a61af66fc99e Initial load
duke
parents:
diff changeset
2219 // Generate a list of resources, and masks
a61af66fc99e Initial load
duke
parents:
diff changeset
2220 for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 int len = (int)strlen(resource);
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 if (reslen < len)
a61af66fc99e Initial load
duke
parents:
diff changeset
2223 reslen = len;
a61af66fc99e Initial load
duke
parents:
diff changeset
2224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2225
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 const ResourceForm *resform = _pipeline->_resdict[resource]->is_resource();
a61af66fc99e Initial load
duke
parents:
diff changeset
2228 int mask = resform->mask();
a61af66fc99e Initial load
duke
parents:
diff changeset
2229 if ((mask & (mask-1)) == 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
2230 fprintf(fp_hpp, " resource_%-*s = %d,\n", reslen, resource, rescount++);
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2232 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2233 for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2234 const ResourceForm *resform = _pipeline->_resdict[resource]->is_resource();
a61af66fc99e Initial load
duke
parents:
diff changeset
2235 fprintf(fp_hpp, " res_mask_%-*s = 0x%08x,\n", reslen, resource, resform->mask());
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2237 fprintf(fp_hpp, "\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 fprintf(fp_hpp, " resource_count = %d\n", rescount);
a61af66fc99e Initial load
duke
parents:
diff changeset
2240 fprintf(fp_hpp, "};\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
2241 }