/* * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Class List class Form; class InstructForm; class MachNodeForm; class OperandForm; class OpClassForm; class AttributeForm; class RegisterForm; class PipelineForm; class SourceForm; class EncodeForm; class Component; class Constraint; class Predicate; class MatchRule; class Attribute; class Effect; class ExpandRule; class RewriteRule; class ConstructRule; class FormatRule; class Peephole; class EncClass; class Interface; class RegInterface; class ConstInterface; class MemInterface; class CondInterface; class Opcode; class InsEncode; class RegDef; class RegClass; class CodeSnippetRegClass; class ConditionalRegClass; class AllocClass; class ResourceForm; class PipeClassForm; class PeepMatch; class PeepConstraint; class PeepReplace; class MatchList;
class ArchDesc;
//------------------------------FormDict--------------------------------------- // Dictionary containing Forms, and objects derived from forms class FormDict { private:
Dict _form; // map names, char*, to their Form* or NULL
// Disable public use of constructor, copy-ctor, operator =, operator ==
FormDict( );
FormDict &operator =( const FormDict & ); // == compares two dictionaries; they must have the same keys (their keys // must match using CmpKey) and they must have the same values (pointer // comparison). If so 1 is returned, if not 0 is returned. booloperator ==(const FormDict &d) const; // Compare dictionaries for equal
public: // cmp is a key comparison routine. hash is a routine to hash a key. // FormDict( CmpKey cmp, Hash hash );
FormDict( CmpKey cmp, Hash hash, AdlArena *arena );
FormDict( const FormDict & fd ); // Deep-copy guts
~FormDict();
// Return # of key-value pairs in dict int Size(void) const;
// Insert inserts the given key-value pair into the dictionary. The prior // value of the key is returned; NULL if the key was not previously defined. const Form *Insert(constchar *name, Form *form); // A new key-value
// Find finds the value of a given key; or NULL if not found. // The dictionary is NOT changed. const Form *operator [](constchar *name) const; // Do a lookup
void dump();
};
// ***** Master Class for ADL Parser Forms ***** //------------------------------Form------------------------------------------- class Form { public: static AdlArena *arena; // arena used by forms private: static AdlArena *generate_arena(); // allocate arena used by forms
protected: int _ftype; // Indicator for derived class type
public: // Public Data
Form *_next; // Next pointer for form lists int _linenum; // Line number for debugging
// Check if this form is an operand usable for cisc-spilling virtualbool is_cisc_reg(FormDict &globals) const { returnfalse; } virtualbool is_cisc_mem(FormDict &globals) const { returnfalse; }
// Public Methods
Form(int formType=0, int line=0)
: _next(NULL), _linenum(line), _ftype(formType) { }; virtual ~Form() {};
virtualbool ideal_only() const {
assert(0,"Check of ideal status on non-instruction/operand form.\n"); returnFALSE;
}
// Check constraints after parsing virtualbool verify() { returntrue; }
public: // ADLC types, match the last character on ideal operands and instructions enum DataType {
none = 0, // Not a simple type
idealI = 1, // Integer type
idealP = 2, // Pointer types, oop(s)
idealL = 3, // Long type
idealF = 4, // Float type
idealD = 5, // Double type
idealB = 6, // Byte type
idealC = 7, // Char type
idealS = 8, // String type
idealN = 9, // Narrow oop types
idealNKlass = 10, // Narrow klass types
idealV = 11 // Vector type
}; // Convert ideal name to a DataType, return DataType::none if not a 'ConX'
Form::DataType ideal_to_const_type(constchar *ideal_type_name) const; // Convert ideal name to a DataType, return DataType::none if not a 'sRegX
Form::DataType ideal_to_sReg_type(constchar *name) const; // Convert ideal name to a DataType, return DataType::none if not a 'RegX
Form::DataType ideal_to_Reg_type(constchar *name) const;
// Convert ideal name to a DataType, return DataType::none if not a 'LoadX
Form::DataType is_load_from_memory(constchar *opType) const; // Convert ideal name to a DataType, return DataType::none if not a 'StoreX
Form::DataType is_store_to_memory(constchar *opType) const;
// ADLC call types, matched with ideal world enum CallType {
invalid_type = 0, // invalid call type
JAVA_STATIC = 1, // monomorphic entry
JAVA_DYNAMIC = 2, // possibly megamorphic, inline cache call
JAVA_COMPILED = 3, // callee will be compiled java
JAVA_INTERP = 4, // callee will be executed by interpreter
JAVA_NATIVE = 5, // native entrypoint
JAVA_RUNTIME = 6, // runtime entrypoint
JAVA_LEAF = 7 // calling leaf
};
// Interface types for operands and operand classes enum InterfaceType {
no_interface = 0, // unknown or inconsistent interface type
constant_interface = 1, // interface to constants
register_interface = 2, // interface to registers
memory_interface = 3, // interface to memory
conditional_interface = 4 // interface for condition codes
}; virtual Form::InterfaceType interface_type(FormDict &globals) const;
//------------------------------FormList--------------------------------------- class FormList { private:
Form *_root;
Form *_tail;
Form *_cur; int _justReset; // Set immediately after reset
Form *_cur2; // Nested iterator int _justReset2;
//------------------------------NameList--------------------------------------- // Extendable list of pointers, <char *> class NameList { friendclass PreserveIter;
private: int _cur; // Insert next entry here; count of entries int _max; // Number of spaces allocated constchar **_names; // Array of names
protected: int _iter; // position during iteration bool _justReset; // Set immediately after reset
void reset(); // Reset iteration constchar *iter(); // after reset(), first element : else next constchar *current(); // return current element in iteration. constchar *peek(int skip = 1); // returns element + skip in iteration if there is one
bool current_is_signal(); // Return 'true' if current entry is signal bool is_signal(constchar *entry); // Return true if entry is a signal
bool search(constchar *); // Search for a name in the list int index(constchar *); // Return index of name in list constchar *name (intptr_t index);// Return name at index in list
void dump(); // output to stderr void output(FILE *fp); // Output list of names to 'fp'
NameList();
~NameList();
};
// Convenience class to preserve iteration state since iterators are // internal instead of being external. class PreserveIter { private:
NameList* _list; int _iter; bool _justReset;
//------------------------------NameAndList------------------------------------ // Storage for a name and an associated list of names class NameAndList { private: constchar *_name;
NameList _list;
public:
NameAndList(char *name);
~NameAndList();
// Add to entries in list void add_entry(constchar *entry);
// Access the name and its associated list. constchar *name() const; void reset(); constchar *iter();
int count() { return _list.count(); }
// Return the "index" entry in the list, zero-based constchar *operator[](int index);
void dump(); // output to stderr void output(FILE *fp); // Output list of names to 'fp'
};
//------------------------------ComponentList--------------------------------- // Component lists always have match rule operands first, followed by parameter // operands which do not appear in the match list (in order of declaration). class ComponentList : private NameList { private: int _matchcnt; // Count of match rule operands
public:
// This is a batch program. (And I have a destructor bug!) voidoperatordelete( void *ptr ) {}
int count(); int match_count() { return _matchcnt; } // Get count of match rule opers
Component *iter(); // after reset(), first element : else next
Component *match_iter(); // after reset(), first element : else next
Component *post_match_iter(); // after reset(), first element : else next void reset(); // Reset iteration
Component *current(); // return current element in iteration.
// Return element at "position", else NULL
Component *operator[](int position);
Component *at(int position) { return (*this)[position]; }
// Return first component having this name. const Component *search(constchar *name);
// Return number of USEs + number of DEFs int num_operands(); // Return zero-based position in list; -1 if not in list. int operand_position(constchar *name, int usedef, Form *fm); // Find position for this name, regardless of use/def information int operand_position(constchar *name); // Find position for this name when looked up for output via "format" int operand_position_format(constchar *name, Form *fm); // Find position for the Label when looked up for output via "format" int label_position(); // Find position for the Method when looked up for output via "format" int method_position();
void dump(); // output to stderr void output(FILE *fp); // Output list of names to 'fp'
ComponentList();
~ComponentList();
};
//------------------------------SourceForm------------------------------------- class SourceForm : public Form { private:
public: // Public Data char *_code; // Buffer for storing code text
// Public Methods
SourceForm(char* code);
~SourceForm();
//------------------------------Expr------------------------------------------ #define STRING_BUFFER_LENGTH 2048 // class Expr represents integer expressions containing constants and addition // Value must be in range zero through maximum positive integer. 32bits. // Expected use: instruction and operand costs class Expr { public: enum {
Zero = 0,
Max = 0x7fffffff
}; constchar *_external_name; // if !NULL, then print this instead of _expr constchar *_expr; int _min_value; int _max_value;
Expr();
Expr(constchar *cost);
Expr(constchar *name, constchar *expression, int min_value, int max_value);
Expr *clone() const;
staticchar *buffer() { return &external_buffer[0]; } staticbool init_buffers(); // Fill buffers with 0 staticbool check_buffers(); // if buffer use may have overflowed, assert
private: static Expr *_unknown_expr; staticchar string_buffer[STRING_BUFFER_LENGTH]; staticchar external_buffer[STRING_BUFFER_LENGTH]; staticbool _init_buffers; constchar *compute_expr(const Expr *c1, const Expr *c2); // cost as string after adding 'c1' and 'c2' int compute_min (const Expr *c1, const Expr *c2); // minimum after adding 'c1' and 'c2' int compute_max (const Expr *c1, const Expr *c2); // maximum after adding 'c1' and 'c2' constchar *compute_external(const Expr *c1, const Expr *c2); // external name after adding 'c1' and 'c2'
};
//------------------------------ExprDict--------------------------------------- // Dictionary containing Exprs class ExprDict { private:
Dict _expr; // map names, char*, to their Expr* or NULL
NameList _defines; // record the order of definitions entered with define call
// Disable public use of constructor, copy-ctor, operator =, operator ==
ExprDict( );
ExprDict( const ExprDict & ); // Deep-copy guts
ExprDict &operator =( const ExprDict & ); // == compares two dictionaries; they must have the same keys (their keys // must match using CmpKey) and they must have the same values (pointer // comparison). If so 1 is returned, if not 0 is returned. booloperator ==(const ExprDict &d) const; // Compare dictionaries for equal
public: // cmp is a key comparison routine. hash is a routine to hash a key.
ExprDict( CmpKey cmp, Hash hash, AdlArena *arena );
~ExprDict();
// Return # of key-value pairs in dict int Size(void) const;
// define inserts the given key-value pair into the dictionary, // and records the name in order for later output, ... const Expr *define(constchar *name, Expr *expr);
// Insert inserts the given key-value pair into the dictionary. The prior // value of the key is returned; NULL if the key was not previously defined. const Expr *Insert(constchar *name, Expr *expr); // A new key-value
// Find finds the value of a given key; or NULL if not found. // The dictionary is NOT changed. const Expr *operator [](constchar *name) const; // Do a lookup
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.