Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Public Member Functions | Public Attributes | Properties | Private Member Functions | Private Attributes | List of all members
miasm2.ir.ir.irbloc Class Reference
+ Inheritance diagram for miasm2.ir.ir.irbloc:
+ Collaboration diagram for miasm2.ir.ir.irbloc:

Public Member Functions

def __init__
 
def dst_linenb
 
def get_rw
 
def __str__
 

Public Attributes

 label
 
 irs
 
 lines
 
 except_automod
 
 r
 
 w
 
 cur_reach
 
 prev_reach
 
 cur_kill
 
 prev_kill
 
 defout
 

Properties

 dst = property(_get_dst, _set_dst)
 

Private Member Functions

def _get_dst
 
def _set_dst
 

Private Attributes

 _dst
 
 _dst_linenb
 

Detailed Description

Definition at line 30 of file ir.py.

Constructor & Destructor Documentation

def miasm2.ir.ir.irbloc.__init__ (   self,
  label,
  irs,
  lines = [] 
)

Definition at line 32 of file ir.py.

32 
33  def __init__(self, label, irs, lines = []):
34  assert(isinstance(label, asmbloc.asm_label))
35  self.label = label
36  self.irs = irs
37  self.lines = lines
38  self.except_automod = True
39  self._dst = None
40  self._dst_linenb = None
41 
def __init__
Definition: ir.py:32

Member Function Documentation

def miasm2.ir.ir.irbloc.__str__ (   self)

Definition at line 111 of file ir.py.

112  def __str__(self):
113  o = []
114  o.append('%s' % self.label)
115  for expr in self.irs:
116  for e in expr:
117  o.append('\t%s' % e)
118  o.append("")
119 
120  return "\n".join(o)
121 
def miasm2.ir.ir.irbloc._get_dst (   self)
private
Find the IRDst affectation and update dst, dst_linenb accordingly

Definition at line 42 of file ir.py.

42 
43  def _get_dst(self):
44  """Find the IRDst affectation and update dst, dst_linenb accordingly"""
45  if self._dst is not None:
46  return self._dst
47  dst = None
48  for linenb, ir in enumerate(self.irs):
49  for i in ir:
50  if isinstance(i.dst, m2_expr.ExprId) and i.dst.name == "IRDst":
51  if dst is not None:
52  raise ValueError('Multiple destinations!')
53  dst = i.src
54  dst_linenb = linenb
55  self._dst = dst
56  self._dst_linenb = linenb
57  return dst
def _get_dst
Definition: ir.py:42

+ Here is the caller graph for this function:

def miasm2.ir.ir.irbloc._set_dst (   self,
  value 
)
private
Find and replace the IRDst affectation's source by @value

Definition at line 58 of file ir.py.

58 
59  def _set_dst(self, value):
60  """Find and replace the IRDst affectation's source by @value"""
61  if self._dst_linenb is None:
62  self._get_dst()
63 
64  ir = self.irs[self._dst_linenb]
65  for i, expr in enumerate(ir):
66  if isinstance(expr.dst, m2_expr.ExprId) and expr.dst.name == "IRDst":
67  ir[i] = m2_expr.ExprAff(expr.dst, value)
68  self._dst = value
def _set_dst
Definition: ir.py:58
def _get_dst
Definition: ir.py:42

+ Here is the call graph for this function:

def miasm2.ir.ir.irbloc.dst_linenb (   self)
Line number of the IRDst setting statement in the current irs

Definition at line 72 of file ir.py.

72 
73  def dst_linenb(self):
74  """Line number of the IRDst setting statement in the current irs"""
75  return self._dst_linenb
def dst_linenb
Definition: ir.py:72
def miasm2.ir.ir.irbloc.get_rw (   self,
  regs_ids 
)
Computes the variables read and written by each instructions
Initialize attributes needed for in/out and reach computation.
@regs_ids : ids of registers used in IR

Definition at line 76 of file ir.py.

76 
77  def get_rw(self, regs_ids):
78  """
79  Computes the variables read and written by each instructions
80  Initialize attributes needed for in/out and reach computation.
81  @regs_ids : ids of registers used in IR
82  """
83  self.r = []
84  self.w = []
85  self.cur_reach = [{reg: set() for reg in regs_ids}
86  for _ in xrange(len(self.irs))]
87  self.prev_reach = [{reg: set() for reg in regs_ids}
88  for _ in xrange(len(self.irs))]
89  self.cur_kill = [{reg: set() for reg in regs_ids}
90  for _ in xrange(len(self.irs))]
91  self.prev_kill = [{reg: set() for reg in regs_ids}
92  for _ in xrange(len(self.irs))]
93  self.defout = [{reg: set() for reg in regs_ids}
94  for _ in xrange(len(self.irs))]
95 
96  for k, ir in enumerate(self.irs):
97  r, w = set(), set()
98  for i in ir:
99  r.update(x for x in i.get_r(True)
100  if isinstance(x, m2_expr.ExprId))
101  w.update(x for x in i.get_w()
102  if isinstance(x, m2_expr.ExprId))
103  if isinstance(i.dst, m2_expr.ExprMem):
104  r.update(x for x in i.dst.arg.get_r(True)
105  if isinstance(x, m2_expr.ExprId))
106  self.defout[k].update((x, {(self.label, k, i)})
107  for x in i.get_w()
108  if isinstance(x, m2_expr.ExprId))
109  self.r.append(r)
110  self.w.append(w)

+ Here is the caller graph for this function:

Member Data Documentation

miasm2.ir.ir.irbloc._dst
private

Definition at line 38 of file ir.py.

miasm2.ir.ir.irbloc._dst_linenb
private

Definition at line 39 of file ir.py.

miasm2.ir.ir.irbloc.cur_kill

Definition at line 88 of file ir.py.

miasm2.ir.ir.irbloc.cur_reach

Definition at line 84 of file ir.py.

miasm2.ir.ir.irbloc.defout

Definition at line 92 of file ir.py.

miasm2.ir.ir.irbloc.except_automod

Definition at line 37 of file ir.py.

miasm2.ir.ir.irbloc.irs

Definition at line 35 of file ir.py.

miasm2.ir.ir.irbloc.label

Definition at line 34 of file ir.py.

miasm2.ir.ir.irbloc.lines

Definition at line 36 of file ir.py.

miasm2.ir.ir.irbloc.prev_kill

Definition at line 90 of file ir.py.

miasm2.ir.ir.irbloc.prev_reach

Definition at line 86 of file ir.py.

miasm2.ir.ir.irbloc.r

Definition at line 82 of file ir.py.

miasm2.ir.ir.irbloc.w

Definition at line 83 of file ir.py.

Property Documentation

miasm2.ir.ir.irbloc.dst = property(_get_dst, _set_dst)
static

Definition at line 69 of file ir.py.


The documentation for this class was generated from the following file: