61 unsigned int _function_id,
62 const DesignFlowManagerConstRef _design_flow_manager)
78 switch(relationship_type)
82 relationships.insert(std::make_pair(CHECK_SYSTEM_TYPE,
SAME_FUNCTION));
83 relationships.insert(std::make_pair(COMPUTE_IMPLICIT_CALLS,
SAME_FUNCTION));
84 relationships.insert(std::make_pair(FIX_STRUCTS_PASSED_BY_VALUE,
CALLED_FUNCTIONS));
86 relationships.insert(std::make_pair(IR_LOWERING,
SAME_FUNCTION));
87 relationships.insert(std::make_pair(USE_COUNTING,
SAME_FUNCTION));
92 relationships.insert(std::make_pair(REMOVE_CLOBBER_GA,
SAME_FUNCTION));
104 return relationships;
109 bool changed =
false;
110 const auto TM =
AppM->get_tree_manager();
113 const auto fd = GetPointerS<const function_decl>(tn);
114 THROW_ASSERT(fd && fd->body,
"Node is not a function or it hasn't a body");
115 const auto sl = GetPointerS<const statement_list>(
GET_CONST_NODE(fd->body));
117 const auto CGMan =
AppM->CGetCallGraphManager();
118 const auto called_body_fun_ids = CGMan->GetReachedFunctionsFrom(
function_id);
120 for(
const auto&
block :
sl->list_of_bloc)
123 for(
const auto& stmt :
block.second->CGetStmtList())
129 const auto ga = GetPointerS<const gimple_assign>(
GET_CONST_NODE(stmt));
130 const auto srcp_default = ga->include_name +
":" +
STR(ga->line_number) +
":" +
STR(ga->column_number);
135 if(code1 == call_expr_K || code1 == aggr_init_expr_K)
137 const auto ce = GetPointerS<call_expr>(
GET_NODE(ga->op1));
141 const auto ae = GetPointerS<const addr_expr>(addr_node);
143 THROW_ASSERT(fu_decl_node->get_kind() == function_decl_K,
"node " +
STR(fu_decl_node) +
144 " is not function_decl but " +
145 fu_decl_node->get_kind_text());
148 "---is a call_expr with LHS " +
GET_CONST_NODE(ga->op0)->ToString());
150 "---the called function returns type " +
STR(ret_type_node));
151 if(code0 == ssa_name_K)
156 STR(assigned_ssa_type_node));
164 const auto ga_nop = tree_man->CreateNopExpr(new_ssa, assigned_ssa_type_node,
tree_nodeRef(),
169 const auto cast_ga = GetPointerS<const gimple_assign>(
GET_CONST_NODE(ga_nop));
170 TM->ReplaceTreeNode(ga_nop, cast_ga->op0, ga->op0);
174 TM->ReplaceTreeNode(stmt, ga->op0, new_ssa);
178 block.second->PushAfter(ga_nop, stmt,
AppM);
185 if(called_body_fun_ids.find(called_id) != called_body_fun_ids.end())
203 const auto gc = GetPointerS<gimple_call>(
GET_NODE(stmt));
207 const auto ae = GetPointerS<const addr_expr>(addr_node);
212 if(called_body_fun_ids.find(called_id) != called_body_fun_ids.end())
214 const auto srcp_default =
215 gc->include_name +
":" +
STR(gc->line_number) +
":" +
STR(gc->column_number);
244 std::vector<tree_nodeRef>&
args,
const std::string&
srcp)
const 246 bool changed =
false;
248 auto arg_it = args.cbegin();
249 for(; arg_it != args.cend(); arg_it++, arg_n++)
257 "---formal type = " +
GET_CONST_NODE(formal_type)->get_kind_text() +
"\t" +
STR(formal_type));
259 "---actual type = " +
GET_CONST_NODE(actual_type)->get_kind_text() +
"\t" +
STR(actual_type));
270 const auto parm_ue = GetPointerS<const unary_expr>(
GET_CONST_NODE(*arg_it));
272 formal_type, parm_ue->op, srcp,
281 block->PushBefore(ga_cleanup, stmt,
AppM);
284 const auto new_ssa = GetPointerS<const gimple_assign>(
GET_CONST_NODE(ga_cleanup))->op0;
286 auto tmp_arg_it = args.begin();
287 for(; tmp_arg_it != args.end(); tmp_arg_it++, k++)
293 tmp_arg_it = std::next(args.begin(),
static_cast<int>(
k));
294 arg_it = std::next(args.begin(),
static_cast<int>(arg_n));
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
static bool IsSameType(const tree_nodeConstRef &tn0, const tree_nodeConstRef &tn1)
Given two nodes tells if they have same base type (const is not considered: const double == double) ...
static tree_nodeConstRef GetFormalIth(const tree_nodeConstRef &obj, unsigned int parm_index)
Return the type of the ith formal parameter in case index_obj is a call_expr.
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
File containing functions and utilities to support the printing of debug messagges.
Step successfully executed.
const tree_nodeRef CGetTreeReindex(const unsigned int i) const
Return a tree_reindex wrapping the i-th tree_node.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Definition of the class representing a generic C application.
refcount< tree_manipulation > tree_manipulationRef
struct definition of the source position.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
~FunctionCallTypeCleanup() override
Destructor.
#define GET_INDEX_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
Data structure describing a basic block at tree level.
FunctionCallTypeCleanup(const ParameterConstRef Param, const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
tree_nodeRef create_unary_operation(const tree_nodeConstRef &type, const tree_nodeRef &op, const std::string &srcp, enum kind operation_kind) const
EXPRESSION_TREE_NODES.
tree_nodeRef CreateGimpleAssign(const tree_nodeConstRef &type, const tree_nodeConstRef &min, const tree_nodeConstRef &max, const tree_nodeRef &op, unsigned int function_decl_nid, const std::string &srcp) const
Create gimple assignment.
bool ParametersTypeCleanup(const tree_managerRef &TM, const tree_manipulationRef &tree_man, const blocRef &block, const tree_nodeRef &stmt, std::vector< tree_nodeRef > &args, const std::string &srcp) const
#define STR(s)
Macro which performs a lexical_cast to a string.
void RecursiveReplaceTreeNode(tree_nodeRef &tn, const tree_nodeRef old_node, const tree_nodeRef &new_node, const tree_nodeRef &stmt, bool definition)
Replace the occurrences of tree node old_node with new_node in statement identified by tn...
Auxiliary methods for manipulating string.
std::string ToString(ActorGraphBackend_Type actor_graph_backend_type)
Header include.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
static const uint32_t k[]
const unsigned int index
Represent the index read from the raw file and the index-1 of the vector of tree_node associated to t...
Target must be reexecuted.
#define GET_CONST_NODE(t)
Classes specification of the tree_node data structures.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
Class defining some useful functions to create tree nodes and to manipulate the tree manager...
#define DEBUG_LEVEL_NONE
no debugging print is performed.
This struct specifies the block node.
This file collects some utility functions.
const unsigned int function_id
The index of the function to be analyzed.
const application_managerRef AppM
The application manager.
Class specification of the tree_reindex support class.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
tree_nodeRef CreateNopExpr(const tree_nodeConstRef &operand, const tree_nodeConstRef &type, const tree_nodeConstRef &min, const tree_nodeConstRef &max, unsigned int function_decl_nid) const
Create a nop_expr to perform a conversion.
static tree_nodeConstRef CGetType(const tree_nodeConstRef &node)
Return the treenode of the type of node.
const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > ComputeFrontendRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
Return the set of analyses in relationship with this design step.
this class is used to manage the command-line or XML options.
refcount< tree_node > tree_nodeRef
RefCount type definition of the tree_node class structure.
int debug_level
The debug level.
#define GET_INDEX_CONST_NODE(t)
DesignFlowStep_Status InternalExec() override
Computes the operations CFG graph data structure.
static tree_nodeConstRef GetFunctionReturnType(const tree_nodeConstRef &function, bool void_as_null=true)
Return the return type of a function.
This class creates a layer to add nodes and to manipulate the tree_nodes manager. ...
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header File.
const FunctionBehaviorRef function_behavior
The function behavior of the function to be analyzed.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...