about summary refs log tree commit diff stats
path: root/miasm2/ir/analysis.py
diff options
context:
space:
mode:
Diffstat (limited to 'miasm2/ir/analysis.py')
-rw-r--r--miasm2/ir/analysis.py41
1 files changed, 22 insertions, 19 deletions
diff --git a/miasm2/ir/analysis.py b/miasm2/ir/analysis.py
index 73391bb2..4f7b321f 100644
--- a/miasm2/ir/analysis.py
+++ b/miasm2/ir/analysis.py
@@ -2,8 +2,8 @@
 
 import logging
 
-from miasm2.ir.symbexec import symbexec
-from miasm2.ir.ir import ir, AssignBlock
+from miasm2.ir.symbexec import SymbolicExecutionEngine
+from miasm2.ir.ir import IntermediateRepresentation, AssignBlock
 from miasm2.expression.expression \
     import ExprAff, ExprCond, ExprId, ExprInt, ExprMem, ExprOp
 
@@ -14,14 +14,17 @@ log.addHandler(console_handler)
 log.setLevel(logging.WARNING)
 
 
-class ira(ir):
+class ira(IntermediateRepresentation):
     """IR Analysis
     This class provides higher level manipulations on IR, such as dead
     instruction removals.
 
-    This class can be used as a common parent with `miasm2.ir.ir::ir` class.
+    This class can be used as a common parent with
+    `miasm2.ir.ir::IntermediateRepresentation` class.
+
     For instance:
         class ira_x86_16(ir_x86_16, ira)
+
     """
 
     def ira_regs_ids(self):
@@ -84,14 +87,14 @@ class ira(ir):
         useful = set()
 
         for node in self.graph.nodes():
-            if node not in self.blocs:
+            if node not in self.blocks:
                 continue
 
-            block = self.blocs[node]
+            block = self.blocks[node]
             successors = self.graph.successors(node)
             has_son = bool(successors)
             for p_son in successors:
-                if p_son not in self.blocs:
+                if p_son not in self.blocks:
                     # Leaf has lost its son: don't remove anything
                     # reaching this block
                     for r in self.ira_regs_ids():
@@ -136,7 +139,7 @@ class ira(ir):
             useful.add(elem)
             irb_label, irs_ind, dst = elem
 
-            assignblk = self.blocs[irb_label].irs[irs_ind]
+            assignblk = self.blocks[irb_label].irs[irs_ind]
             ins = assignblk.dst2ExprAff(dst)
 
             # Handle dependencies of used variables in ins
@@ -161,10 +164,10 @@ class ira(ir):
         """
         useful = self._mark_useful_code()
         modified = False
-        for block in self.blocs.values():
-            modified |= self.remove_dead_instr(block, useful)
+        for irblock in self.blocks.values():
+            modified |= self.remove_dead_instr(irblock, useful)
             # Remove useless structures
-            for assignblk in block.irs:
+            for assignblk in irblock.irs:
                 del assignblk._cur_kill
                 del assignblk._prev_kill
                 del assignblk._cur_reach
@@ -214,7 +217,7 @@ class ira(ir):
 
         # Compute reach from predecessors
         for n_pred in self.graph.predecessors(irb.label):
-            p_block = self.blocs[n_pred]
+            p_block = self.blocks[n_pred]
 
             # Handle each register definition
             for c_reg in self.ira_regs_ids():
@@ -253,8 +256,8 @@ class ira(ir):
 
         fixed = True
         for node in self.graph.nodes():
-            if node in self.blocs:
-                irb = self.blocs[node]
+            if node in self.blocks:
+                irb = self.blocks[node]
                 for assignblk in irb.irs:
                     if (assignblk._cur_reach != assignblk._prev_reach or
                             assignblk._cur_kill != assignblk._prev_kill):
@@ -276,8 +279,8 @@ class ira(ir):
         log.debug('iteration...')
         while not fixed_point:
             for node in self.graph.nodes():
-                if node in self.blocs:
-                    self.compute_reach_block(self.blocs[node])
+                if node in self.blocks:
+                    self.compute_reach_block(self.blocks[node])
             fixed_point = self._test_kill_reach_fix()
 
     def dead_simp(self):
@@ -288,7 +291,7 @@ class ira(ir):
         Source : Kennedy, K. (1979). A survey of data flow analysis techniques.
         IBM Thomas J. Watson Research Division, page 43
         """
-        # Update r/w variables for all irblocs
+        # Update r/w variables for all irblocks
         self.get_rw(self.ira_regs_ids())
         # Liveness step
         self.compute_reach()
@@ -297,10 +300,10 @@ class ira(ir):
         self.simplify_blocs()
 
     def gen_equations(self):
-        for irb in self.blocs.values():
+        for irb in self.blocks.values():
             symbols_init = dict(self.arch.regs.all_regs_ids_init)
 
-            sb = symbexec(self, dict(symbols_init))
+            sb = SymbolicExecutionEngine(self, dict(symbols_init))
             sb.emulbloc(irb)
             eqs = []
             for n_w in sb.symbols: