65 unsigned int _function_id,
const DesignFlowManagerConstRef _design_flow_manager)
77 switch(relationship_type)
81 relationships.insert(std::make_pair(USE_COUNTING,
SAME_FUNCTION));
87 relationships.insert(std::make_pair(SDC_CODE_MOTION,
SAME_FUNCTION));
103 if(operation_kind1 == plus_expr_K && operation_kind2 == plus_expr_K)
105 return ternary_plus_expr_K;
107 else if(operation_kind1 == plus_expr_K && operation_kind2 == minus_expr_K)
109 return ternary_pm_expr_K;
111 else if(operation_kind1 == minus_expr_K && operation_kind2 == plus_expr_K)
113 return ternary_mp_expr_K;
117 return ternary_mm_expr_K;
123 if(operation_kind1 == plus_expr_K && operation_kind2 == plus_expr_K)
125 return ternary_plus_expr_K;
127 else if(operation_kind1 == plus_expr_K && operation_kind2 == minus_expr_K)
129 return ternary_mm_expr_K;
131 else if(operation_kind1 == minus_expr_K && operation_kind2 == plus_expr_K)
133 return ternary_pm_expr_K;
137 return ternary_mp_expr_K;
143 if(
parameters->IsParameter(
"disable-extract-patterns") &&
144 parameters->GetParameter<
unsigned int>(
"disable-extract-patterns") == 1)
148 const auto hls_d = GetPointer<const HLS_manager>(
AppM)->get_HLS_device();
149 if(hls_d->has_parameter(
"disable_extract_ternary_patterns") &&
150 hls_d->get_parameter<
unsigned>(
"disable_extract_ternary_patterns"))
157 const auto TM =
AppM->get_tree_manager();
160 const auto fd = GetPointer<const function_decl>(tn);
161 THROW_ASSERT(fd && fd->body,
"Node is not a function or it hasn't a body");
162 auto sl = GetPointer<statement_list>(
GET_NODE(fd->body));
166 bool modified =
false;
167 for(
const auto& bb_pair :
sl->list_of_bloc)
169 const auto&
B = bb_pair.second;
170 const auto& B_id =
B->number;
172 const auto list_of_stmt =
B->CGetStmtList();
174 auto it_los = list_of_stmt.begin();
175 auto it_los_end = list_of_stmt.end();
176 while(it_los != it_los_end)
178 if(!
AppM->ApplyNewTransformation())
186 const auto ga = GetPointerS<const gimple_assign>(
GET_CONST_NODE(*it_los));
189 if(code0 == ssa_name_K && (code1 == plus_expr_K || code1 == minus_expr_K))
194 const auto ssa_defined = GetPointerS<const ssa_name>(
GET_CONST_NODE(ga->op0));
196 const auto binop0 = GetPointerS<const binary_expr>(
GET_CONST_NODE(ga->op1));
197 if((ssa_defined->CGetNumberUses() == 1) &&
201 const auto statement_node = ssa_defined->CGetUseStmts().begin()->first;
204 auto ga_dest = GetPointerS<gimple_assign>(
GET_NODE(statement_node));
208 if(code_dest0 == ssa_name_K && (code_dest1 == plus_expr_K || code_dest1 == minus_expr_K) &&
209 ga_dest->bb_index == B_id && ssa_dest0_size == ssa_defined_size)
214 "---Ternary plus expr statement found ");
215 const auto srcp_default = ga_dest->include_name +
":" +
STR(ga_dest->line_number) +
":" +
216 STR(ga_dest->column_number);
217 const auto binop_dest = GetPointerS<const binary_expr>(
GET_CONST_NODE(ga_dest->op1));
221 binop_dest->type, binop0->op0, binop0->op1, binop_dest->op1, srcp_default,
223 TM->ReplaceTreeNode(statement_node, ga_dest->op1, ternary_op);
228 binop_dest->type, binop_dest->op0, binop0->op0, binop0->op1, srcp_default,
230 TM->ReplaceTreeNode(statement_node, ga_dest->op1, ternary_op);
233 "<--Statement removed " +
GET_NODE(*it_los)->ToString());
234 B->RemoveStmt(*it_los,
AppM);
235 it_los = list_of_stmt.begin();
236 it_los_end = list_of_stmt.end();
237 AppM->RegisterTransformation(
GetName(), statement_node);
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
static bool IsComplexType(const tree_nodeConstRef &type)
Return if treenode is a complex.
Data structure representing the entire HLS information.
#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.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
Step successfully executed.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Definition of the class representing a generic C application.
std::string GetName() const override
Return the name of this design step.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
Data structure describing a basic block at tree level.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
Target must be reexecuted.
static bool IsVectorType(const tree_nodeConstRef &type)
Return true if the treenode is a vector.
#define GET_CONST_NODE(t)
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 file collects some utility functions.
tree_nodeRef create_ternary_operation(const tree_nodeConstRef &type, const tree_nodeRef &op0, const tree_nodeRef &op1, const tree_nodeRef &op2, const std::string &srcp, enum kind operation_kind) const
Function used to create a ternary expression.
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...
static tree_nodeConstRef CGetType(const tree_nodeConstRef &node)
Return the treenode of the type of node.
this class is used to manage the command-line or XML options.
int debug_level
The debug level.
#define GET_INDEX_CONST_NODE(t)
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.
HLS specialization of generic_device.
A brief description of the C++ Header File.
static bool IsRealType(const tree_nodeConstRef &type)
Return true if the treenode is of real type.
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 ...