summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunyan He <junyan.he@linux.intel.com>2015-11-17 07:40:07 +0800
committerYang Rong <rong.r.yang@intel.com>2015-11-17 16:23:21 +0800
commitd7004d26d0c842cd303cd9aa03fb4e14388fdec9 (patch)
treefc7d93090f71758957b57c0a38e78f116ede063d
parent47b9cca14be0c69c77b12bc4f467dbcab49b4b15 (diff)
Backend: Add ProfilingInfo to Unit.
The Unit will hold profiling infomation. The profiling infomation may be needed throughout the whole backend processing, so it is suitable to add it to unit. Signed-off-by: Junyan He <junyan.he@linux.intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--backend/src/ir/unit.cpp6
-rw-r--r--backend/src/ir/unit.hpp10
2 files changed, 15 insertions, 1 deletions
diff --git a/backend/src/ir/unit.cpp b/backend/src/ir/unit.cpp
index 84208e57..56042446 100644
--- a/backend/src/ir/unit.cpp
+++ b/backend/src/ir/unit.cpp
@@ -27,9 +27,13 @@
namespace gbe {
namespace ir {
- Unit::Unit(PointerSize pointerSize) : pointerSize(pointerSize), valid(true) {}
+ Unit::Unit(PointerSize pointerSize) : pointerSize(pointerSize), valid(true) {
+ profilingInfo = GBE_NEW(ProfilingInfo);
+ inProfilingMode = false;
+ }
Unit::~Unit(void) {
for (const auto &pair : functions) GBE_DELETE(pair.second);
+ delete profilingInfo;
}
Function *Unit::getFunction(const std::string &name) const {
auto it = functions.find(name);
diff --git a/backend/src/ir/unit.hpp b/backend/src/ir/unit.hpp
index 8ff858d6..41dc1aee 100644
--- a/backend/src/ir/unit.hpp
+++ b/backend/src/ir/unit.hpp
@@ -26,6 +26,7 @@
#include "ir/constant.hpp"
#include "ir/register.hpp"
+#include "ir/profiling.hpp"
#include "sys/map.hpp"
namespace gbe {
@@ -33,6 +34,7 @@ namespace ir {
// A unit contains a set of functions
class Function;
+ class ProfilingInfo;
/*! Complete unit of compilation. It contains a set of functions and a set of
* constant the functions may refer to.
@@ -72,6 +74,12 @@ namespace ir {
ConstantSet& getConstantSet(void) { return constantSet; }
/*! Return the constant set */
const ConstantSet& getConstantSet(void) const { return constantSet; }
+ /*! Get profiling info in this function */
+ ProfilingInfo* getProfilingInfo(void) const { return profilingInfo; }
+ /*! Set in profiling mode */
+ void setInProfilingMode(bool b) { inProfilingMode = b; }
+ /*! Get in profiling mode */
+ bool getInProfilingMode(void) const { return inProfilingMode; }
void setValid(bool value) { valid = value; }
bool getValid() { return valid; }
private:
@@ -79,8 +87,10 @@ namespace ir {
FunctionSet functions; //!< All the defined functions
ConstantSet constantSet; //!< All the constants defined in the unit
PointerSize pointerSize; //!< Size shared by all pointers
+ ProfilingInfo *profilingInfo; //!< profilingInfo store the information for profiling.
GBE_CLASS(Unit);
bool valid;
+ bool inProfilingMode;
};
/*! Output the unit string in the given stream */