-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtimeStmt.py
38 lines (31 loc) · 1.29 KB
/
timeStmt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pyvex
class Time(pyvex.stmt.IRStmt):
"""
An expression to keep track of execution time
"""
__slots__ = ['instruction', 'dependsOn', 'keyStatement', 'instructionAddress']
class surrogate_c_stmt(object):
def __init__(self):
self.tag = 0
def __init__(self, irsb, instruction, keyStatement, instructionAddress):
c_stmt = self.surrogate_c_stmt()
pyvex.stmt.IRStmt.__init__(self, c_stmt, irsb)
self.arch = irsb.arch
self.tag = 'Ist_Time'
self.instruction = instruction
self.dependsOn = 4 #listOfRegisters/Temps/constants/simExpressions?
self.keyStatement = keyStatement
self.instructionAddress = instructionAddress
def __str__(self):
return "+++++ Timing (%s) +++++" % (self.instruction)
@staticmethod
#maybe we can circumvent the tag hack with the surrogate statement by not relying on the tagtoclass function but instead just using the TimedSimIRSB constructor
def _translate(c_stmt, irsb):
if c_stmt[0] == ffi.NULL:
return None
tag = c_stmt.tag
try:
stmt_class = _tag_to_class[tag]
except KeyError:
raise PyVEXError('Unknown/unsupported IRStmtTag %s\n' % ints_to_enums[tag])
return stmt_class(c_stmt, irsb)