59 const DesignFlowManagerConstRef _design_flow_manager,
74 switch(relationship_type)
100 unsigned long long int& bambu_address,
101 unsigned long long int& taste_address,
unsigned int& registers,
102 const bool first_level,
const bool little_endianess)
114 taste_address = taste_address + 4;
124 bambu_address = bambu_address + 1;
125 taste_address = taste_address + 4;
143 taste_address = taste_address + 4;
153 bambu_address = bambu_address + 4;
154 taste_address = taste_address + 4;
168 taste_address = taste_address + 8;
194 bambu_address = bambu_address + byte_size;
195 taste_address = taste_address + 8;
197 else if(byte_size == 8)
204 bambu_address = bambu_address + byte_size;
205 taste_address = taste_address + 8;
209 THROW_ERROR(
"Integer larger than 128 bits not supported");
217 const auto octet_string = GetPointer<const OctetStringAsnType>(asn_type);
218 const auto byte_size = octet_string->size;
219 const auto word_size = (byte_size % 4) ? ((byte_size / 4) + 1) * 4 : byte_size / 4;
226 bambu_address = bambu_address + 1;
227 taste_address = taste_address + 1;
242 taste_address = taste_address + 8;
251 taste_address = taste_address + 4;
267 bambu_address = bambu_address + byte_size;
268 taste_address = taste_address + 4;
270 else if(byte_size == 8)
277 bambu_address = bambu_address + byte_size;
278 taste_address = taste_address + 8;
289 const auto redefine = GetPointer<const RedefineAsnType>(asn_type);
290 const auto redefine_asn_type =
aadl_information->CGetAsnType(redefine->name);
291 ComputeAddress(redefine_asn_type, tree_parameter_type, bambu_address, taste_address, registers, first_level,
297 const auto sequence = GetPointer<const SequenceAsnType>(asn_type);
299 const auto tree_fields = tree_record_type->list_of_flds;
300 size_t tree_field_index = 0;
301 for(
const auto& field : sequence->fields)
304 taste_address, registers,
false, little_endianess);
306 GetPointer<const field_decl>(
GET_NODE(tree_fields[tree_field_index]))->bpos) >= 0,
309 GetPointer<const field_decl>(
GET_NODE(tree_fields[tree_field_index]))->bpos));
310 THROW_ASSERT(field_bpos % 8 == 0,
"Bitfield not supported");
311 const auto current_field_beginning = field_bpos / 8;
312 const auto next_field_beginning = [&]() ->
unsigned long long int {
313 if(tree_field_index + 1 > tree_fields.size())
320 GetPointer<const field_decl>(
GET_NODE(tree_fields[tree_field_index + 1]))->bpos) >=
323 return static_cast<unsigned long long>(
325 GetPointer<const field_decl>(
GET_NODE(tree_fields[tree_field_index + 1]))->bpos) /
330 bambu_address = bambu_address + (field_size - (next_field_beginning - current_field_beginning));
338 const auto sequenceof = GetPointer<const SequenceOfAsnType>(asn_type);
339 const auto element_type =
aadl_information->CGetAsnType(sequenceof->element);
344 bambu_address, taste_address, registers,
false, little_endianess);
351 const auto set = GetPointer<const SetAsnType>(asn_type);
352 const auto tree_record_type = GetPointer<const record_type>(
TreeM->
CGetTreeNode(tree_parameter_type));
353 const auto tree_fields = tree_record_type->list_of_flds;
354 size_t tree_field_index = 0;
355 for(
const auto& field : set->fields)
358 taste_address, registers,
false, little_endianess);
360 GetPointer<const field_decl>(
GET_NODE(tree_fields[tree_field_index]))->bpos) >= 0,
363 GetPointer<const field_decl>(
GET_NODE(tree_fields[tree_field_index]))->bpos));
364 THROW_ASSERT(field_bpos % 8 == 0,
"Bitfield not supported");
365 const auto current_field_beginning = field_bpos / 8;
366 const auto next_field_beginning = [&]() ->
unsigned long long {
367 if(tree_field_index + 1 > tree_fields.size())
374 GetPointer<const field_decl>(
GET_NODE(tree_fields[tree_field_index + 1]))->bpos) >=
377 return static_cast<unsigned long long>(
379 GetPointer<const field_decl>(
GET_NODE(tree_fields[tree_field_index + 1]))->bpos) /
384 bambu_address = bambu_address + (field_size - (next_field_beginning - current_field_beginning));
391 const auto setof = GetPointer<const SetOfAsnType>(asn_type);
397 bambu_address, taste_address, registers,
false, little_endianess);
409 bool changed =
false;
410 const auto tmp_directory =
parameters->getOption<std::string>(OPT_output_temporary_directory);
411 const auto top_functions =
parameters->getOption<std::string>(OPT_top_functions_names);
412 auto new_top_functions = top_functions;
418 unsigned long long int taste_return_address = 0;
423 auto& function_parameters =
aadl_information->function_parameters.find(
"PI_" + top_function_name)->second;
427 "(unsigned int arg)\n");
432 "(unsigned int arg)\n");
441 "(unsigned int arg)\n");
444 unsigned long long int bambu_address = 0;
446 unsigned long long int taste_address = 4;
449 THROW_ASSERT(function_node,
"Function " + top_function_name +
" not found in tree");
450 const auto fd = GetPointer<const function_decl>(
GET_CONST_NODE(function_node));
451 for(
const auto&
arg : fd->list_of_args)
453 const auto pd = GetPointer<const parm_decl>(
GET_NODE(
arg));
454 const auto id = GetPointer<const identifier_node>(
GET_NODE(pd->name));
455 const auto param_name =
id->strg;
458 const auto ft = GetPointer<const function_type>(
GET_NODE(fd->type));
461 parameter_to_type[
"return"] = ft->retn->index;
463 bool used_return =
false;
464 for(
auto& parameter : function_parameters)
466 const auto parameter_name = parameter.name;
467 bambu_address = (bambu_address % 8) ? ((bambu_address / 8) + 1) * 8 : bambu_address;
468 taste_address = (taste_address % 8) ? ((taste_address / 8) + 1) * 8 : taste_address;
471 const auto tree_parameter_index = [&]() ->
unsigned int {
472 if(parameter_to_type.find(parameter_name) != parameter_to_type.end())
474 return parameter_to_type.find(parameter_name)->second;
478 THROW_ASSERT(not used_return,
"Parameter " + parameter_name +
" not found in C function");
479 THROW_ASSERT(parameter_to_type.find(
"return") != parameter_to_type.end(),
480 "Parameter " + parameter_name +
" not found in C function");
482 taste_return_address = taste_address;
483 return parameter_to_type.find(
"return")->second;
488 parameter.bambu_address = bambu_address;
490 ComputeAddress(asn_type, tree_parameter_index, bambu_address, taste_address, parameter.num_registers,
true,
491 parameter.endianess);
509 AppM->input_files.push_back(endianess_check_file);
512 if(bambu_address != 0)
517 const auto address_translation_file =
519 const auto memory_enabling_file =
525 AppM->input_files.push_back(address_translation_file);
526 AppM->input_files.push_back(memory_enabling_file);
527 AppM->input_files.push_back(data_size_file);
534 "(unsigned int address, unsigned int reg_status" +
535 (used_return ?
", unsigned int function_return_port" :
"") +
536 (bambu_address != 0 ?
", unsigned int from_memory" :
"") +
")\n");
537 output_multiplexer->
Append(
"{\n");
538 output_multiplexer->
Append(
"unsigned int ret = 0;\n");
541 output_multiplexer->
Append(
"if(address == " +
STR(taste_return_address) +
")\n");
542 output_multiplexer->
Append(
"{\n");
543 output_multiplexer->
Append(
"return function_return_port;\n");
544 output_multiplexer->
Append(
"}\n");
546 if(bambu_address != 0)
548 output_multiplexer->
Append(
"if(address == 0)\n");
549 output_multiplexer->
Append(
"{\n");
550 output_multiplexer->
Append(
"return reg_status;\n");
551 output_multiplexer->
Append(
"}\n");
552 output_multiplexer->
Append(
"else\n");
553 output_multiplexer->
Append(
"{\n");
554 output_multiplexer->
Append(
"return from_memory;\n");
555 output_multiplexer->
Append(
"}\n");
559 output_multiplexer->
Append(
"return reg_status;\n");
561 output_multiplexer->
Append(
"}\n");
562 const auto output_multiplexer_file =
564 output_multiplexer->
WriteFile(output_multiplexer_file);
565 AppM->input_files.push_back(output_multiplexer_file);
572 "(unsigned int current_value, unsigned int from_outside, unsigned int from_done)\n");
573 reg_status->
Append(
"{\n");
574 reg_status->
Append(
"unsigned int ret = 0;\n");
576 reg_status->
Append(
"unsigned int bit0 = from_outside & 1;\n");
577 reg_status->
Append(
"ret = ret | bit0 ;\n");
579 reg_status->
Append(
"unsigned int bit1 = (((bit0 != 0) && ((current_value & 2) == 0)) || (((current_value & 2) != 0) " 580 "&& (from_done == 0))) ? 2 : 0;\n");
581 reg_status->
Append(
"ret = ret | bit1;\n");
584 "unsigned int bit2 = (((current_value & 4) || (from_done)) && !((bit0) && !(current_value & 2))) ? 4 : 0;\n");
585 reg_status->
Append(
"ret = ret | bit2;\n");
587 reg_status->
Append(
"unsigned int bit3 = ((bit0) && (current_value & 2)) ? 8 : 0;\n");
588 reg_status->
Append(
"ret = ret | bit3;\n");
589 reg_status->
Append(
"return ret;\n");
590 reg_status->
Append(
"}\n");
593 AppM->input_files.push_back(reg_status_file);
599 endianess_inversion->
Append(
"{\n");
600 endianess_inversion->
Append(
"const int inverted = bswap32(input);\n");
601 endianess_inversion->
Append(
"return endianess == 1 ? inverted : input;\n");
602 endianess_inversion->
Append(
"}\n");
604 endianess_inversion->
WriteFile(endianess_inversion_file);
605 AppM->input_files.push_back(endianess_inversion_file);
#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.
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;.
virtual void Initialize()
Initialize the step (i.e., like a constructor, but executed just before exec.
File containing functions and utilities to support the printing of debug messagges.
void WriteFile(const std::string &file_name)
Write the indented output on a file.
#define STR_CST_string_separator
The character used to separate concatenated string.
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
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.
#define STR_CST_taste_memory_enabling
The suffix of the memory enabling function.
void ComputeAddress(const AsnTypeRef asn_type, const unsigned int tree_parameter_type, unsigned long long &bambu_address, unsigned long long int &taste_address, unsigned int ®isters, const bool first_level, const bool little_endianess)
Compute the addresses and add them to the writers.
Definition of the class representing a generic C application.
RelationshipType
The relationship type.
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
Source must be executed to satisfy target.
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.
#define STR_CST_taste_output_multiplexer
The suffix of the output multiplexer function.
CustomOrderedMap< T, U > CustomMap
IndentedOutputStreamRef memory_enabling
The memory enabling stream.
Class to print indented code.
Writes source code of hdl module to translate addresses from pci address space to bambu address space...
bool already_executed
True if it was already executed.
const tree_nodeConstRef CGetTreeNode(const unsigned int i) const
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
const tree_nodeRef get_tree_node_const(unsigned int i) const
Return the reference to the i-th tree_node Constant version of get_tree_node.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
~CreateAddressTranslation() override
Destructor.
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
refcount< IndentedOutputStream > IndentedOutputStreamRef
void Append(const std::string &str)
Append a string to the output.
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 STR_CST_taste_reg_status
The suffix of the reg_status value computation function.
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
#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.
This file collects some utility functions and macros.
#define STR_CST_taste_endianess_check
The suffix of the endianess check function.
tree_managerConstRef TreeM
The tree manager.
static bool is_a_pointer(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is a pointer.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
#define STR_CST_taste_data_size
The suffix of the data size function.
#define STR_CST_taste_endianess_inversion
The suffix of the endianess inversion function.
This file collects some utility functions.
enum FrontendFlowStepType { CREATE_TREE_MANAGER, FIND_MAX_TRANSFORMATIONS, FUNCTION_ANALYSIS, SYMBOLIC_APPLICATION_FRONTEND_FLOW_STEP, ADD_BB_ECFG_EDGES, ADD_ARTIFICIAL_CALL_FLOW_EDGES, ADD_OP_EXIT_FLOW_EDGES, ADD_OP_LOOP_FLOW_EDGES, ADD_OP_PHI_FLOW_EDGES, BAMBU_FRONTEND_FLOW, BASIC_BLOCKS_CFG_COMPUTATION, BB_CONTROL_DEPENDENCE_COMPUTATION, BB_FEEDBACK_EDGES_IDENTIFICATION, BB_ORDER_COMPUTATION, BB_REACHABILITY_COMPUTATION, BIT_VALUE, BIT_VALUE_OPT, BITVALUE_RANGE, BIT_VALUE_IPA, BLOCK_FIX, BUILD_VIRTUAL_PHI, CALL_EXPR_FIX, CALL_GRAPH_BUILTIN_CALL, CHECK_SYSTEM_TYPE, COMPLETE_BB_GRAPH, COMPLETE_CALL_GRAPH, COMPUTE_IMPLICIT_CALLS, COMMUTATIVE_EXPR_RESTRUCTURING, COND_EXPR_RESTRUCTURING, CSE_STEP, DATAFLOW_CG_EXT, DEAD_CODE_ELIMINATION, DEAD_CODE_ELIMINATION_IPA, DETERMINE_MEMORY_ACCESSES, DOM_POST_DOM_COMPUTATION, EXTRACT_GIMPLE_COND_OP, EXTRACT_PATTERNS, FIX_STRUCTS_PASSED_BY_VALUE, FUNCTION_CALL_TYPE_CLEANUP, FUNCTION_CALL_OPT, FANOUT_OPT, FIX_VDEF, HDL_FUNCTION_DECL_FIX, HDL_VAR_DECL_FIX, HLS_DIV_CG_EXT, HWCALL_INJECTION, INTERFACE_INFER, IR_LOWERING, LOOP_COMPUTATION, LOOPS_ANALYSIS_BAMBU, LOOPS_COMPUTATION, LUT_TRANSFORMATION, MULTI_WAY_IF, MULTIPLE_ENTRY_IF_REDUCTION, NI_SSA_LIVENESS, OP_CONTROL_DEPENDENCE_COMPUTATION, OP_FEEDBACK_EDGES_IDENTIFICATION, OP_ORDER_COMPUTATION, OP_REACHABILITY_COMPUTATION, OPERATIONS_CFG_COMPUTATION, PARM2SSA, PARM_DECL_TAKEN_ADDRESS, PHI_OPT, PREDICATE_STATEMENTS, ESSA, RANGE_ANALYSIS, REBUILD_INITIALIZATION, REBUILD_INITIALIZATION2, REMOVE_CLOBBER_GA, REMOVE_ENDING_IF, SCALAR_SSA_DATA_FLOW_ANALYSIS, SERIALIZE_MUTUAL_EXCLUSIONS, SPLIT_RETURN, SHORT_CIRCUIT_TAF, SIMPLE_CODE_MOTION, SOFT_FLOAT_CG_EXT, STRING_CST_FIX, SWITCH_FIX, UN_COMPARISON_LOWERING, UNROLLING_DEGREE, USE_COUNTING, VAR_ANALYSIS, VAR_DECL_FIX, VECTORIZE, VERIFICATION_OPERATION, VIRTUAL_AGGREGATE_DATA_FLOW_ANALYSIS, VIRTUAL_PHI_NODES_SPLIT } FrontendFlowStepType
IndentedOutputStreamRef data_size
The data size stream.
std::string GetSignature() const override
Return the signature of this step.
IndentedOutputStreamRef address_translation
The address translation stream.
const AadlInformationRef aadl_information
The asn information.
refcount< T > lock() const
#define STR_CST_taste_address_translation
The suffix of the address translation function.
const application_managerRef AppM
The application manager.
Class specification of the tree_reindex support class.
AsnType_Kind GetKind()
Return the type.
T * GetPointer(const refcount< U > &t)
Template function used to hide dynamic_cast The template parameter T represents a type of an object h...
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.
static tree_nodeConstRef CGetPointedType(const tree_nodeConstRef &pointer)
Return the pointed type of a pointer object.
this class is used to manage the command-line or XML options.
unsigned counter[N_THREADS]
Class to print indented code.
static integer_cst_t GetConstValue(const tree_nodeConstRef &tn, bool is_signed=true)
Get value from integer constant.
int debug_level
The debug level.
Data classes storing information for asn types.
DesignFlowStep_Status Exec() override
Execute this step.
tree_nodeRef GetFunction(const std::string &function_name) const
Return the index of a function given its name.
IndentedOutputStreamRef endianess_check
The endianess check stream.
CreateAddressTranslation(const application_managerRef AppM, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters)
Constructor.
Class specification of the manager of the tree structures extracted from the raw file.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...