annotate src/share/vm/adlc/forms.hpp @ 7212:291ffc492eb6

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Fri, 14 Dec 2012 14:35:13 +0100
parents d336b3173277
children b42fe1a8e180
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 1972
diff changeset
2 * Copyright (c) 1997, 2012, 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: 624
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 624
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: 624
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
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_ADLC_FORMS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_ADLC_FORMS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // FORMS.HPP - ADL Parser Generic and Utility Forms Classes
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 #define TRUE 1
a61af66fc99e Initial load
duke
parents:
diff changeset
31 #define FALSE 0
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // DEFINITIONS OF LEGAL ATTRIBUTE TYPES
a61af66fc99e Initial load
duke
parents:
diff changeset
34 #define INS_ATTR 0
a61af66fc99e Initial load
duke
parents:
diff changeset
35 #define OP_ATTR 1
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // DEFINITIONS OF LEGAL CONSTRAINT TYPES
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // Class List
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class Form;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class InstructForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 class MachNodeForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class OperandForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class OpClassForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class AttributeForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class RegisterForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 class PipelineForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 class SourceForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class EncodeForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 class Component;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 class Constraint;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 class Predicate;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 class MatchRule;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 class Attribute;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 class Effect;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 class ExpandRule;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 class RewriteRule;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 class ConstructRule;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 class FormatRule;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 class Peephole;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 class EncClass;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 class Interface;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 class RegInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 class ConstInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 class MemInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 class CondInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 class Opcode;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 class InsEncode;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 class RegDef;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 class RegClass;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 class AllocClass;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 class ResourceForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 class PipeClassForm;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 class PeepMatch;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 class PeepConstraint;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 class PeepReplace;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 class MatchList;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 class ArchDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 //------------------------------FormDict---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Dictionary containing Forms, and objects derived from forms
a61af66fc99e Initial load
duke
parents:
diff changeset
83 class FormDict {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
85 Dict _form; // map names, char*, to their Form* or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Disable public use of constructor, copy-ctor, operator =, operator ==
a61af66fc99e Initial load
duke
parents:
diff changeset
88 FormDict( );
a61af66fc99e Initial load
duke
parents:
diff changeset
89 FormDict &operator =( const FormDict & );
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // == compares two dictionaries; they must have the same keys (their keys
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // must match using CmpKey) and they must have the same values (pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // comparison). If so 1 is returned, if not 0 is returned.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 bool operator ==(const FormDict &d) const; // Compare dictionaries for equal
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // cmp is a key comparision routine. hash is a routine to hash a key.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // FormDict( CmpKey cmp, Hash hash );
a61af66fc99e Initial load
duke
parents:
diff changeset
98 FormDict( CmpKey cmp, Hash hash, Arena *arena );
a61af66fc99e Initial load
duke
parents:
diff changeset
99 FormDict( const FormDict & fd ); // Deep-copy guts
a61af66fc99e Initial load
duke
parents:
diff changeset
100 ~FormDict();
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Return # of key-value pairs in dict
a61af66fc99e Initial load
duke
parents:
diff changeset
103 int Size(void) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Insert inserts the given key-value pair into the dictionary. The prior
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // value of the key is returned; NULL if the key was not previously defined.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 const Form *Insert(const char *name, Form *form); // A new key-value
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Find finds the value of a given key; or NULL if not found.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // The dictionary is NOT changed.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 const Form *operator [](const char *name) const; // Do a lookup
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 void dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 };
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // ***** Master Class for ADL Parser Forms *****
a61af66fc99e Initial load
duke
parents:
diff changeset
117 //------------------------------Form-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
118 class Form {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
120 static Arena *arena; // arena used by forms
a61af66fc99e Initial load
duke
parents:
diff changeset
121 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
122 static Arena *generate_arena(); // allocate arena used by forms
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
125 int _ftype; // Indicator for derived class type
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Public Data
a61af66fc99e Initial load
duke
parents:
diff changeset
129 Form *_next; // Next pointer for form lists
603
dbbe28fc66b5 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 415
diff changeset
130 int _linenum; // Line number for debugging
0
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // Dynamic type check for common forms.
a61af66fc99e Initial load
duke
parents:
diff changeset
133 virtual OpClassForm *is_opclass() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 virtual OperandForm *is_operand() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 virtual InstructForm *is_instruction() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 virtual MachNodeForm *is_machnode() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 virtual AttributeForm *is_attribute() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 virtual Effect *is_effect() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 virtual ResourceForm *is_resource() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 virtual PipeClassForm *is_pipeclass() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // Check if this form is an operand usable for cisc-spilling
a61af66fc99e Initial load
duke
parents:
diff changeset
143 virtual bool is_cisc_reg(FormDict &globals) const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 virtual bool is_cisc_mem(FormDict &globals) const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // Public Methods
a61af66fc99e Initial load
duke
parents:
diff changeset
147 Form(int formType=0, int line=0)
a61af66fc99e Initial load
duke
parents:
diff changeset
148 : _next(NULL), _linenum(line), _ftype(formType) { };
a61af66fc99e Initial load
duke
parents:
diff changeset
149 ~Form() {};
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 virtual bool ideal_only() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 assert(0,"Check of ideal status on non-instruction/operand form.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return FALSE;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Check constraints after parsing
a61af66fc99e Initial load
duke
parents:
diff changeset
157 virtual bool verify() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 virtual void dump() { output(stderr); } // Debug printer
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Write info to output files
a61af66fc99e Initial load
duke
parents:
diff changeset
161 virtual void output(FILE *fp) { fprintf(fp,"Form Output"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // ADLC types, match the last character on ideal operands and instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
165 enum DataType {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 none = 0, // Not a simple type
a61af66fc99e Initial load
duke
parents:
diff changeset
167 idealI = 1, // Integer type
a61af66fc99e Initial load
duke
parents:
diff changeset
168 idealP = 2, // Pointer types, oop(s)
a61af66fc99e Initial load
duke
parents:
diff changeset
169 idealL = 3, // Long type
a61af66fc99e Initial load
duke
parents:
diff changeset
170 idealF = 4, // Float type
a61af66fc99e Initial load
duke
parents:
diff changeset
171 idealD = 5, // Double type
a61af66fc99e Initial load
duke
parents:
diff changeset
172 idealB = 6, // Byte type
a61af66fc99e Initial load
duke
parents:
diff changeset
173 idealC = 7, // Char type
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
174 idealS = 8, // String type
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 1972
diff changeset
175 idealN = 9, // Narrow oop types
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6179
diff changeset
176 idealNKlass = 10, // Narrow klass types
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6179
diff changeset
177 idealV = 11 // Vector type
0
a61af66fc99e Initial load
duke
parents:
diff changeset
178 };
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // Convert ideal name to a DataType, return DataType::none if not a 'ConX'
a61af66fc99e Initial load
duke
parents:
diff changeset
180 Form::DataType ideal_to_const_type(const char *ideal_type_name) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Convert ideal name to a DataType, return DataType::none if not a 'sRegX
a61af66fc99e Initial load
duke
parents:
diff changeset
182 Form::DataType ideal_to_sReg_type(const char *name) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // Convert ideal name to a DataType, return DataType::none if not a 'RegX
a61af66fc99e Initial load
duke
parents:
diff changeset
184 Form::DataType ideal_to_Reg_type(const char *name) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // Convert ideal name to a DataType, return DataType::none if not a 'LoadX
a61af66fc99e Initial load
duke
parents:
diff changeset
187 Form::DataType is_load_from_memory(const char *opType) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // Convert ideal name to a DataType, return DataType::none if not a 'StoreX
a61af66fc99e Initial load
duke
parents:
diff changeset
189 Form::DataType is_store_to_memory(const char *opType) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // ADLC call types, matched with ideal world
a61af66fc99e Initial load
duke
parents:
diff changeset
192 enum CallType {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 invalid_type = 0, // invalid call type
a61af66fc99e Initial load
duke
parents:
diff changeset
194 JAVA_STATIC = 1, // monomorphic entry
a61af66fc99e Initial load
duke
parents:
diff changeset
195 JAVA_DYNAMIC = 2, // possibly megamorphic, inline cache call
a61af66fc99e Initial load
duke
parents:
diff changeset
196 JAVA_COMPILED = 3, // callee will be compiled java
a61af66fc99e Initial load
duke
parents:
diff changeset
197 JAVA_INTERP = 4, // callee will be executed by interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
198 JAVA_NATIVE = 5, // native entrypoint
a61af66fc99e Initial load
duke
parents:
diff changeset
199 JAVA_RUNTIME = 6, // runtime entrypoint
a61af66fc99e Initial load
duke
parents:
diff changeset
200 JAVA_LEAF = 7 // calling leaf
a61af66fc99e Initial load
duke
parents:
diff changeset
201 };
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // Interface types for operands and operand classes
a61af66fc99e Initial load
duke
parents:
diff changeset
204 enum InterfaceType {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 no_interface = 0, // unknown or inconsistent interface type
a61af66fc99e Initial load
duke
parents:
diff changeset
206 constant_interface = 1, // interface to constants
a61af66fc99e Initial load
duke
parents:
diff changeset
207 register_interface = 2, // interface to registers
a61af66fc99e Initial load
duke
parents:
diff changeset
208 memory_interface = 3, // interface to memory
a61af66fc99e Initial load
duke
parents:
diff changeset
209 conditional_interface = 4 // interface for condition codes
a61af66fc99e Initial load
duke
parents:
diff changeset
210 };
a61af66fc99e Initial load
duke
parents:
diff changeset
211 virtual Form::InterfaceType interface_type(FormDict &globals) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 enum CiscSpillInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 Not_cisc_spillable = AdlcVMDeps::Not_cisc_spillable,
a61af66fc99e Initial load
duke
parents:
diff changeset
215 Maybe_cisc_spillable = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
216 Is_cisc_spillable = 1
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
218 };
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // LEGAL FORM TYPES
a61af66fc99e Initial load
duke
parents:
diff changeset
221 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 INS,
a61af66fc99e Initial load
duke
parents:
diff changeset
223 OPER,
a61af66fc99e Initial load
duke
parents:
diff changeset
224 OPCLASS,
a61af66fc99e Initial load
duke
parents:
diff changeset
225 SRC,
a61af66fc99e Initial load
duke
parents:
diff changeset
226 ADEF,
a61af66fc99e Initial load
duke
parents:
diff changeset
227 REG,
a61af66fc99e Initial load
duke
parents:
diff changeset
228 PIPE,
a61af66fc99e Initial load
duke
parents:
diff changeset
229 CNST,
a61af66fc99e Initial load
duke
parents:
diff changeset
230 PRED,
a61af66fc99e Initial load
duke
parents:
diff changeset
231 ATTR,
a61af66fc99e Initial load
duke
parents:
diff changeset
232 MAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
233 ENC,
a61af66fc99e Initial load
duke
parents:
diff changeset
234 FOR,
a61af66fc99e Initial load
duke
parents:
diff changeset
235 EXP,
a61af66fc99e Initial load
duke
parents:
diff changeset
236 REW,
a61af66fc99e Initial load
duke
parents:
diff changeset
237 EFF,
a61af66fc99e Initial load
duke
parents:
diff changeset
238 RDEF,
a61af66fc99e Initial load
duke
parents:
diff changeset
239 RCL,
a61af66fc99e Initial load
duke
parents:
diff changeset
240 ACL,
a61af66fc99e Initial load
duke
parents:
diff changeset
241 RES,
a61af66fc99e Initial load
duke
parents:
diff changeset
242 PCL,
a61af66fc99e Initial load
duke
parents:
diff changeset
243 PDEF,
a61af66fc99e Initial load
duke
parents:
diff changeset
244 REGL,
a61af66fc99e Initial load
duke
parents:
diff changeset
245 RESL,
a61af66fc99e Initial load
duke
parents:
diff changeset
246 STAL,
a61af66fc99e Initial load
duke
parents:
diff changeset
247 COMP,
a61af66fc99e Initial load
duke
parents:
diff changeset
248 PEEP,
a61af66fc99e Initial load
duke
parents:
diff changeset
249 RESO
a61af66fc99e Initial load
duke
parents:
diff changeset
250 };
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 };
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 //------------------------------FormList---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
255 class FormList {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
257 Form *_root;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 Form *_tail;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 Form *_cur;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 int _justReset; // Set immediately after reset
a61af66fc99e Initial load
duke
parents:
diff changeset
261 Form *_cur2; // Nested iterator
a61af66fc99e Initial load
duke
parents:
diff changeset
262 int _justReset2;
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
265 void addForm(Form * entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (_tail==NULL) { _root = _tail = _cur = entry;}
a61af66fc99e Initial load
duke
parents:
diff changeset
267 else { _tail->_next = entry; _tail = entry;}
a61af66fc99e Initial load
duke
parents:
diff changeset
268 };
a61af66fc99e Initial load
duke
parents:
diff changeset
269 Form * current() { return _cur; };
a61af66fc99e Initial load
duke
parents:
diff changeset
270 Form * iter() { if (_justReset) _justReset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 else if (_cur) _cur = _cur->_next;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 return _cur;};
a61af66fc99e Initial load
duke
parents:
diff changeset
273 void reset() { if (_root) {_cur = _root; _justReset = 1;} };
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // Second iterator, state is internal
a61af66fc99e Initial load
duke
parents:
diff changeset
276 Form * current2(){ return _cur2; };
a61af66fc99e Initial load
duke
parents:
diff changeset
277 Form * iter2() { if (_justReset2) _justReset2 = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
278 else if (_cur2) _cur2 = _cur2->_next;
a61af66fc99e Initial load
duke
parents:
diff changeset
279 return _cur2;};
a61af66fc99e Initial load
duke
parents:
diff changeset
280 void reset2() { if (_root) {_cur2 = _root; _justReset2 = 1;} };
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 int count() {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 int count = 0; reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
284 for( Form *cur; (cur = iter()) != NULL; ) { ++count; };
a61af66fc99e Initial load
duke
parents:
diff changeset
285 return count;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 void dump() {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
290 Form *cur;
a61af66fc99e Initial load
duke
parents:
diff changeset
291 for(; (cur = iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 cur->dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
293 };
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 bool verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 bool verified = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
300 Form *cur;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 for(; (cur = iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 if ( ! cur->verify() ) verified = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 };
a61af66fc99e Initial load
duke
parents:
diff changeset
304
a61af66fc99e Initial load
duke
parents:
diff changeset
305 return verified;
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 void output(FILE* fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
310 Form *cur;
a61af66fc99e Initial load
duke
parents:
diff changeset
311 for( ; (cur = iter()) != NULL; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 cur->output(fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
313 };
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 FormList() { _justReset = 1; _justReset2 = 1; _root = NULL; _tail = NULL; _cur = NULL; _cur2 = NULL;};
a61af66fc99e Initial load
duke
parents:
diff changeset
317 ~FormList();
a61af66fc99e Initial load
duke
parents:
diff changeset
318 };
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 //------------------------------NameList---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // Extendable list of pointers, <char *>
a61af66fc99e Initial load
duke
parents:
diff changeset
322 class NameList {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 friend class PreserveIter;
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
326 int _cur; // Insert next entry here; count of entries
a61af66fc99e Initial load
duke
parents:
diff changeset
327 int _max; // Number of spaces allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
328 const char **_names; // Array of names
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
331 int _iter; // position during iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
332 bool _justReset; // Set immediately after reset
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
336 static const char *_signal; // reserved user-defined string
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 196
diff changeset
337 static const char *_signal2; // reserved user-defined string
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 196
diff changeset
338 static const char *_signal3; // reserved user-defined string
0
a61af66fc99e Initial load
duke
parents:
diff changeset
339 enum { Not_in_list = -1 };
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 void addName(const char *name);
a61af66fc99e Initial load
duke
parents:
diff changeset
342 void add_signal();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 void clear(); // Remove all entries
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 int count() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 void reset(); // Reset iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
348 const char *iter(); // after reset(), first element : else next
a61af66fc99e Initial load
duke
parents:
diff changeset
349 const char *current(); // return current element in iteration.
624
337400e7a5dd 6797305: Add LoadUB and LoadUI opcode class
twisti
parents: 603
diff changeset
350 const char *peek(int skip = 1); // returns element + skip in iteration if there is one
0
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 bool current_is_signal(); // Return 'true' if current entry is signal
a61af66fc99e Initial load
duke
parents:
diff changeset
353 bool is_signal(const char *entry); // Return true if entry is a signal
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 bool search(const char *); // Search for a name in the list
a61af66fc99e Initial load
duke
parents:
diff changeset
356 int index(const char *); // Return index of name in list
a61af66fc99e Initial load
duke
parents:
diff changeset
357 const char *name (intptr_t index);// Return name at index in list
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 void dump(); // output to stderr
a61af66fc99e Initial load
duke
parents:
diff changeset
360 void output(FILE *fp); // Output list of names to 'fp'
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 NameList();
a61af66fc99e Initial load
duke
parents:
diff changeset
363 ~NameList();
a61af66fc99e Initial load
duke
parents:
diff changeset
364 };
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // Convenience class to preserve iteration state since iterators are
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // internal instead of being external.
a61af66fc99e Initial load
duke
parents:
diff changeset
369 class PreserveIter {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
371 NameList* _list;
a61af66fc99e Initial load
duke
parents:
diff changeset
372 int _iter;
a61af66fc99e Initial load
duke
parents:
diff changeset
373 bool _justReset;
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
376 PreserveIter(NameList* nl) {
a61af66fc99e Initial load
duke
parents:
diff changeset
377 _list = nl;
a61af66fc99e Initial load
duke
parents:
diff changeset
378 _iter = _list->_iter;
a61af66fc99e Initial load
duke
parents:
diff changeset
379 _justReset = _list->_justReset;
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381 ~PreserveIter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
382 _list->_iter = _iter;
a61af66fc99e Initial load
duke
parents:
diff changeset
383 _list->_justReset = _justReset;
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 };
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 //------------------------------NameAndList------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // Storage for a name and an associated list of names
a61af66fc99e Initial load
duke
parents:
diff changeset
391 class NameAndList {
a61af66fc99e Initial load
duke
parents:
diff changeset
392 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
393 const char *_name;
a61af66fc99e Initial load
duke
parents:
diff changeset
394 NameList _list;
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
397 NameAndList(char *name);
a61af66fc99e Initial load
duke
parents:
diff changeset
398 ~NameAndList();
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // Add to entries in list
a61af66fc99e Initial load
duke
parents:
diff changeset
401 void add_entry(const char *entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Access the name and its associated list.
a61af66fc99e Initial load
duke
parents:
diff changeset
404 const char *name() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
405 void reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
406 const char *iter();
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 int count() { return _list.count(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410 // Return the "index" entry in the list, zero-based
a61af66fc99e Initial load
duke
parents:
diff changeset
411 const char *operator[](int index);
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413
a61af66fc99e Initial load
duke
parents:
diff changeset
414 void dump(); // output to stderr
a61af66fc99e Initial load
duke
parents:
diff changeset
415 void output(FILE *fp); // Output list of names to 'fp'
a61af66fc99e Initial load
duke
parents:
diff changeset
416 };
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 //------------------------------ComponentList---------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
419 // Component lists always have match rule operands first, followed by parameter
a61af66fc99e Initial load
duke
parents:
diff changeset
420 // operands which do not appear in the match list (in order of declaration).
a61af66fc99e Initial load
duke
parents:
diff changeset
421 class ComponentList : private NameList {
a61af66fc99e Initial load
duke
parents:
diff changeset
422 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
423 int _matchcnt; // Count of match rule operands
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // This is a batch program. (And I have a destructor bug!)
a61af66fc99e Initial load
duke
parents:
diff changeset
428 void operator delete( void *ptr ) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 void insert(Component *component, bool mflag);
a61af66fc99e Initial load
duke
parents:
diff changeset
431 void insert(const char *name, const char *opType, int usedef, bool mflag);
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 int count();
a61af66fc99e Initial load
duke
parents:
diff changeset
434 int match_count() { return _matchcnt; } // Get count of match rule opers
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 Component *iter(); // after reset(), first element : else next
a61af66fc99e Initial load
duke
parents:
diff changeset
437 Component *match_iter(); // after reset(), first element : else next
a61af66fc99e Initial load
duke
parents:
diff changeset
438 Component *post_match_iter(); // after reset(), first element : else next
a61af66fc99e Initial load
duke
parents:
diff changeset
439 void reset(); // Reset iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
440 Component *current(); // return current element in iteration.
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // Return element at "position", else NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
443 Component *operator[](int position);
a61af66fc99e Initial load
duke
parents:
diff changeset
444 Component *at(int position) { return (*this)[position]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 // Return first component having this name.
a61af66fc99e Initial load
duke
parents:
diff changeset
447 const Component *search(const char *name);
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // Return number of USEs + number of DEFs
a61af66fc99e Initial load
duke
parents:
diff changeset
450 int num_operands();
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // Return zero-based position in list; -1 if not in list.
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
452 int operand_position(const char *name, int usedef, Form *fm);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
453 // Find position for this name, regardless of use/def information
a61af66fc99e Initial load
duke
parents:
diff changeset
454 int operand_position(const char *name);
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // Find position for this name when looked up for output via "format"
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 6848
diff changeset
456 int operand_position_format(const char *name, Form *fm);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
457 // Find position for the Label when looked up for output via "format"
a61af66fc99e Initial load
duke
parents:
diff changeset
458 int label_position();
a61af66fc99e Initial load
duke
parents:
diff changeset
459 // Find position for the Method when looked up for output via "format"
a61af66fc99e Initial load
duke
parents:
diff changeset
460 int method_position();
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 void dump(); // output to stderr
a61af66fc99e Initial load
duke
parents:
diff changeset
463 void output(FILE *fp); // Output list of names to 'fp'
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 ComponentList();
a61af66fc99e Initial load
duke
parents:
diff changeset
466 ~ComponentList();
a61af66fc99e Initial load
duke
parents:
diff changeset
467 };
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 //------------------------------SourceForm-------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
470 class SourceForm : public Form {
a61af66fc99e Initial load
duke
parents:
diff changeset
471 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // Public Data
a61af66fc99e Initial load
duke
parents:
diff changeset
475 char *_code; // Buffer for storing code text
a61af66fc99e Initial load
duke
parents:
diff changeset
476
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // Public Methods
a61af66fc99e Initial load
duke
parents:
diff changeset
478 SourceForm(char* code);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 ~SourceForm();
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 virtual const char* classname() { return "SourceForm"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 void dump(); // Debug printer
a61af66fc99e Initial load
duke
parents:
diff changeset
484 void output(FILE *fp); // Write output files
a61af66fc99e Initial load
duke
parents:
diff changeset
485 };
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 class HeaderForm : public SourceForm {
a61af66fc99e Initial load
duke
parents:
diff changeset
488 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
489 HeaderForm(char* code) : SourceForm(code) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
490
a61af66fc99e Initial load
duke
parents:
diff changeset
491 virtual const char* classname() { return "HeaderForm"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
492 };
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494 class PreHeaderForm : public SourceForm {
a61af66fc99e Initial load
duke
parents:
diff changeset
495 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
496 PreHeaderForm(char* code) : SourceForm(code) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 virtual const char* classname() { return "PreHeaderForm"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 };
a61af66fc99e Initial load
duke
parents:
diff changeset
500
a61af66fc99e Initial load
duke
parents:
diff changeset
501
a61af66fc99e Initial load
duke
parents:
diff changeset
502
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 //------------------------------Expr------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
505 #define STRING_BUFFER_LENGTH 2048
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // class Expr represents integer expressions containing constants and addition
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // Value must be in range zero through maximum positive integer. 32bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // Expected use: instruction and operand costs
a61af66fc99e Initial load
duke
parents:
diff changeset
509 class Expr {
a61af66fc99e Initial load
duke
parents:
diff changeset
510 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
511 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
512 Zero = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
513 Max = 0x7fffffff
a61af66fc99e Initial load
duke
parents:
diff changeset
514 };
a61af66fc99e Initial load
duke
parents:
diff changeset
515 const char *_external_name; // if !NULL, then print this instead of _expr
a61af66fc99e Initial load
duke
parents:
diff changeset
516 const char *_expr;
a61af66fc99e Initial load
duke
parents:
diff changeset
517 int _min_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
518 int _max_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
519
a61af66fc99e Initial load
duke
parents:
diff changeset
520 Expr();
a61af66fc99e Initial load
duke
parents:
diff changeset
521 Expr(const char *cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
522 Expr(const char *name, const char *expression, int min_value, int max_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
523 Expr *clone() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
524
a61af66fc99e Initial load
duke
parents:
diff changeset
525 bool is_unknown() const { return (this == Expr::get_unknown()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
526 bool is_zero() const { return (_min_value == Expr::Zero && _max_value == Expr::Zero); }
a61af66fc99e Initial load
duke
parents:
diff changeset
527 bool less_than_or_equal(const Expr *c) const { return (_max_value <= c->_min_value); }
a61af66fc99e Initial load
duke
parents:
diff changeset
528
a61af66fc99e Initial load
duke
parents:
diff changeset
529 void add(const Expr *c);
a61af66fc99e Initial load
duke
parents:
diff changeset
530 void add(const char *c);
a61af66fc99e Initial load
duke
parents:
diff changeset
531 void add(const char *c, ArchDesc &AD); // check if 'c' is defined in <arch>.ad
a61af66fc99e Initial load
duke
parents:
diff changeset
532 void set_external_name(const char *name) { _external_name = name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
533
a61af66fc99e Initial load
duke
parents:
diff changeset
534 const char *as_string() const { return (_external_name != NULL ? _external_name : _expr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
535 void print() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
536 void print_define(FILE *fp) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
537 void print_assert(FILE *fp) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
538
a61af66fc99e Initial load
duke
parents:
diff changeset
539 static Expr *get_unknown(); // Returns pointer to shared unknown cost instance
a61af66fc99e Initial load
duke
parents:
diff changeset
540
a61af66fc99e Initial load
duke
parents:
diff changeset
541 static char *buffer() { return &external_buffer[0]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
542 static bool init_buffers(); // Fill buffers with 0
a61af66fc99e Initial load
duke
parents:
diff changeset
543 static bool check_buffers(); // if buffer use may have overflowed, assert
a61af66fc99e Initial load
duke
parents:
diff changeset
544
a61af66fc99e Initial load
duke
parents:
diff changeset
545 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
546 static Expr *_unknown_expr;
a61af66fc99e Initial load
duke
parents:
diff changeset
547 static char string_buffer[STRING_BUFFER_LENGTH];
a61af66fc99e Initial load
duke
parents:
diff changeset
548 static char external_buffer[STRING_BUFFER_LENGTH];
a61af66fc99e Initial load
duke
parents:
diff changeset
549 static bool _init_buffers;
a61af66fc99e Initial load
duke
parents:
diff changeset
550 const char *compute_expr(const Expr *c1, const Expr *c2); // cost as string after adding 'c1' and 'c2'
a61af66fc99e Initial load
duke
parents:
diff changeset
551 int compute_min (const Expr *c1, const Expr *c2); // minimum after adding 'c1' and 'c2'
a61af66fc99e Initial load
duke
parents:
diff changeset
552 int compute_max (const Expr *c1, const Expr *c2); // maximum after adding 'c1' and 'c2'
a61af66fc99e Initial load
duke
parents:
diff changeset
553 const char *compute_external(const Expr *c1, const Expr *c2); // external name after adding 'c1' and 'c2'
a61af66fc99e Initial load
duke
parents:
diff changeset
554 };
a61af66fc99e Initial load
duke
parents:
diff changeset
555
a61af66fc99e Initial load
duke
parents:
diff changeset
556 //------------------------------ExprDict---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
557 // Dictionary containing Exprs
a61af66fc99e Initial load
duke
parents:
diff changeset
558 class ExprDict {
a61af66fc99e Initial load
duke
parents:
diff changeset
559 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
560 Dict _expr; // map names, char*, to their Expr* or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
561 NameList _defines; // record the order of definitions entered with define call
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // Disable public use of constructor, copy-ctor, operator =, operator ==
a61af66fc99e Initial load
duke
parents:
diff changeset
564 ExprDict( );
a61af66fc99e Initial load
duke
parents:
diff changeset
565 ExprDict( const ExprDict & ); // Deep-copy guts
a61af66fc99e Initial load
duke
parents:
diff changeset
566 ExprDict &operator =( const ExprDict & );
a61af66fc99e Initial load
duke
parents:
diff changeset
567 // == compares two dictionaries; they must have the same keys (their keys
a61af66fc99e Initial load
duke
parents:
diff changeset
568 // must match using CmpKey) and they must have the same values (pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
569 // comparison). If so 1 is returned, if not 0 is returned.
a61af66fc99e Initial load
duke
parents:
diff changeset
570 bool operator ==(const ExprDict &d) const; // Compare dictionaries for equal
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
573 // cmp is a key comparision routine. hash is a routine to hash a key.
a61af66fc99e Initial load
duke
parents:
diff changeset
574 ExprDict( CmpKey cmp, Hash hash, Arena *arena );
a61af66fc99e Initial load
duke
parents:
diff changeset
575 ~ExprDict();
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 // Return # of key-value pairs in dict
a61af66fc99e Initial load
duke
parents:
diff changeset
578 int Size(void) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
579
a61af66fc99e Initial load
duke
parents:
diff changeset
580 // define inserts the given key-value pair into the dictionary,
a61af66fc99e Initial load
duke
parents:
diff changeset
581 // and records the name in order for later output, ...
a61af66fc99e Initial load
duke
parents:
diff changeset
582 const Expr *define(const char *name, Expr *expr);
a61af66fc99e Initial load
duke
parents:
diff changeset
583
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // Insert inserts the given key-value pair into the dictionary. The prior
a61af66fc99e Initial load
duke
parents:
diff changeset
585 // value of the key is returned; NULL if the key was not previously defined.
a61af66fc99e Initial load
duke
parents:
diff changeset
586 const Expr *Insert(const char *name, Expr *expr); // A new key-value
a61af66fc99e Initial load
duke
parents:
diff changeset
587
a61af66fc99e Initial load
duke
parents:
diff changeset
588 // Find finds the value of a given key; or NULL if not found.
a61af66fc99e Initial load
duke
parents:
diff changeset
589 // The dictionary is NOT changed.
a61af66fc99e Initial load
duke
parents:
diff changeset
590 const Expr *operator [](const char *name) const; // Do a lookup
a61af66fc99e Initial load
duke
parents:
diff changeset
591
a61af66fc99e Initial load
duke
parents:
diff changeset
592 void print_defines(FILE *fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
593 void print_asserts(FILE *fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
594 void dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
595 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
596
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
597 #endif // SHARE_VM_ADLC_FORMS_HPP