[ClavaLaraApi] Removes commented code, adds comments
+/**
+ * Instruments an application so that it counts total operations in a region of code.
+ *
+ */
var OpsCounter = function() {
- // Initialize counters
this._counters = {};
this._$counterType = ClavaJoinPoints.builtinType("long");
-
-/*
- for(var counterName of OpsCounter._countersNames) {
- var newCounter = new GlobalVariable(counterName, $counterType, "0");
- this._counters[counterName] = newCounter;
- }
-*/
};
-//OpsCounter._countersNames = ["flops_counter", "iops_counter", "unknown_counter", "ops_counter", "flops_bits_counter", "iops_bits_counter"];
-
// Whitelist of ops
OpsCounter._validOps = new StringSet("mul", "div", "rem", "add", "sub", "shl", "shr", "cmp", "and", "xor", "or", "l_and", "l_or", "mul_assign", "div_assign", "rem_assign", "add_assign", "sub_assign", "shl_assign", "shr_assign", "and_assign", "xor_assign", "or_assign", "post_inc", "post_dec", "pre_inc", "pre_dec");
@@ -22,6 +16,8 @@ OpsCounter.prototype.instrument = function($region) {
for(var $op of Query.searchFrom($region, 'op')) {
this._countOp($op);
}
+
+ // TODO: Call function recursively when function calls are found
};
@@ -48,18 +44,8 @@ OpsCounter.prototype._countOp = function($op) {
var counter = this._getCounter(counterType, bitwidth);
// Add to corresponding counter type
- //var counterName = counterType + "_counter";
- //var counter = this._counters[counterName];
var counterStmt = ClavaJoinPoints.stmtLiteral(counter.getRef($op).code + "++;");
$op.insertBefore(counterStmt);
-
-
-
-
-
- //var bitsCounterName = counterType + "_bits_counter";
-
-
}
@@ -78,6 +64,7 @@ OpsCounter.prototype._getCounter = function(counterType, bitwidth) {
}
OpsCounter.prototype._getCounterPrefix = function(counterType, bitwidth) {
+
// If counterType is undefined, return unknown, without looking at the bitwidth
if(counterType === undefined) {
return "unknown";
