PandA-2024.02
discrepancy_instruction_writer.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2019-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
44 
45 #include "application_manager.hpp"
46 #include "behavioral_helper.hpp"
47 #include "function_behavior.hpp"
48 #include "tree_helper.hpp"
49 #include "tree_manager.hpp"
50 #include "tree_node.hpp"
51 #include "tree_reindex.hpp"
52 
54  const IndentedOutputStreamRef _indented_output_stream,
55  const ParameterConstRef _parameters)
56  : HLSInstructionWriter(_app_man, _indented_output_stream, _parameters)
57 {
58 }
59 
60 void discrepancy_instruction_writer::declareFunction(const unsigned int function_id)
61 {
62  const auto FB = AppM->CGetFunctionBehavior(function_id);
63  const auto BH = FB->CGetBehavioralHelper();
64  const auto funName = BH->get_function_name();
65  const auto TM = AppM->get_tree_manager();
66  const auto node_fun = TM->CGetTreeReindex(function_id);
67  THROW_ASSERT(GetPointer<function_decl>(GET_NODE(node_fun)), "expected a function decl");
68  const auto prepend_static =
69  !tree_helper::IsStaticDeclaration(node_fun) && !tree_helper::IsExternDeclaration(node_fun) && funName != "main";
70  if(prepend_static)
71  {
72  GetPointerS<function_decl>(GET_NODE(node_fun))->static_flag = true;
73  }
75  if(prepend_static)
76  {
77  GetPointerS<function_decl>(GET_NODE(node_fun))->static_flag = false;
78  }
79 }
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
Definition: tree_node.hpp:343
static bool IsExternDeclaration(const tree_nodeConstRef &decl)
discrepancy_instruction_writer(const application_managerConstRef app_man, const IndentedOutputStreamRef indented_output_stream, const ParameterConstRef parameters)
Constructor.
Definition of the class representing a generic C application.
void declareFunction(const unsigned int function_id) override
Write the declaration of a function.
Classes specification of the tree_node data structures.
static bool IsStaticDeclaration(const tree_nodeConstRef &decl)
const application_managerConstRef AppM
The application manager.
This file collects some utility functions.
void declareFunction(const unsigned int function_id) final
Write the declaration of a function.
Class specification of the tree_reindex support class.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
specialization of the instruction writer for the discrepancy analysis
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header 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 ...
Definition: exceptions.hpp:289

Generated on Mon Feb 12 2024 13:02:51 for PandA-2024.02 by doxygen 1.8.13