GCC Middle and Back End API Reference
parser Class Reference
Collaboration diagram for parser:

Public Member Functions

 parser (cpp_reader *, bool gimple)
 

Data Fields

vec< simplify * > simplifiers
 
vec< predicate_id * > user_predicates
 
bool parsing_match_operand
 

Private Member Functions

const cpp_token * next ()
 
const cpp_token * peek (unsigned=1)
 
const cpp_token * peek_ident (const char *=NULL, unsigned=1)
 
const cpp_token * expect (enum cpp_ttype)
 
const cpp_token * eat_token (enum cpp_ttype)
 
const char * get_string ()
 
const char * get_ident ()
 
const cpp_token * eat_ident (const char *)
 
const char * get_number ()
 
unsigned get_internal_capture_id ()
 
id_baseparse_operation (unsigned char &)
 
operandparse_capture (operand *, bool)
 
operandparse_expr ()
 
c_exprparse_c_expr (cpp_ttype)
 
operandparse_op ()
 
void record_operlist (location_t, user_id *)
 
void parse_pattern ()
 
operandparse_result (operand *, predicate_id *)
 
void push_simplify (simplify::simplify_kind, vec< simplify * > &, operand *, operand *)
 
void parse_simplify (simplify::simplify_kind, vec< simplify * > &, predicate_id *, operand *)
 
void parse_for (location_t)
 
void parse_if (location_t)
 
void parse_predicates (location_t)
 
void parse_operator_list (location_t)
 
void finish_match_operand (operand *)
 

Private Attributes

cpp_reader * r
 
bool gimple
 
vec< c_expr * > active_ifs
 
vec< vec< user_id * > > active_fors
 
hash_set< user_id * > * oper_lists_set
 
vec< user_id * > oper_lists
 
cid_map_tcapture_ids
 
unsigned last_id
 

Detailed Description

AST parsing.   

Constructor & Destructor Documentation

◆ parser()

parser::parser ( cpp_reader * r_,
bool gimple_ )
Main entry of the parser.  Repeatedly parse outer control structures.   
parser's ctor.   

References active_fors, active_ifs, capture_ids, gimple, last_id, next(), NULL, oper_lists, oper_lists_set, parse_pattern(), parsing_match_operand, r, simplifiers, user_predicates, and vNULL.

Member Function Documentation

◆ eat_ident()

const cpp_token * parser::eat_ident ( const char * s)
private
Eat an identifier token with value S from R.   

References fatal_at(), get_ident(), and peek().

Referenced by parse_result().

◆ eat_token()

const cpp_token * parser::eat_token ( enum cpp_ttype tk)
private
Consume the next token from R and assert it is of type TK.   

References expect().

Referenced by parse_c_expr(), parse_capture(), parse_expr(), parse_for(), parse_op(), parse_operation(), parse_pattern(), and parse_result().

◆ expect()

const cpp_token * parser::expect ( enum cpp_ttype tk)
private
Read the next token from R and assert it is of type TK.   

References fatal_at(), and next().

Referenced by eat_token(), get_ident(), get_number(), get_string(), and parse_for().

◆ finish_match_operand()

void parser::finish_match_operand ( operand * op)
private
Finish up OP which is a match operand.   

References capture_ids, fatal_at(), get_internal_capture_id(), i, operand::location, NULL, walk_captures(), capture::what, and capture::where.

Referenced by parse_simplify().

◆ get_ident()

const char * parser::get_ident ( )
private
Read the next token from R and assert it is of type CPP_NAME and
return its value.   

References expect().

Referenced by eat_ident(), parse_capture(), parse_expr(), parse_for(), parse_op(), parse_operation(), parse_operator_list(), parse_pattern(), and parse_predicates().

◆ get_internal_capture_id()

unsigned parser::get_internal_capture_id ( )
private
Return a capture ID that can be used internally.   

References capture_ids, and fatal().

Referenced by finish_match_operand(), and parse_expr().

◆ get_number()

const char * parser::get_number ( )
private
Read the next token from R and assert it is of type CPP_NUMBER and
return its value.   

References expect().

Referenced by parse_capture().

◆ get_string()

const char * parser::get_string ( )
private
Read the next token from R and assert it is of type CPP_STRING and
return its value.   

References expect().

◆ next()

const cpp_token * parser::next ( )
private
Lexing helpers.   
Read the next non-whitespace token from R.   

References r.

Referenced by expect(), parse_c_expr(), and parser().

◆ parse_c_expr()

c_expr * parser::parse_c_expr ( cpp_ttype start)
private
Lex native C code delimited by START recording the preprocessing tokens
for later processing.
  c_expr = ('{'|'(') <pp token>... ('}'|')')   

References c_expr::c_expr(), capture_ids, c_expr::code, eat_token(), end(), fatal_at(), gcc_unreachable, get_operator(), next(), c_expr::nr_stmts, r, and vNULL.

Referenced by parse_if(), parse_op(), and parse_result().

◆ parse_capture()

class operand * parser::parse_capture ( operand * op,
bool require_existing )
private
Parse a capture.
 capture = '@'<number>   

References capture_ids, eat_token(), fatal_at(), get_ident(), get_number(), NULL, parsing_match_operand, and peek().

Referenced by parse_expr(), parse_op(), and parse_pattern().

◆ parse_expr()

◆ parse_for()

void parser::parse_for ( location_t )
private
Parsing of the outer control structures.   
Parse a for expression
 for = '(' 'for' <subst>... <pattern> ')'
 subst = <ident> '(' <ident>... ')'   

References active_fors, dyn_cast(), eat_token(), expect(), fatal_at(), get_ident(), get_operator(), id_base::hashval, i, user_id::is_oper_list, id_base::nargs, NULL, operators, parse_pattern(), peek(), peek_ident(), user_id::substitutes, vNULL, and warning_at().

Referenced by parse_pattern().

◆ parse_if()

void parser::parse_if ( location_t )
private
Parse an outer if expression.
 if = '(' 'if' '(' <c-expr> ')' <pattern> ')'   

References active_ifs, fatal_at(), parse_c_expr(), parse_pattern(), and peek().

Referenced by parse_pattern().

◆ parse_op()

class operand * parser::parse_op ( )
private
Parse an operand which is either an expression, a predicate or
a standalone capture.
  op = predicate | expr | c_expr | capture   

References dyn_cast(), eat_token(), fatal_at(), get_ident(), get_operator(), NULL, parse_c_expr(), parse_capture(), parse_expr(), parsing_match_operand, and peek().

Referenced by parse_expr(), parse_result(), and parse_simplify().

◆ parse_operation()

id_base * parser::parse_operation ( unsigned char & opt_grp)
private
Parse the operator ID, special-casing convert?, convert1? and
convert2?   

References active_fors, dyn_cast(), eat_token(), fatal_at(), free(), get_ident(), get_operator(), user_id::is_oper_list, NULL, parsing_match_operand, peek(), and record_operlist().

Referenced by parse_expr().

◆ parse_operator_list()

void parser::parse_operator_list ( location_t )
private
Parse an identifier associated with a list of operators.
 oprs = '(' 'define_operator_list' <ident> <ident>... ')'   

References dyn_cast(), fatal_at(), get_ident(), get_operator(), id_base::hashval, id_base::nargs, operators, peek(), peek_ident(), and user_id::substitutes.

Referenced by parse_pattern().

◆ parse_pattern()

◆ parse_predicates()

void parser::parse_predicates ( location_t )
private
Parse a list of predefined predicate identifiers.
 preds = '(' 'define_predicates' <ident>... ')'   

References add_predicate(), get_ident(), and peek().

Referenced by parse_pattern().

◆ parse_result()

operand * parser::parse_result ( operand * result,
predicate_id * matcher )
private
Parse
  <result-op> = <op> | <if> | <with>
  <if> = '(' 'if' '(' <c-expr> ')' <result-op> ')'
  <with> = '(' 'with' '{' <c-expr> '}' <result-op> ')'
and return it.   

References as_a(), if_expr::cond, eat_ident(), eat_token(), if_expr::falseexpr, fatal_at(), c_expr::nr_stmts, parse_c_expr(), parse_expr(), parse_op(), parse_result(), peek(), peek_ident(), with_expr::subexpr, if_expr::trueexpr, and with_expr::with.

Referenced by parse_result(), and parse_simplify().

◆ parse_simplify()

void parser::parse_simplify ( simplify::simplify_kind kind,
vec< simplify * > & simplifiers,
predicate_id * matcher,
operand * result )
private
Parse
  simplify = 'simplify' <expr> <result-op>
or
  match = 'match' <ident> <expr> [<result-op>]
and fill SIMPLIFIERS with the results.   

References active_ifs, as_a(), capture_ids, if_expr::cond, fatal_at(), finish_match_operand(), i, is_a(), operand::location, NULL, operand::OP_CAPTURE, operand::OP_EXPR, oper_lists, oper_lists_set, parse_op(), parse_result(), parsing_match_operand, peek(), push_simplify(), simplifiers, if_expr::trueexpr, operand::type, and vNULL.

Referenced by parse_pattern().

◆ peek()

const cpp_token * parser::peek ( unsigned num = 1)
private

◆ peek_ident()

const cpp_token * parser::peek_ident ( const char * id = NULL,
unsigned num = 1 )
private
Peek at the next identifier token (or return NULL if the next
token is not an identifier or equal to ID if supplied).   

References peek().

Referenced by parse_for(), parse_operator_list(), and parse_result().

◆ push_simplify()

void parser::push_simplify ( simplify::simplify_kind kind,
vec< simplify * > & simplifiers,
operand * match,
operand * result )
private
Create a new simplify from the current parsing state and MATCH,
MATCH_LOC, RESULT and RESULT_LOC and push it to SIMPLIFIERS.   

References active_fors, capture_ids, last_id, oper_lists, and simplifiers.

Referenced by parse_simplify().

◆ record_operlist()

void parser::record_operlist ( location_t loc,
user_id * p )
private
Record an operator-list use for transparent for handling.   

References fatal_at(), oper_lists, oper_lists_set, and user_id::substitutes.

Referenced by parse_operation().

Field Documentation

◆ active_fors

vec<vec<user_id *> > parser::active_fors
private

◆ active_ifs

vec<c_expr *> parser::active_ifs
private

◆ capture_ids

◆ gimple

bool parser::gimple
private

Referenced by parser().

◆ last_id

unsigned parser::last_id
private

Referenced by parser(), and push_simplify().

◆ oper_lists

vec<user_id *> parser::oper_lists
private

◆ oper_lists_set

hash_set<user_id *>* parser::oper_lists_set
private

◆ parsing_match_operand

bool parser::parsing_match_operand

◆ r

cpp_reader* parser::r
private

Referenced by next(), parse_c_expr(), parser(), and peek().

◆ simplifiers

vec<simplify *> parser::simplifiers

◆ user_predicates

vec<predicate_id *> parser::user_predicates

Referenced by main(), parse_pattern(), and parser().


The documentation for this class was generated from the following files: