------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2016, Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285 laboratory, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 1249 $ -- $Date: 2014-08-28 07:02:15 +0200 (Fri, 28 Aug 2014) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with unbounded_strings; use unbounded_strings; with Framework_Config; use Framework_Config; with CFG_Nodes; use CFG_Nodes; with CFG_Nodes.Extended; use CFG_Nodes.Extended; with Basic_Blocks; use Basic_Blocks; with Tables; with sets; with CFG_Edge_Set; use CFG_Edge_Set; package CFG_Node_Set.Basic_Block_Set is ---------------------------------------------------- -- This package is used for a task's control flow graph analysis -- each node in the graph represent a basic block. -- -- Notes: in the implementation of Cheddar, a CFG_Node is always instantiated -- either as a Basic_Block or an Atomic_Operation. -- + Some methods such as Search_Basic_Block, Search_Basic_Block_By_Id, ... -- are duplicated for Basic_Blocks to avoid type casting in the future. -- + The name of the methods is changed to improve the clarity thus no overload. ---------------------------------------------------- package Basic_Block_Set is new Sets ( max_element => Framework_Config.Max_CFG_Nodes, element => Basic_Block_Ptr, free => Free, copy => Copy, put => Put, xml_string => XML_String, xml_ref_string => XML_Ref_String); use Basic_Block_Set; type Basic_Blocks_Set is new Basic_Block_Set.set with private; subtype Basic_Blocks_Range is Basic_Block_Set.element_range; subtype Basic_Blocks_Iterator is Basic_Block_Set.iterator; ---------------------------------------------------- -- CHECK - BASIC_BLOCK ---------------------------------------------------- procedure Check_Basic_Block (name : in Unbounded_String; node_type : in CFG_Node_Type; graph_type : in CFG_Graph_Type; instruction_offset : in Integer; instruction_capacity : in Integer; data_offset : in Integer; data_capacity : in Integer; loop_bound : in Integer); --Check if the input data for a basic block is valid or not. --Called by the Add_CFG_Node for Basic_Block. ---------------------------------------------------- -- ADD - BASIC_BLOCK ---------------------------------------------------- procedure Add_Basic_Block (my_basic_blocks : in out Basic_Blocks_Set; a_basic_block : in out Basic_Block_Ptr; name : in Unbounded_String; node_type : in CFG_Node_Type; graph_type : in CFG_Graph_Type; instruction_offset : in Integer; instruction_capacity : in Integer; data_offset : in Integer; data_capacity : in Integer; loop_bound : in Integer); -- Add a Basic_Block to a Basic_Blocks_Set procedure Add_Basic_Block (my_basic_blocks : in out Basic_Blocks_Set; name : in Unbounded_String; node_type : in CFG_Node_Type; graph_type : in CFG_Graph_Type; instruction_offset : in Integer; instruction_capacity : in Integer; data_offset : in Integer; data_capacity : in Integer; loop_bound : in Integer); -- Add a Basic_Block to a Basic_Blocks_Set ------------------------------------------------------ -- UPDATE - BASIC_BLOCK ------------------------------------------------------ procedure Update_Basic_Block (my_basic_blocks : in out Basic_Blocks_Set; name : in Unbounded_String; node_type : in CFG_Node_Type; graph_type : in CFG_Graph_Type; instruction_offset : in Integer; instruction_capacity : in Integer; data_offset : in Integer; data_capacity : in Integer; loop_bound : in Integer); ------------------------------------------------------ -- DELETE ------------------------------------------------------ procedure Delete_Basic_Block (my_basic_blocks : in out Basic_Blocks_Set; a_basic_block : in out Basic_Block_Ptr); procedure Delete_Basic_Block (my_basic_blocks : in out Basic_Blocks_Set; name : in Unbounded_String); ---------------------------------------------------- -- ADD - (CFG_NODE) BASIC_BLOCK ---------------------------------------------------- procedure Add_CFG_Node (my_cfg_nodes : in out CFG_Nodes_Set; a_cfg_node : in out CFG_Node_Ptr; name : in Unbounded_String; node_type : in CFG_Node_Type; graph_type : in CFG_Graph_Type; instruction_offset : in Integer; instruction_capacity : in Integer; data_offset : in Integer; data_capacity : in Integer; loop_bound : in Integer); -- Add a (CFG_Node)Basic_Block to a CFG_Nodes_Set procedure Add_CFG_Node (my_cfg_nodes : in out CFG_Nodes_Set; name : in Unbounded_String; node_type : in CFG_Node_Type; graph_type : in CFG_Graph_Type; instruction_offset : in Integer; instruction_capacity : in Integer; data_offset : in Integer; data_capacity : in Integer; loop_bound : in Integer); -- Add a (CFG_Node)Basic_Block to a CFG_Nodes_Set ------------------------------------------------------ -- SEARCH ------------------------------------------------------ function Search_Basic_Block (my_basic_blocks : in Basic_Blocks_Set; name : in Unbounded_String) return Basic_Block_Ptr; --Search Basic_Block by name function Search_Basic_Block_By_Id (my_basic_blocks : in Basic_Blocks_Set; id : in Unbounded_String) return Basic_Block_Ptr; --Search Basic_Block by cheddar_private_id ------------------------------------------------------ -- NEXT, PREVIOUS ------------------------------------------------------ procedure Add_Next_Basic_Block (my_basic_blocks : in out Basic_Blocks_Set; name : in Unbounded_String; next_block_name : in Unbounded_String); -- Add the Basic_Block with name="next_node_name : in" to -- the next_nodes of the Basic_Block with name="name : in". procedure Add_Next_Basic_Block_By_Id (my_basic_blocks : in out Basic_Blocks_Set; a_basic_block : in out Basic_Block_Ptr; next_block_id : in Unbounded_String); -- Add the Basic_Block with id="previous_block_id : in" to -- the next_nodes of the Basic_Block a_basic_block. procedure Add_Previous_Basic_Block (my_basic_blocks : in out Basic_Blocks_Set; name : in Unbounded_String; previous_block_name : in Unbounded_String); -- Add the Basic_Block with name="previous_block_name : in" to -- the previous_nodes of the Basic_Block with name="name : in". procedure Add_Previous_Basic_Block_By_Id (my_basic_blocks : in out Basic_Blocks_Set; a_basic_block : in out Basic_Block_Ptr; previous_block_id : in Unbounded_String); -- Add the Basic_Block with id="previous_block_id : in" to -- the previous_nodes of the Basic_Block a_basic_block. procedure Set_Previous_Basic_Blocks (my_basic_blocks : in out Basic_Blocks_Set); --If all the next_nodes is set, this method is used to automatically --set the previous nodes. ---------------------------------------------------- -- CONVERT -- Methods for analysis based on the Useful Cache Block (UCB) ---------------------------------------------------- procedure Convert_To_Basic_Block_UCB_Set (my_cfg_nodes : in out CFG_Nodes_Set; my_cfg_edges : in out CFG_Edges_Set; size : in Integer); -- Convert a normal CFG_Node to Basic_Block_UCB -- Basic_Block_UCB is defined at CFG_Nodes.Extended procedure Convert_To_Basic_Block_UCB_Set (my_basic_blocks : in out Basic_Blocks_Set; my_cfg_edges : in out CFG_Edges_Set; size : in Integer); -- Convert a normal Basic_Block to Basic_Block_UCB -- Basic_Block_UCB is defined at CFG_Nodes.Extended private type Basic_Blocks_Set is new Basic_Block_Set.set with null record; end CFG_Node_Set.Basic_Block_Set;