gcc/gcc/tree-ssanames.h
Prasad Ghangal 1ee62b9264 Make-lang.in (C_AND_OBJC_OBJS): Add gimple-parser.o.
2016-11-14  Prasad Ghangal  <prasad.ghangal@gmail.com>
	Richard Biener  <rguenther@suse.de>
    
    	c/
    	* Make-lang.in (C_AND_OBJC_OBJS): Add gimple-parser.o.
    	* config-lang.in (gtfiles): Add c/c-parser.h.
    	* c-tree.h (enum c_declspec_word): Add cdw_gimple.
    	(struct c_declspecs): Add gimple_pass member and gimple_p flag.
    	* c-parser.c (enum c_id_kind, struct c_token,
    	c_parser_next_token_is, c_parser_next_token_is_not,
    	c_parser_next_token_is_keyword,
    	enum c_lookahead_kind, enum c_dtr_syn, enum c_parser_prec):
    	Split out to ...
    	* c-parser.h: ... new header.
    	* c-parser.c: Include c-parser.h and gimple-parser.h.
	(c_parser_peek_token, c_parser_peek_2nd_token,
    	c_token_starts_typename, c_parser_next_token_starts_declspecs,
    	c_parser_next_tokens_start_declaration, c_parser_consume_token,
    	c_parser_error, c_parser_require, c_parser_skip_until_found,
    	c_parser_declspecs, c_parser_declarator, c_parser_peek_nth_token,
    	c_parser_type_name): Export.
    	(c_parser_tokens_buf): New function.
    	(c_parser_error): Likewise.
    	(c_parser_set_error): Likewise.
    	(c_parser_declspecs): Handle RID_GIMPLE.
	(c_parser_declaration_or_fndef): Parse __GIMPLE marked body
	via c_parser_parse_gimple_body.
    	* c-parser.h (c_parser_peek_token, c_parser_peek_2nd_token,
    	c_token_starts_typename, c_parser_next_token_starts_declspecs,
    	c_parser_next_tokens_start_declaration, c_parser_consume_token,
    	c_parser_error, c_parser_require, c_parser_skip_until_found,
    	c_parser_declspecs, c_parser_declarator, c_parser_peek_nth_token,
    	c_parser_type_name): Declare.
	(struct c_parser): Declare forward.
	(c_parser_tokens_buf): Declare.
        (c_parser_error): Likewise.
        (c_parser_set_error): Likewise.
    	* gimple-parser.c: New file.
    	* gimple-parser.h: Likewise.
    
    	obj-c/
    	* config-lang.in (gtfiles): Add c/c-parser.h.

    	c-family/
    	* c-common.h (c_common_resword): Add RID_GIMPLE, RID_PHI types.
    	* c-common.h (enum rid): Add RID_GIMPLE, RID_PHI.
    	* c.opt (fgimple): New option.

	* doc/invoke.texi (fgimple): Document.
 
    	* dumpfile.h (TDF_GIMPLE): Add.
    	* dumpfile.c (dump_options): Add gimple.
    	* gimple-pretty-print.c (dump_gimple_switch): Adjust dump
	for TDF_GIMPLE.
	(dump_gimple_label): Likewise.
	(dump_gimple_phi): Likewise.
	(dump_gimple_bb_header): Likewise.
	(dump_phi_nodes): Likewise.
	(pp_cfg_jump): Likewise.  Pass in dump flags.
	(dump_implicit_edges): Adjust.
    	* passes.c (pass_init_dump_file): Do not dump function header
    	for TDF_GIMPLE.
    	* tree-cfg.c (dump_function_to_file): Dump function return type
	and __GIMPLE keyword for TDF_GIMPLE.  Change guard for dumping
	GIMPLE stmts.
    	* tree-pretty-print.c (dump_decl_name): Adjust dump for TDF_GIMPLE.
    	(dump_generic_node): Likewise.

	* function.h (struct function): Add pass_startwith member.
	* passes.c (execute_one_pass): Implement startwith.

    	* tree-ssanames.c (make_ssa_name_fn): New argument, check for version
    	and assign proper version for parsed ssa names.
    	* tree-ssanames.h (make_ssa_name_fn): Add new argument to the function.
    	* internal-fn.c (expand_PHI): New function.
    	* internal-fn.h (expand_PHI): Declared here.
    	* internal-fn.def: New defination for PHI.
    	* tree-cfg.c (lower_phi_internal_fn): New function.
	(build_gimple_cfg): Call it.
    	(verify_gimple_call): Condition for passing label as arg in internal
    	function PHI.
	* tree-into-ssa.c (rewrite_add_phi_arguments): Handle already
	present PHIs with arguments.

    	testsuite/
    	* gcc.dg/gimplefe-1.c: New testcase.
    	* gcc.dg/gimplefe-2.c: Likewise.
    	* gcc.dg/gimplefe-3.c: Likewise.
    	* gcc.dg/gimplefe-4.c: Likewise.
    	* gcc.dg/gimplefe-5.c: Likewise.
    	* gcc.dg/gimplefe-6.c: Likewise.
    	* gcc.dg/gimplefe-7.c: Likewise.
    	* gcc.dg/gimplefe-8.c: Likewise.
    	* gcc.dg/gimplefe-9.c: Likewise.
    	* gcc.dg/gimplefe-10.c: Likewise.
    	* gcc.dg/gimplefe-11.c: Likewise.
    	* gcc.dg/gimplefe-12.c: Likewise.
    	* gcc.dg/gimplefe-13.c: Likewise.
    	* gcc.dg/gimplefe-14.c: Likewise.
    	* gcc.dg/gimplefe-15.c: Likewise.
    	* gcc.dg/gimplefe-16.c: Likewise.
    	* gcc.dg/gimplefe-17.c: Likewise.
    	* gcc.dg/gimplefe-18.c: Likewise.

Co-Authored-By: Richard Biener <rguenther@suse.de>

From-SVN: r242387
2016-11-14 13:51:48 +00:00

157 lines
5.3 KiB
C

/* SSA name expresssons routines
Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC 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
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_TREE_SSANAMES_H
#define GCC_TREE_SSANAMES_H
/* Aliasing information for SSA_NAMEs representing pointer variables. */
struct GTY(()) ptr_info_def
{
/* The points-to solution. */
struct pt_solution pt;
/* Alignment and misalignment of the pointer in bytes. Together
align and misalign specify low known bits of the pointer.
ptr & (align - 1) == misalign. */
/* When known, this is the power-of-two byte alignment of the object this
pointer points into. This is usually DECL_ALIGN_UNIT for decls and
MALLOC_ABI_ALIGNMENT for allocated storage. When the alignment is not
known, it is zero. Do not access directly but use functions
get_ptr_info_alignment, set_ptr_info_alignment,
mark_ptr_info_alignment_unknown and similar. */
unsigned int align;
/* When alignment is known, the byte offset this pointer differs from the
above alignment. Access only through the same helper functions as align
above. */
unsigned int misalign;
};
/* Value range information for SSA_NAMEs representing non-pointer variables. */
struct GTY ((variable_size)) range_info_def {
/* Minimum, maximum and nonzero bits. */
TRAILING_WIDE_INT_ACCESSOR (min, ints, 0)
TRAILING_WIDE_INT_ACCESSOR (max, ints, 1)
TRAILING_WIDE_INT_ACCESSOR (nonzero_bits, ints, 2)
trailing_wide_ints <3> ints;
};
#define SSANAMES(fun) (fun)->gimple_df->ssa_names
#define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
#define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names))
#define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)])
#define FOR_EACH_SSA_NAME(I, VAR, FN) \
for (I = 1; SSANAMES (FN)->iterate (I, &VAR); ++I) \
if (VAR)
/* Sets the value range to SSA. */
extern void set_range_info (tree, enum value_range_type, const wide_int_ref &,
const wide_int_ref &);
/* Gets the value range from SSA. */
extern enum value_range_type get_range_info (const_tree, wide_int *,
wide_int *);
extern void set_nonzero_bits (tree, const wide_int_ref &);
extern wide_int get_nonzero_bits (const_tree);
extern bool ssa_name_has_boolean_range (tree);
extern void init_ssanames (struct function *, int);
extern void fini_ssanames (struct function *);
extern void ssanames_print_statistics (void);
extern tree make_ssa_name_fn (struct function *, tree, gimple *,
unsigned int version = 0);
extern void release_ssa_name_fn (struct function *, tree);
extern bool get_ptr_info_alignment (struct ptr_info_def *, unsigned int *,
unsigned int *);
extern void mark_ptr_info_alignment_unknown (struct ptr_info_def *);
extern void set_ptr_info_alignment (struct ptr_info_def *, unsigned int,
unsigned int);
extern void adjust_ptr_info_misalignment (struct ptr_info_def *,
unsigned int);
extern struct ptr_info_def *get_ptr_info (tree);
extern void set_ptr_nonnull (tree);
extern bool get_ptr_nonnull (const_tree);
extern tree copy_ssa_name_fn (struct function *, tree, gimple *);
extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
extern void duplicate_ssa_name_range_info (tree, enum value_range_type,
struct range_info_def *);
extern void reset_flow_sensitive_info (tree);
extern void reset_flow_sensitive_info_in_bb (basic_block);
extern void release_defs (gimple *);
extern void replace_ssa_name_symbol (tree, tree);
extern void flush_ssaname_freelist (void);
/* Return an SSA_NAME node for variable VAR defined in statement STMT
in function cfun. */
static inline tree
make_ssa_name (tree var, gimple *stmt = NULL)
{
return make_ssa_name_fn (cfun, var, stmt);
}
/* Return an SSA_NAME node using the template SSA name NAME defined in
statement STMT in function cfun. */
static inline tree
copy_ssa_name (tree var, gimple *stmt = NULL)
{
return copy_ssa_name_fn (cfun, var, stmt);
}
/* Creates a duplicate of a SSA name NAME tobe defined by statement STMT
in function cfun. */
static inline tree
duplicate_ssa_name (tree var, gimple *stmt)
{
return duplicate_ssa_name_fn (cfun, var, stmt);
}
/* Release the SSA name NAME used in function cfun. */
static inline void
release_ssa_name (tree name)
{
release_ssa_name_fn (cfun, name);
}
/* Return an anonymous SSA_NAME node for type TYPE defined in statement STMT
in function cfun. Arrange so that it uses NAME in dumps. */
static inline tree
make_temp_ssa_name (tree type, gimple *stmt, const char *name)
{
tree ssa_name;
gcc_checking_assert (TYPE_P (type));
ssa_name = make_ssa_name_fn (cfun, type, stmt);
SET_SSA_NAME_VAR_OR_IDENTIFIER (ssa_name, get_identifier (name));
return ssa_name;
}
#endif /* GCC_TREE_SSANAMES_H */