PandA-2024.02
Bit_Value.hpp
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) 2004-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  */
48 #ifndef BIT_VALUE_HPP
49 #define BIT_VALUE_HPP
50 
51 #include "bit_lattice.hpp"
53 
54 #include "refcount.hpp"
61 class binary_expr;
62 enum class bit_lattice;
63 class gimple_assign;
64 class ssa_name;
65 class statement_list;
66 class addr_expr;
71 
80 {
81  private:
85  static const std::map<bit_lattice, std::map<bit_lattice, std::map<bit_lattice, std::deque<bit_lattice>>>>
87 
91  static const std::map<bit_lattice, std::map<bit_lattice, std::map<bit_lattice, std::deque<bit_lattice>>>>
93 
97  static const std::map<bit_lattice, std::map<bit_lattice, bit_lattice>> bit_ior_expr_map;
98 
102  static const std::map<bit_lattice, std::map<bit_lattice, bit_lattice>> bit_xor_expr_map;
103 
107  static const std::map<bit_lattice, std::map<bit_lattice, bit_lattice>> bit_and_expr_map;
108 
111 
115  std::vector<blocRef> bb_topological;
116 
123 
128 
133  void print_bitstring_map(const CustomMap<unsigned int, std::deque<bit_lattice>>& map) const;
134 
135  unsigned long long pointer_resizing(unsigned int output_id) const;
136 
137  unsigned int lsb_to_zero(const addr_expr* ae, bool safe) const;
138 
166  void initialize();
167 
171  void clear_current();
172 
179  void forward();
180 
187  void backward();
188 
195  std::deque<bit_lattice> forward_transfer(const gimple_assign* ga) const;
196 
203  std::deque<bit_lattice> backward_transfer(const gimple_assign* ga, unsigned int output_id) const;
204 
205  std::deque<bit_lattice> backward_chain(const tree_nodeConstRef& ssa) const;
206 
210  bool update_IR();
211 
217  std::deque<bit_lattice> get_current(const tree_nodeConstRef& tn) const;
218 
224  std::deque<bit_lattice> get_current_or_best(const tree_nodeConstRef& tn) const;
225 
227  ComputeFrontendRelationships(const DesignFlowStep::RelationshipType relationship_type) const override;
228 
229  public:
237  Bit_Value(const ParameterConstRef Param, const application_managerRef AM, unsigned int f_id,
238  const DesignFlowManagerConstRef dfm);
239 
243  ~Bit_Value() override;
249 
253  void Initialize() override;
254 
259  bool HasToBeExecuted() const override;
260 };
261 
262 #endif /* BIT_VALUE_HPP */
This struct specifies the field bloc (basic block).
static const std::map< bit_lattice, std::map< bit_lattice, std::map< bit_lattice, std::deque< bit_lattice > > > > plus_expr_map
Map storing the implementation of the forward_transfer&#39;s plus_expr.
Definition: Bit_Value.hpp:86
This struct specifies the statement_list node.
Definition: tree_node.hpp:4662
bool not_frontend
True if this step is not executed in the frontend.
Definition: Bit_Value.hpp:110
std::deque< bit_lattice > backward_chain(const tree_nodeConstRef &ssa) const
RelationshipType
The relationship type.
This class manages the tree structures extracted from the raw file.
CustomOrderedMap< T, U > CustomMap
Definition: custom_map.hpp:167
DesignFlowStep_Status InternalExec() override
perform the bit value analysis
Definition: Bit_Value.cpp:1047
void backward()
Applies the backward algorithm, as described in the paper, analyzing each assignment statement starti...
This class contains the base representation for a generic frontend flow step which works on a single ...
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapUnstable
Definition: custom_map.hpp:156
Abstract pure class for the tree structure.
Definition: tree_node.hpp:139
void print_bitstring_map(const CustomMap< unsigned int, std::deque< bit_lattice >> &map) const
Debugging function used to print the contents of the current and best maps.
Definition: Bit_Value.cpp:1095
std::deque< bit_lattice > backward_transfer(const gimple_assign *ga, unsigned int output_id) const
Compute the inputs back propagation values, given a gimple assignment and the uid of the output varia...
static const std::map< bit_lattice, std::map< bit_lattice, std::map< bit_lattice, std::deque< bit_lattice > > > > minus_expr_map
Map storing the implementation of the forward_transfer&#39;s minus_expr.
Definition: Bit_Value.hpp:92
void forward()
Applies the forward algorithm, as described in the paper, analyzing each assignment statement followi...
~Bit_Value() override
Destructor.
unsigned long long pointer_resizing(unsigned int output_id) const
Definition: Bit_Value.cpp:819
unsigned map[NUM_VERTICES]
Definition: bfs.c:12
This struct specifies the gimple_assign node (GCC 4.3 tree node).
Definition: tree_node.hpp:3015
unsigned int lsb_to_zero(const addr_expr *ae, bool safe) const
Definition: Bit_Value.cpp:888
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
Definition: Bit_Value.cpp:973
static const std::map< bit_lattice, std::map< bit_lattice, bit_lattice > > bit_and_expr_map
Map storing the implementation of the forward_transfer&#39;s bit_and_expr_map.
Definition: Bit_Value.hpp:107
static const std::map< bit_lattice, std::map< bit_lattice, bit_lattice > > bit_ior_expr_map
Map storing the implementation of the forward_transfer&#39;s bit_ior_expr_map.
Definition: Bit_Value.hpp:97
std::deque< bit_lattice > get_current(const tree_nodeConstRef &tn) const
Given an operand, returns its current bitvalue.
bit_lattice
Definition: bit_lattice.hpp:60
DesignFlowStep_Status
The status of a step.
bool update_IR()
Updates the bitvalues of the intermediate representation with the values taken from the input map...
Definition: Bit_Value.cpp:1112
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
Definition: Bit_Value.cpp:968
REF_FORWARD_DECL(Bit_Value)
Template definition of refcount.
CustomUnorderedMapUnstable< unsigned int, unsigned int > direct_call_id_to_called_id
Maps the id of a gimple statement to the id of the function called in that statement.
Definition: Bit_Value.hpp:122
void initialize()
Initializes best with C type as bitstring, signed_var and arguments using the information taken from ...
Definition: Bit_Value.cpp:1171
CONSTREF_FORWARD_DECL(tree_node)
std::deque< bit_lattice > forward_transfer(const gimple_assign *ga) const
Takes a gimple assignment, analyzes the operation performed from the rhs and its input bitstring...
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.
Definition: Bit_Value.cpp:929
std::vector< blocRef > bb_topological
Topologically ordered basic blocks.
Definition: Bit_Value.hpp:115
void clear_current()
Clears all the entry in the current map, except for the input arguments.
Definition: Bit_Value.cpp:1883
This struct specifies the ssa_name node.
Definition: tree_node.hpp:4523
CustomUnorderedSet< unsigned int > arguments
Contains the input parameters of the function that&#39;s being analyzed.
Definition: Bit_Value.hpp:127
struct definition of the binary node structures.
Definition: tree_node.hpp:1206
Full implementation of Bit Value analysis as described in BitValue Inference: Detecting and Exploitin...
Definition: Bit_Value.hpp:79
static const std::map< bit_lattice, std::map< bit_lattice, bit_lattice > > bit_xor_expr_map
Map storing the implementation of the forward_transfer&#39;s bit_xor_expr_map.
Definition: Bit_Value.hpp:102
Bit_Value(const ParameterConstRef Param, const application_managerRef AM, unsigned int f_id, const DesignFlowManagerConstRef dfm)
Constructor.
Definition: Bit_Value.cpp:917
std::deque< bit_lattice > get_current_or_best(const tree_nodeConstRef &tn) const
Given an operand, returns its current bitvalue, or its best if current is not available.

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