/* * 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. *
*/
// ADLPARSE.HPP - Definitions for Architecture Description Language Parser // Authors: Chris Vick and Mike Paleczny
// Class List class Form; // ***** Top Level, 1, classes ***** class InstructForm; class OperandForm; class OpClassForm; class AttributeForm; class RegisterForm; class PipelineForm; class SourceForm; class Peephole; // ***** Level 2 classes ***** class Component; class Predicate; class MatchRule; class Encode; class Attribute; class Effect; class ExpandRule; class RewriteRule; class Constraint; class ConstructRule; // ***** Register Section ***** class RegDef; class RegClass; class CodeSnippetRegClass; class ConditionalRegClass; class AllocClass; class ResourceForm; // ***** Pipeline Section ***** class PipeDesc; class PipeClass; class RegList; // ***** Peephole Section ***** class PeepPredicate; class PeepMatch; class PeepProcedure; class PeepConstraint; class PeepReplace;
externchar *toUpper(constchar *str);
//---------------------------ADLParser----------------------------------------- class ADLParser { protected: char *_curline; // Start of current line char *_ptr; // Pointer into current location in File Buffer char _curchar; // Current character from buffer
FormDict &_globalNames; // Global names
enum { _preproc_limit = 20 }; int _preproc_depth; // How deep are we into ifdefs? int _preproc_not_taken; // How deep in not-taken ifdefs? bool _preproc_taken[_preproc_limit]; // Are we taking this ifdef level? bool _preproc_else[_preproc_limit]; // Did this level have an else yet?
// Parse components of the register section void reg_def_parse(void); // Parse register definition void reg_class_parse(void); // Parse register class definition void reg_class_dynamic_parse(void); // Parse dynamic register class definition void alloc_class_parse(void); // Parse allocation class definition
// Parse components of the definition section void int_def_parse(void); // Parse an integer definition
// Parse components of a pipeline rule void resource_parse(PipelineForm &pipe); // Parse resource definition void pipe_desc_parse(PipelineForm &pipe); // Parse pipeline description definition void pipe_class_parse(PipelineForm &pipe); // Parse pipeline class definition
// Parse components of a peephole rule void peep_predicate_parse(Peephole &peep); // Parse the peephole predicate void peep_match_parse(Peephole &peep); // Parse the peephole match rule void peep_procedure_parse(Peephole &peep); // Parse the peephole procedure void peep_constraint_parse(Peephole &peep);// Parse the peephole constraints void peep_replace_parse(Peephole &peep); // Parse peephole replacement rule
// Parse the peep match rule tree
InstructForm *peep_match_child_parse(PeepMatch &match, int parent, int &position, int input);
// Parse components of an operand and/or instruction form
Predicate *pred_parse(void); // Parse predicate rule // Parse match rule, and internal nodes
MatchRule *match_parse(FormDict &operands);
MatchNode *matchNode_parse(FormDict &operands, int &depth, int &numleaves, bool atroot);
MatchNode *matchChild_parse(FormDict &operands, int &depth, int &numleaves, bool atroot);
// Return the next identifier given a pointer into a line of the buffer. char *get_ident() { return get_ident_common(true); } char *get_ident_no_preproc() { return get_ident_common(false); } char *get_ident_common(bool do_preproc); // Grab it from the file buffer char *get_ident_dup(void); // Grab a duplicate of the identifier char *get_ident_or_literal_constant(constchar* description); // Grab unique identifier from file buffer char *get_unique_ident(FormDict &dict, constchar *nameDescription); // Return the next replacement variable identifier char *get_rep_var_ident(void); // Skip first '$' and make a duplicate of the string char *get_rep_var_ident_dup(void); // Return the next token given as a signed integer. int get_int(void); // Return the next token, a relational operator { ==, !=, <=, >= } char *get_relation_dup(void);
void get_oplist(NameList ¶meters, FormDict &operands);// Parse type-operand pairs void get_effectlist(FormDict &effects, FormDict &operands, bool& has_call); // Parse effect-operand pairs // Return the contents of a parenthesized expression. // Requires initial '(' and consumes final ')', which is replaced by '\0'. char *get_paren_expr(constchar *description, bool include_location = false); // Return expression up to next stop-char, which terminator replaces. // Does not require initial '('. Does not consume final stop-char. // Final stop-char is left in _curchar, but is also is replaced by '\0'. char *get_expr(constchar *description, constchar *stop_chars); char *find_cpp_block(constchar *description); // Parse a C++ code block // Issue parser error message & go to EOL void parse_err(int flag, constchar *fmt, ...); // Create a location marker for this file and line. char *get_line_string(int linenum = 0); // Return a location marker which tells the C preprocessor to // forget the previous location marker. (Requires awk postprocessing.) char *end_line_marker() { return (char*)"\n#line 999999\n"; }
// Return pointer to current character inlinechar cur_char(void); // Advance to next character, assign this to _curchar inlinevoid next_char(void); inlinevoid next_char_or_line(void); // Advance File Buffer to next line, updating _curline inlinevoid next_line(void); // Issue an error if we are not at the beginning of a line (exc. whitespace). void ensure_start_of_line(void); // Issue an error if we are not at the end of a line (exc. whitespace). void ensure_end_of_line(void); // Skip whitespace, leaving ptr pointing to first non-whitespace character // Also handle preprocessor constructs like "#ifdef". void skipws() { skipws_common(true); } // Skip comments and spaces but not newlines or preprocessor constructs. void skipws_no_preproc() { skipws_common(false); } void skipws_common(bool do_preproc);
FileBuff &_buf; // File buffer to be parsed
ArchDesc &_AD; // Architecture Description being built
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.