risc::sg::SegmentGraph Class Reference

This class represents a segment graph for a process. More...

#include <segment_graph.h>

List of all members.

Public Types

typedef std::set
< SgFunctionDefinition * > 
FunctionCallBoundarySet
typedef std::set< VariantT > CCxxKeywordsBoundarySet
typedef std::set
< VertexDescriptor
SegmentSet

Public Member Functions

 SegmentGraph (FunctionCallBoundarySet function_boundaries)
 SegmentGraph (CCxxKeywordsBoundarySet keyword_boundaries)
 SegmentGraph (FunctionCallBoundarySet function_boundaries, CCxxKeywordsBoundarySet keyword_boundaries)
void clean_graph ()
 This function deletes all duplicated nodes in each vertex of the graph.
void print_graph (std::string filename)
 This function prints the graph in a dot file. The name of the file is user defined by argument.
void print_graph_read_write_access (std::string filename)
 This function prints all variables which have read or written in this segment.
void add_function (Function *function, bool duplicate_segments=false)
 This function analyzes the given function and creates a segment graph for it. The graph will be automatically inserted in the existing graph. The flag duplicate_segments will be used to generate an instance segement graph.
void read_write_analysis_of_segments ()
 The function determines which variables are read and written in the individual segments.
void set_all_segments_to_untouched ()
 This function sets the status of the flag helper_for_graph_algorithms for all nodes to 'Untouched'.

Public Attributes

Graph graph_
std::set< VertexDescriptorprecached_function_segments_

Private Member Functions

void handle_recursive_calls ()
 This function integrates the recursive function calls.
void separate_variable_declaration_and_initializer_on_demand (SgBasicBlock *&bb, bool duplicate_segments)
 This function checks if a direct or indirect boundary call is in the initializer expression of the variable declaration. If yes, the declaration and initialization will be separated. Example: Input: int x = y + foo(); // foo() has a indirect boundary Output: int x; x = y + foo();.
void decompose_expression_with_boundary_calls (SgExpression *expr, SgBasicBlock *&bb, bool duplicate_segments)
 This function decomposes an expression into multiple statements. Functions which call directly or indirectly a boundary will be separated and have temporally variables. Example: Input: x = y + foo(); // foo() has a indirect boundary Output: int temp_foo = foo(); int x = y + temp_foo();.
void create_temp_variable_for_expression (SgExpression *expr, SgBasicBlock *&bb)
 This function creates a variable declaration of the type of the given expression. The variable will be inserted before the associated expression statement of the given expression.
SgExpression * decompose_member_function_calls (SgFunctionCallExp *func_call, SgBasicBlock *&bb)
 This function decomposes member function calls like in the following given example: m + x.y->foo() + n; // where foo() has a boundary statement into Y *y = x.y; int temp_foo; temp_foo = y->foo() m + temp_foo + n;.
std::string generate_unique_name (SgNode *node)
 Generates an unique name for a varible based on the given node.
bool is_boundary_stmt (SgStatement const *const current_stmt)
 This function checks if a given statement is a potential boundary statement.
SgFunctionCallExp * has_function_call_with_boundary (SgExpression *expr, bool duplicate_segments)
 This function checks if in the given expression a function call occurs which calls a functon with a boundary statements.
bool should_decompose_function (SgExpression *expr)
 This function determines if a expression should be decomposed. This is the case if expression has the following structure: var = somepointer->func(); var = somevariable.func(); var = func(); and var is a global, member, or static variable.
SgFunctionDeclaration * contains_function_call_expression (SgExpression *expr)
 In this function we look for expressions which contain a function call in the following style: foo(); this->foo(); var = foo(); var = this->foo(); The return value will be the function declaration of the called function.
SegmentSet build_graph (SgStatement *current_stmt, SegmentSet current_segments, SegmentSet &break_segments, SegmentSet &continue_segments, bool duplicate_segments)
 This function creates the segment graph.
void add_expression_to_segment (SegmentSet segments, SgNode *expr)
 This function adds to each segment the given expression.
CachedFunctionAstAttributesbuild_segment_graph_for_function (SgFunctionDefinition *func_def, bool duplicate_segments)
 This function generates a segment graph for a function.
void insert_loop_edges (VertexDescriptor &loop_vertex, SegmentSet &current_segments, SegmentSet &continue_segments, SegmentSet &leaf_segments_of_loop)
 This is a helper function for loop handling.
SegmentSet duplicate_segments (SegmentSet segments)
SegmentSet duplicate_empty_segments (SegmentSet segments)

Private Attributes

FunctionCallBoundarySet function_boundaries_
CCxxKeywordsBoundarySet keyword_boundaries_
std::set< VertexDescriptorrecursive_function_calls_

Static Private Attributes

static int counter = 0

Detailed Description

This class represents a segment graph for a process.


Member Typedef Documentation

typedef std::set<SgFunctionDefinition*> risc::sg::SegmentGraph::FunctionCallBoundarySet

Constructor & Destructor Documentation

risc::sg::SegmentGraph::SegmentGraph ( FunctionCallBoundarySet  function_boundaries  ) 
risc::sg::SegmentGraph::SegmentGraph ( CCxxKeywordsBoundarySet  keyword_boundaries  ) 
risc::sg::SegmentGraph::SegmentGraph ( FunctionCallBoundarySet  function_boundaries,
CCxxKeywordsBoundarySet  keyword_boundaries 
)

Member Function Documentation

void risc::sg::SegmentGraph::add_expression_to_segment ( SegmentSet  segments,
SgNode *  expr 
) [private]

This function adds to each segment the given expression.

add_expression_to_segment

Parameters:
segments These segments which will contain the given expression
expr The expressions which will added to all segments
void risc::sg::SegmentGraph::add_function ( Function function,
bool  duplicate_segments = false 
)

This function analyzes the given function and creates a segment graph for it. The graph will be automatically inserted in the existing graph. The flag duplicate_segments will be used to generate an instance segement graph.

add_function

risc::sg::SegmentGraph::SegmentSet risc::sg::SegmentGraph::build_graph ( SgStatement *  current_stmt,
SegmentSet  current_segments,
SegmentSet break_segments,
SegmentSet continue_segments,
bool  duplicate_segments 
) [private]

This function creates the segment graph.

build_graph

Parameters:
current_stmt The first statement of the sequence which will be analyzed
current_segments The beginning segments
risc::sg::CachedFunctionAstAttributes * risc::sg::SegmentGraph::build_segment_graph_for_function ( SgFunctionDefinition *  func_def,
bool  duplicate_segments 
) [private]

This function generates a segment graph for a function.

build_segment_graph_for_function

void risc::sg::SegmentGraph::clean_graph (  ) 

This function deletes all duplicated nodes in each vertex of the graph.

clean_graph

SgFunctionDeclaration * risc::sg::SegmentGraph::contains_function_call_expression ( SgExpression *  expr  )  [private]

In this function we look for expressions which contain a function call in the following style: foo(); this->foo(); var = foo(); var = this->foo(); The return value will be the function declaration of the called function.

contains_call_expression

void risc::sg::SegmentGraph::create_temp_variable_for_expression ( SgExpression *  expr,
SgBasicBlock *&  bb 
) [private]

This function creates a variable declaration of the type of the given expression. The variable will be inserted before the associated expression statement of the given expression.

create_temp_variable_for_expression

void risc::sg::SegmentGraph::decompose_expression_with_boundary_calls ( SgExpression *  expr,
SgBasicBlock *&  bb,
bool  duplicate_segments 
) [private]

This function decomposes an expression into multiple statements. Functions which call directly or indirectly a boundary will be separated and have temporally variables. Example: Input: x = y + foo(); // foo() has a indirect boundary Output: int temp_foo = foo(); int x = y + temp_foo();.

decompose_expression_with_boundary_calls

SgExpression * risc::sg::SegmentGraph::decompose_member_function_calls ( SgFunctionCallExp *  func_call,
SgBasicBlock *&  bb 
) [private]

This function decomposes member function calls like in the following given example: m + x.y->foo() + n; // where foo() has a boundary statement into Y *y = x.y; int temp_foo; temp_foo = y->foo() m + temp_foo + n;.

decompose_member_function_calls It works for the dot operator with references as well.

risc::sg::SegmentGraph::SegmentSet risc::sg::SegmentGraph::duplicate_empty_segments ( SegmentSet  segments  )  [private]
risc::sg::SegmentGraph::SegmentSet risc::sg::SegmentGraph::duplicate_segments ( SegmentSet  segments  )  [private]
std::string risc::sg::SegmentGraph::generate_unique_name ( SgNode *  node  )  [private]

Generates an unique name for a varible based on the given node.

generate_unique_name

void risc::sg::SegmentGraph::handle_recursive_calls (  )  [private]

This function integrates the recursive function calls.

handle_recursive_calls

SgFunctionCallExp * risc::sg::SegmentGraph::has_function_call_with_boundary ( SgExpression *  expr,
bool  duplicate_segments 
) [private]

This function checks if in the given expression a function call occurs which calls a functon with a boundary statements.

has_function_call_with_boundary

void risc::sg::SegmentGraph::insert_loop_edges ( VertexDescriptor loop_vertex,
SegmentSet current_segments,
SegmentSet continue_segments,
SegmentSet leaf_segments_of_loop 
) [private]

This is a helper function for loop handling.

insert_loop_edges

bool risc::sg::SegmentGraph::is_boundary_stmt ( SgStatement const *const   current_stmt  )  [private]

This function checks if a given statement is a potential boundary statement.

is_boundary_stmt

Parameters:
current_stmt The statement which will be checked
void risc::sg::SegmentGraph::print_graph ( std::string  filename  ) 

This function prints the graph in a dot file. The name of the file is user defined by argument.

print_graph

Parameters:
filename The name of the file
void risc::sg::SegmentGraph::print_graph_read_write_access ( std::string  filename  ) 

This function prints all variables which have read or written in this segment.

print_graph_read_write_access

Parameters:
filename The name of the file
void risc::sg::SegmentGraph::read_write_analysis_of_segments (  ) 

The function determines which variables are read and written in the individual segments.

read_write_analysis_of_segments

void risc::sg::SegmentGraph::separate_variable_declaration_and_initializer_on_demand ( SgBasicBlock *&  bb,
bool  duplicate_segments 
) [private]

This function checks if a direct or indirect boundary call is in the initializer expression of the variable declaration. If yes, the declaration and initialization will be separated. Example: Input: int x = y + foo(); // foo() has a indirect boundary Output: int x; x = y + foo();.

separate_variable_declaration_and_initializer_on_demand

void risc::sg::SegmentGraph::set_all_segments_to_untouched (  ) 

This function sets the status of the flag helper_for_graph_algorithms for all nodes to 'Untouched'.

set_all_segments_to_untouched

bool risc::sg::SegmentGraph::should_decompose_function ( SgExpression *  expr  )  [private]

This function determines if a expression should be decomposed. This is the case if expression has the following structure: var = somepointer->func(); var = somevariable.func(); var = func(); and var is a global, member, or static variable.

should_decompose_function


Member Data Documentation

int risc::sg::SegmentGraph::counter = 0 [static, private]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 30 Sep 2015 by  doxygen 1.6.1