annotate src/share/vm/adlc/forms.hpp @ 5663:1dcea64e9f00

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