Otawa  0.10
FlowFactLoader.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * FlowFactLoader class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2005-09, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef OTAWA_UTIL_FLOW_FACT_LOADER_H
23 #define OTAWA_UTIL_FLOW_FACT_LOADER_H
24 
25 #include <elm/string.h>
26 #include <elm/utility.h>
27 #include <elm/io.h>
28 #include <elm/system/Path.h>
29 #include <otawa/base.h>
30 #include <otawa/prop/Identifier.h>
31 #include <otawa/proc/Feature.h>
32 #include <elm/genstruct/Vector.h>
34 #include <elm/types.h>
35 #include <otawa/dfa/State.h>
36 
37 // Externals
38 namespace otawa { class FlowFactLoader; }
39 namespace elm { namespace xom { class Element; class Node; } }
41 void util_fft_error(otawa::FlowFactLoader *loader, const char *msg);
42 
43 namespace otawa {
44 
45 using namespace elm;
46 using namespace elm::genstruct;
47 
48 // Extern class
49 class ContextualPath;
50 class File;
51 class WorkSpace;
52 
53 // FlowFactLoader abstract class
54 class FlowFactLoader: public Processor {
55  friend int ::util_fft_parse(FlowFactLoader *loader);
56  friend void ::util_fft_error(otawa::FlowFactLoader *loader, const char *msg);
57 public:
58  static p::declare reg;
59  FlowFactLoader(p::declare& r = reg);
60 
61 protected:
62  inline WorkSpace *workSpace(void) const { return _fw; }
63 
64  Address addressOf(const string& label);
65  MemArea addressOf(const string& file, int line) throw(ProcessorException);
66  void onError(const string& message);
67  void onWarning(const string& message);
68 
69  virtual void onCheckSum(const String& name, t::uint32 sum);
70  virtual void onLibrary(void);
71  virtual void onLoop(address_t addr, int count, int total, const ContextualPath& path);
72  virtual void onReturn(address_t addr);
73  virtual void onNoReturn(address_t addr);
74  virtual void onNoReturn(String name);
75  virtual void onNoCall(Address address);
76  virtual void onNoInline(Address address, bool no_inline, const ContextualPath& path);
77  virtual void onIgnoreSeq(Address address);
78  virtual void onIgnoreControl(Address address);
79  virtual void onMultiBranch(Address control, const Vector<Address>& target);
80  virtual void onMultiCall(Address control, const Vector<Address>& target);
81  virtual void onPreserve(Address address);
82  virtual void onIgnoreEntry(string name);
83 
84  virtual void onUnknownLoop(Address addr);
85  virtual void onUnknownMultiBranch(Address control);
86  virtual void onUnknownMultiCall(Address control);
87 
88  virtual void onMemoryAccess(Address iaddr, Address lo, Address hi, const ContextualPath& path);
89  virtual void onRegSet(string name, const dfa::Value& value);
90  virtual void onMemSet(Address addr, const Type *type, const dfa::Value& value);
91  virtual void onSetInlining(Address address, bool policy, const ContextualPath& path);
92 
93  virtual void processWorkSpace(WorkSpace *ws);
94  virtual void configure (const PropList &props);
95  virtual void setup(WorkSpace *ws);
96 
97 private:
103  bool mandatory;
106  bool lib;
107 
108  // F4 support
109  void loadF4(const string& path) throw(ProcessorException);
110 
111  // XML support
112  void load(WorkSpace *ws, const Path& path);
113  void loadXML(const string& path) throw(ProcessorException);
114  void scanXLoop(xom::Element *element, ContextualPath& path) throw(ProcessorException);
115  void scanXFun(xom::Element *element, ContextualPath& path) throw(ProcessorException);
116  void scanXConditional(xom::Element *element, ContextualPath& path) throw(ProcessorException);
117  MemArea scanAddress(xom::Element *element, ContextualPath& path) throw(ProcessorException);
118  Option<long> scanInt(xom::Element *element, cstring name) throw(ProcessorException);
120  Option<long> scanBound(xom::Element *element, cstring name) throw(ProcessorException);
121  void scanXContent(xom::Element *element, ContextualPath& path) throw(ProcessorException);
122  void scanXBody(xom::Element *element, ContextualPath& path) throw(ProcessorException);
123  void scanXCall(xom::Element *element, ContextualPath& path) throw(ProcessorException);
124  string xline(xom::Node *element);
125  void scanNoInline(xom::Element *element, ContextualPath& cpath, bool no_inline);
126  void scanIgnoreEntry(xom::Element *element);
127  void scanMultiBranch(xom::Element *element, ContextualPath& cpath);
128  void scanMultiCall(xom::Element *element, ContextualPath& cpath);
129  void scanIgnoreControl(xom::Element *element, ContextualPath& cpath);
130  void scanIgnoreSeq(xom::Element *element, ContextualPath& cpath);
131  dfa::Value scanValue(xom::Element *element);
132  void scanMemAccess(xom::Element *element);
133  void scanRegSet(xom::Element *element);
134  void scanMemSet(xom::Element *element);
135  void scanSetInlining(xom::Element *element, ContextualPath& cpath, bool policy);
136 };
137 
138 // Properties
142 
143 // Features
146 
147 // Annotations
163 
164 } // otawa
165 
166 #endif // OTAWA_UTIL_FLOW_FACT_READER_H
Identifier< int > MIN_ITERATION
Put on the first instruction of a loop, it gives the minimal number of iterations.
Identifier< bool > IGNORE_SEQ
Put on a control instruction to prevent to pass in sequence.
bool lines_available
Definition: FlowFactLoader.h:104
Identifier< int > TOTAL_ITERATION
Put on the first instruction of a loop, it gives the total number of iterations during the whole exec...
WorkSpace * _fw
Definition: FlowFactLoader.h:98
Feature< FlowFactLoader > FLOW_FACTS_FEATURE
This feature ensures that the flow facts has been loaded.
Definition: ContextualProperty.h:105
genstruct::Vector< xom::Element * > nodes
Definition: FlowFactLoader.h:101
Class to declare simple a processor.
Definition: Registration.h:213
Identifier< bool > FLOW_FACTS_MANDATORY
In configuration of the FlowFactLoader, makes it fail if no flow fact fail is available.
Identifier< bool > IGNORE_CONTROL
Put on a control instruction to prevent it to be interpreted as is.
WorkSpace * workSpace(void) const
Definition: FlowFactLoader.h:62
bool mandatory
Definition: FlowFactLoader.h:103
elm::io::IntFormat address(Address addr)
Build a format to display addresses.
Definition: base.cpp:213
Identifier< Address > CALL_TARGET
Put on instruction that may call to several targets or whose target computation cannot computed...
Identifier< Address > BRANCH_TARGET
Put on instruction that may branch to several targets or whose target computation cannot computed...
int util_fft_parse(otawa::FlowFactLoader *loader)
Identifier< bool > INLINING_POLICY
Put on the first instruction of a function to set default inlining behavior during its virtualization...
The processor class is implemented by all code processor.
Definition: Processor.h:49
Identifier< bool > NO_INLINE
Put on the first instruction of a function to indicate whether it should be inlined or not during vir...
Identifier< bool > IS_RETURN
Put on a control flow instruction, this shows that this instruction is equivalent to a function retur...
bool checksummed
Definition: FlowFactLoader.h:99
dfa::State * state
Definition: FlowFactLoader.h:105
static p::declare reg
Definition: FlowFactLoader.h:58
Feature< FlowFactLoader > MKFF_PRESERVATION_FEATURE
This feature ensures that preservation information used by mkff is put on instruction.
Identifier< Pair< Address, Address > > ACCESS_RANGE
Put on a memory access instruction, provides a range of possible accesses.
Identifier< bool > PRESERVED
Put on instruction that must preserved from the mkff special flow-fact detection. ...
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
bool lib
Definition: FlowFactLoader.h:106
Utility class representing an area in the memory defined by a base address and a size.
Definition: base.h:113
inst load(int d, int a, int t)
Definition: inst.h:153
The representation of an address in OTAWA.
Definition: base.h:54
Represents a value of the data state.
Definition: State.h:86
Identifier< xom::Element * > FLOW_FACTS_NODES
This property may be used in the configuration of a code processor to directly pass an xml element co...
genstruct::Vector< Path > paths
Definition: FlowFactLoader.h:100
dtd::RefAttr< BasicBlock * > target("target", dtd::STRICT|dtd::REQUIRED)
Identifier< bool > NO_CALL
Put on the first instruction of a function that must be no called.
Identifier< Path > FLOW_FACTS_PATH
This property may be used in the configuration of a code processor to pass the path of an flow fact f...
This class represents identifier with a typed associated value.
Definition: Identifier.h:51
cstring name
Definition: odisasm.cpp:107
Identifier< int > MAX_ITERATION
Put on the first instruction of a loop, it gives the maximum number of iteration of this loop...
void util_fft_error(otawa::FlowFactLoader *loader, const char *msg)
Definition: util_fft_parser.cpp:2056
This a list of properties.
Definition: PropList.h:63
Identifier< bool > IGNORE_ENTRY
Put on function symbol that must be ignored as function entry.
This class is used for returning exceptions from the processors.
Definition: ProcessorException.h:17
This class is an abstract class to monitor the load of flow facts.
Definition: FlowFactLoader.h:54
const Type & type(void)
Definition: type.h:163
Definition: State.h:37
This class describes the type of the data in the program.
Definition: type.h:39
Path current
Definition: FlowFactLoader.h:102
uint32_t uint32
A feature is a set of facilities, usually provided using properties, available on a framework...
Definition: Feature.h:46
Identifier< bool > NO_RETURN
This annotation is put on the first instruction of functions that does not never return.