diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2017-02-14 16:32:54 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2017-03-13 13:56:26 +0100 |
| commit | b9c87b0e9167940fbbadf0f642e07ee9d7a678e5 (patch) | |
| tree | 44af3f4626074209c650e2efee9e003e11346422 | |
| parent | d8cbc059655bd275b5e178b2339b931d9f0b126a (diff) | |
| download | miasm-b9c87b0e9167940fbbadf0f642e07ee9d7a678e5.tar.gz miasm-b9c87b0e9167940fbbadf0f642e07ee9d7a678e5.zip | |
IR/ir: rename irbloc to IRBlock
| -rw-r--r-- | miasm2/analysis/depgraph.py | 6 | ||||
| -rw-r--r-- | miasm2/arch/arm/sem.py | 4 | ||||
| -rw-r--r-- | miasm2/arch/mips32/ira.py | 4 | ||||
| -rw-r--r-- | miasm2/arch/mips32/sem.py | 4 | ||||
| -rw-r--r-- | miasm2/arch/x86/sem.py | 40 | ||||
| -rw-r--r-- | miasm2/core/sembuilder.py | 8 | ||||
| -rw-r--r-- | miasm2/ir/ir.py | 43 | ||||
| -rw-r--r-- | miasm2/jitter/codegen.py | 4 | ||||
| -rw-r--r-- | test/analysis/depgraph.py | 168 | ||||
| -rw-r--r-- | test/ir/analysis.py | 314 |
10 files changed, 309 insertions, 286 deletions
diff --git a/miasm2/analysis/depgraph.py b/miasm2/analysis/depgraph.py index 50e9dcf8..f2e87c41 100644 --- a/miasm2/analysis/depgraph.py +++ b/miasm2/analysis/depgraph.py @@ -5,7 +5,7 @@ from miasm2.core.graph import DiGraph from miasm2.core.asmbloc import asm_label, expr_is_int_or_label, expr_is_label from miasm2.expression.simplifications import expr_simp from miasm2.ir.symbexec import SymbolicExecutionEngine -from miasm2.ir.ir import irbloc, AssignBlock +from miasm2.ir.ir import IRBlock, AssignBlock from miasm2.ir.translators import Translator from miasm2.expression.expression_helper import possible_values @@ -270,7 +270,7 @@ class DependencyResult(DependencyState): assignblk[element] = irb.irs[line_nb][element] assignblks.append(assignblk) - return irbloc(irb.label, assignblks) + return IRBlock(irb.label, assignblks) def emul(self, ctx=None, step=False): """Symbolic execution of relevant nodes according to the history @@ -299,7 +299,7 @@ class DependencyResult(DependencyState): # Eval the block temp_label = asm_label("Temp") symb_exec = SymbolicExecutionEngine(self._ira, ctx_init) - symb_exec.emulbloc(irbloc(temp_label, assignblks), step=step) + symb_exec.emulbloc(IRBlock(temp_label, assignblks), step=step) # Return only inputs values (others could be wrongs) return {element: symb_exec.symbols[element] diff --git a/miasm2/arch/arm/sem.py b/miasm2/arch/arm/sem.py index 225b393c..742032e6 100644 --- a/miasm2/arch/arm/sem.py +++ b/miasm2/arch/arm/sem.py @@ -1,5 +1,5 @@ from miasm2.expression.expression import * -from miasm2.ir.ir import ir, irbloc +from miasm2.ir.ir import ir, IRBlock from miasm2.arch.arm.arch import mn_arm, mn_armt from miasm2.arch.arm.regs import * @@ -1055,7 +1055,7 @@ def add_condition_expr(ir, instr, cond, instr_ir): break if not has_irdst: instr_ir.append(ExprAff(ir.IRDst, lbl_next)) - e_do = irbloc(lbl_do.name, [instr_ir]) + e_do = IRBlock(lbl_do.name, [instr_ir]) e = [ExprAff(ir.IRDst, dst_cond)] return e, [e_do] diff --git a/miasm2/arch/mips32/ira.py b/miasm2/arch/mips32/ira.py index 8f7b2df3..6efbf8ae 100644 --- a/miasm2/arch/mips32/ira.py +++ b/miasm2/arch/mips32/ira.py @@ -1,7 +1,7 @@ #-*- coding:utf-8 -*- from miasm2.expression.expression import * -from miasm2.ir.ir import ir, irbloc, AssignBlock +from miasm2.ir.ir import ir, IRBlock, AssignBlock from miasm2.ir.analysis import ira from miasm2.arch.mips32.sem import ir_mips32l, ir_mips32b from miasm2.arch.mips32.regs import * @@ -47,7 +47,7 @@ class ir_a_mips32l(ir_mips32l, ira): irs = self.call_effects(pc_val, l) irs.append(AssignBlock([ExprAff(self.IRDst, ExprId(lbl, size=self.pc.size))])) - nbloc = irbloc(new_lbl, irs) + nbloc = IRBlock(new_lbl, irs) nbloc.lines = [l] * len(irs) self.blocs[new_lbl] = nbloc irb.dst = ExprId(new_lbl, size=self.pc.size) diff --git a/miasm2/arch/mips32/sem.py b/miasm2/arch/mips32/sem.py index b52b8401..74ad4f3e 100644 --- a/miasm2/arch/mips32/sem.py +++ b/miasm2/arch/mips32/sem.py @@ -1,5 +1,5 @@ import miasm2.expression.expression as m2_expr -from miasm2.ir.ir import ir, irbloc +from miasm2.ir.ir import ir, IRBlock from miasm2.arch.mips32.arch import mn_mips32 from miasm2.arch.mips32.regs import R_LO, R_HI, PC, RA from miasm2.core.sembuilder import SemBuilder @@ -468,7 +468,7 @@ class ir_mips32l(ir): if c is None: # print 'new c' label = self.get_label(l) - c = irbloc(label, [], []) + c = IRBlock(label, [], []) ir_blocs_all.append(c) bloc_dst = None # print 'Translate', l diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 18a1421e..50faf557 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -21,7 +21,7 @@ from miasm2.expression.simplifications import expr_simp from miasm2.arch.x86.regs import * from miasm2.arch.x86.arch import mn_x86, repeat_mn, replace_regs from miasm2.expression.expression_helper import expr_cmps, expr_cmpu -from miasm2.ir.ir import ir, irbloc +from miasm2.ir.ir import ir, IRBlock from miasm2.core.sembuilder import SemBuilder import math import struct @@ -277,7 +277,7 @@ def gen_fcmov(ir, instr, cond, arg1, arg2, mov_if): e_do, extra_irs = [m2_expr.ExprAff(arg1, arg2)], [] e_do.append(m2_expr.ExprAff(ir.IRDst, lbl_skip)) e.append(m2_expr.ExprAff(ir.IRDst, m2_expr.ExprCond(cond, dstA, dstB))) - return e, [irbloc(lbl_do.name, [e_do])] + return e, [IRBlock(lbl_do.name, [e_do])] def gen_cmov(ir, instr, cond, dst, src, mov_if): @@ -297,7 +297,7 @@ def gen_cmov(ir, instr, cond, dst, src, mov_if): e_do, extra_irs = mov(ir, instr, dst, src) e_do.append(m2_expr.ExprAff(ir.IRDst, lbl_skip)) e.append(m2_expr.ExprAff(ir.IRDst, m2_expr.ExprCond(cond, dstA, dstB))) - return e, [irbloc(lbl_do.name, [e_do])] + return e, [IRBlock(lbl_do.name, [e_do])] def mov(_, instr, dst, src): @@ -518,7 +518,7 @@ def _rotate_tpl(ir, instr, dst, src, op, left=False, include_cf=False): e_do.append(m2_expr.ExprAff(ir.IRDst, lbl_skip)) e.append(m2_expr.ExprAff( ir.IRDst, m2_expr.ExprCond(shifter, lbl_do, lbl_skip))) - return (e, [irbloc(lbl_do.name, [e_do])]) + return (e, [IRBlock(lbl_do.name, [e_do])]) def l_rol(ir, instr, dst, src): @@ -615,7 +615,7 @@ def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None, left=False, e_do.append(m2_expr.ExprAff(ir.IRDst, lbl_skip)) e.append(m2_expr.ExprAff(ir.IRDst, m2_expr.ExprCond(shifter, lbl_do, lbl_skip))) - return e, [irbloc(lbl_do.name, [e_do])] + return e, [IRBlock(lbl_do.name, [e_do])] def sar(ir, instr, dst, src): @@ -963,7 +963,7 @@ def cmps(ir, instr, size): e0.append(m2_expr.ExprAff(b.arg, b.arg + m2_expr.ExprInt(size / 8, b.arg.size))) e0.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e0 = irbloc(lbl_df_0.name, [e0]) + e0 = IRBlock(lbl_df_0.name, [e0]) e1 = [] e1.append(m2_expr.ExprAff(a.arg, @@ -971,7 +971,7 @@ def cmps(ir, instr, size): e1.append(m2_expr.ExprAff(b.arg, b.arg - m2_expr.ExprInt(size / 8, b.arg.size))) e1.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e1 = irbloc(lbl_df_1.name, [e1]) + e1 = IRBlock(lbl_df_1.name, [e1]) e.append(m2_expr.ExprAff(ir.IRDst, m2_expr.ExprCond(df, lbl_df_1, lbl_df_0))) @@ -992,13 +992,13 @@ def scas(ir, instr, size): e0.append(m2_expr.ExprAff(a.arg, a.arg + m2_expr.ExprInt(size / 8, a.arg.size))) e0.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e0 = irbloc(lbl_df_0.name, [e0]) + e0 = IRBlock(lbl_df_0.name, [e0]) e1 = [] e1.append(m2_expr.ExprAff(a.arg, a.arg - m2_expr.ExprInt(size / 8, a.arg.size))) e1.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e1 = irbloc(lbl_df_1.name, [e1]) + e1 = IRBlock(lbl_df_1.name, [e1]) e.append(m2_expr.ExprAff(ir.IRDst, m2_expr.ExprCond(df, lbl_df_1, lbl_df_0))) @@ -1641,12 +1641,12 @@ def stos(ir, instr, size): e0 = [] e0.append(m2_expr.ExprAff(addr_o, addr_p)) e0.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e0 = irbloc(lbl_df_0.name, [e0]) + e0 = IRBlock(lbl_df_0.name, [e0]) e1 = [] e1.append(m2_expr.ExprAff(addr_o, addr_m)) e1.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e1 = irbloc(lbl_df_1.name, [e1]) + e1 = IRBlock(lbl_df_1.name, [e1]) e = [] e.append(m2_expr.ExprAff(ir.ExprMem(addr, size), b)) @@ -1676,12 +1676,12 @@ def lods(ir, instr, size): e0 = [] e0.append(m2_expr.ExprAff(addr_o, addr_p)) e0.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e0 = irbloc(lbl_df_0.name, [e0]) + e0 = IRBlock(lbl_df_0.name, [e0]) e1 = [] e1.append(m2_expr.ExprAff(addr_o, addr_m)) e1.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e1 = irbloc(lbl_df_1.name, [e1]) + e1 = IRBlock(lbl_df_1.name, [e1]) e = [] if instr.mode == 64 and b.size == 32: @@ -1718,13 +1718,13 @@ def movs(ir, instr, size): e0.append(m2_expr.ExprAff(a, a + m2_expr.ExprInt(size / 8, a.size))) e0.append(m2_expr.ExprAff(b, b + m2_expr.ExprInt(size / 8, b.size))) e0.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e0 = irbloc(lbl_df_0.name, [e0]) + e0 = IRBlock(lbl_df_0.name, [e0]) e1 = [] e1.append(m2_expr.ExprAff(a, a - m2_expr.ExprInt(size / 8, a.size))) e1.append(m2_expr.ExprAff(b, b - m2_expr.ExprInt(size / 8, b.size))) e1.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - e1 = irbloc(lbl_df_1.name, [e1]) + e1 = IRBlock(lbl_df_1.name, [e1]) e.append(m2_expr.ExprAff(ir.IRDst, m2_expr.ExprCond(df, lbl_df_1, lbl_df_0))) @@ -2758,8 +2758,8 @@ def bsr_bsf(ir, instr, dst, src, op_name): e_src_not_null.append(m2_expr.ExprAff(dst, m2_expr.ExprOp(op_name, src))) e_src_not_null.append(aff_dst) - return e, [irbloc(lbl_src_null.name, [e_src_null]), - irbloc(lbl_src_not_null.name, [e_src_not_null])] + return e, [IRBlock(lbl_src_null.name, [e_src_null]), + IRBlock(lbl_src_not_null.name, [e_src_not_null])] def bsf(ir, instr, dst, src): @@ -3655,7 +3655,7 @@ def ps_rl_ll(ir, instr, dst, src, op, size): e_do = [] e.append(m2_expr.ExprAff(dst[0:dst.size], m2_expr.ExprCompose(*slices))) e_do.append(m2_expr.ExprAff(ir.IRDst, lbl_next)) - return e, [irbloc(lbl_do.name, [e_do]), irbloc(lbl_zero.name, [e_zero])] + return e, [IRBlock(lbl_do.name, [e_do]), IRBlock(lbl_zero.name, [e_zero])] def psrlw(ir, instr, dst, src): @@ -4583,10 +4583,10 @@ class ir_x86_16(ir): cond_bloc.append(m2_expr.ExprAff(self.IRDst, m2_expr.ExprCond(c_cond, lbl_skip, lbl_do))) - cond_bloc = irbloc(lbl_end.name, [cond_bloc]) + cond_bloc = IRBlock(lbl_end.name, [cond_bloc]) e_do = instr_ir - c = irbloc(lbl_do.name, [e_do]) + c = IRBlock(lbl_do.name, [e_do]) c.except_automod = False e_n = [m2_expr.ExprAff(self.IRDst, m2_expr.ExprCond(c_reg, lbl_do, lbl_skip))] diff --git a/miasm2/core/sembuilder.py b/miasm2/core/sembuilder.py index 6ff390bb..f101d94c 100644 --- a/miasm2/core/sembuilder.py +++ b/miasm2/core/sembuilder.py @@ -5,7 +5,7 @@ import ast import re import miasm2.expression.expression as m2_expr -from miasm2.ir.ir import irbloc +from miasm2.ir.ir import IRBlock class MiasmTransformer(ast.NodeTransformer): @@ -125,7 +125,7 @@ class SemBuilder(object): # Init self.transformer = MiasmTransformer() self._ctx = dict(m2_expr.__dict__) - self._ctx["irbloc"] = irbloc + self._ctx["IRBlock"] = IRBlock self._functions = {} # Update context @@ -250,12 +250,12 @@ class SemBuilder(object): sub_blocks[-1] = ast.List(elts=sub_blocks[-1], ctx=ast.Load()) - ## Replace the block with a call to 'irbloc' + ## Replace the block with a call to 'IRBlock' lbl_if_name = ast.Attribute(value=ast.Name(id=lbl_name, ctx=ast.Load()), attr='name', ctx=ast.Load()) - sub_blocks[-1] = ast.Call(func=ast.Name(id='irbloc', + sub_blocks[-1] = ast.Call(func=ast.Name(id='IRBlock', ctx=ast.Load()), args=[lbl_if_name, sub_blocks[-1]], diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py index 0a7d68ce..b06a8136 100644 --- a/miasm2/ir/ir.py +++ b/miasm2/ir/ir.py @@ -17,6 +17,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # +import warnings + from itertools import chain import miasm2.expression.expression as m2_expr @@ -95,7 +97,7 @@ class AssignBlock(dict): # Build the merging expression args = list(e_colision.union(remaining)) - args.sort(key=lambda x:x[1]) + args.sort(key=lambda x: x[1]) starts = [start for (_, start, _) in args] assert len(set(starts)) == len(starts) args = [expr for (expr, _, _) in args] @@ -108,7 +110,7 @@ class AssignBlock(dict): """Return an Expr list of extra expressions needed during the object instanciation""" if not isinstance(src, m2_expr.ExprCompose): - raise ValueError("Get mod slice not on expraff slice", str(self)) + raise ValueError("Get mod slice not on expraff slice", str(src)) modified_s = [] for index, arg in src.iter_args(): if not (isinstance(arg, m2_expr.ExprSlice) and @@ -160,10 +162,20 @@ class AssignBlock(dict): return m2_expr.ExprAff(dst, self[dst]) -class irbloc(object): +class IRBlock(object): + """Intermediate representation block object. + + Stand for an intermediate representation basic block. + """ def __init__(self, label, irs, lines=None): - assert(isinstance(label, asm_label)) + """ + @label: asm_label of the IR basic block + @irs: list of AssignBlock + @lines: list of native instructions + """ + + assert isinstance(label, asm_label) if lines is None: lines = [] self.label = label @@ -196,7 +208,7 @@ class irbloc(object): assignblk = self.irs[self._dst_linenb] for dst in assignblk: if isinstance(dst, m2_expr.ExprId) and dst.name == "IRDst": - del(assignblk[dst]) + del assignblk[dst] assignblk[dst] = value # Sanity check is already done in _get_dst break @@ -240,6 +252,17 @@ class irbloc(object): return "\n".join(out) +class irbloc(IRBlock): + """ + DEPRECATED object + Use IRBlock instead of irbloc + """ + + def __init__(self, label, irs, lines=None): + warnings.warn('DEPRECATION WARNING: use "IRBlock" instead of "irblock"') + super(irbloc, self).__init__(label, irs, lines) + + class DiGraphIR(DiGraph): """DiGraph for IR instances""" @@ -330,7 +353,7 @@ class ir(object): ad = ad.name if isinstance(ad, m2_expr.ExprInt): ad = int(ad) - if type(ad) in [int, long]: + if isinstance(ad, (int, long)): ad = self.symbol_pool.getby_offset_create(ad) elif isinstance(ad, asm_label): ad = self.symbol_pool.getby_name_create(ad.name) @@ -360,7 +383,7 @@ class ir(object): c.irs.append(AssignBlock([m2_expr.ExprAff(self.pc, m2_expr.ExprInt(l.offset, self.pc.size) - )])) + )])) c.lines.append(l) def pre_add_instr(self, block, instr, irb_cur, ir_blocks_all, gen_pc_updt): @@ -413,7 +436,7 @@ class ir(object): irb_cur = None return irb_cur - def add_bloc(self, block, gen_pc_updt = False): + def add_bloc(self, block, gen_pc_updt=False): """ Add a native block to the current IR @block: native assembly block @@ -425,7 +448,7 @@ class ir(object): for instr in block.lines: if irb_cur is None: label = self.get_instr_label(instr) - irb_cur = irbloc(label, [], []) + irb_cur = IRBlock(label, [], []) ir_blocks_all.append(irb_cur) irb_cur = self.add_instr_to_irblock(block, instr, irb_cur, ir_blocks_all, gen_pc_updt) @@ -522,7 +545,7 @@ class ir(object): dst = todo.pop() if expr_is_label(dst): done.add(dst) - elif isinstance(dst, m2_expr.ExprMem) or isinstance(dst, m2_expr.ExprInt): + elif isinstance(dst, (m2_expr.ExprMem, m2_expr.ExprInt)): done.add(dst) elif isinstance(dst, m2_expr.ExprCond): todo.add(dst.src1) diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py index 2503e104..d5d8204f 100644 --- a/miasm2/jitter/codegen.py +++ b/miasm2/jitter/codegen.py @@ -1,5 +1,5 @@ import miasm2.expression.expression as m2_expr -from miasm2.ir.ir import irbloc +from miasm2.ir.ir import IRBlock from miasm2.ir.translators import Translator from miasm2.core.asmbloc import expr_is_label, asm_block_bad, asm_label @@ -134,7 +134,7 @@ class CGen(object): instr.offset + instr.l, self.ir_arch.IRDst.size) - return irbloc(self.ir_arch.get_instr_label(instr), [assignblk]) + return IRBlock(self.ir_arch.get_instr_label(instr), [assignblk]) def block2assignblks(self, block): irblocks_list = [] diff --git a/test/analysis/depgraph.py b/test/analysis/depgraph.py index 0b8d97b6..e0407fdb 100644 --- a/test/analysis/depgraph.py +++ b/test/analysis/depgraph.py @@ -3,7 +3,7 @@ from miasm2.expression.expression import ExprId, ExprInt32, ExprAff, ExprCond, \ ExprInt from miasm2.core.asmbloc import asm_label from miasm2.ir.analysis import ira -from miasm2.ir.ir import ir, irbloc, AssignBlock +from miasm2.ir.ir import ir, IRBlock, AssignBlock from miasm2.core.graph import DiGraph from miasm2.analysis.depgraph import DependencyNode, DependencyGraph from itertools import count @@ -50,7 +50,7 @@ LBL4 = asm_label("lbl4") LBL5 = asm_label("lbl5") LBL6 = asm_label("lbl6") -def gen_irbloc(label, exprs_list): +def gen_irblock(label, exprs_list): """ Returns an IRBlock with empty lines. Used only for tests purpose """ @@ -62,7 +62,7 @@ def gen_irbloc(label, exprs_list): else: irs.append(AssignBlock(exprs)) - irbl = irbloc(label, irs, lines) + irbl = IRBlock(label, irs, lines) return irbl @@ -232,9 +232,9 @@ DNC3 = DependencyNode(LBL1, C, 0) G1_IRA = IRATest() -G1_IRB0 = gen_irbloc(LBL0, [[ExprAff(C, CST1)]]) -G1_IRB1 = gen_irbloc(LBL1, [[ExprAff(B, C)]]) -G1_IRB2 = gen_irbloc(LBL2, [[ExprAff(A, B)]]) +G1_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) +G1_IRB1 = gen_irblock(LBL1, [[ExprAff(B, C)]]) +G1_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B)]]) G1_IRA.graph.add_uniq_edge(G1_IRB0.label, G1_IRB1.label) G1_IRA.graph.add_uniq_edge(G1_IRB1.label, G1_IRB2.label) @@ -245,9 +245,9 @@ G1_IRA.blocs = dict([(irb.label, irb) for irb in [G1_IRB0, G1_IRB1, G1_IRB2]]) G2_IRA = IRATest() -G2_IRB0 = gen_irbloc(LBL0, [[ExprAff(C, CST1)]]) -G2_IRB1 = gen_irbloc(LBL1, [[ExprAff(B, CST2)]]) -G2_IRB2 = gen_irbloc(LBL2, [[ExprAff(A, B + C)]]) +G2_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) +G2_IRB1 = gen_irblock(LBL1, [[ExprAff(B, CST2)]]) +G2_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B + C)]]) G2_IRA.graph.add_uniq_edge(G2_IRB0.label, G2_IRB1.label) G2_IRA.graph.add_uniq_edge(G2_IRB1.label, G2_IRB2.label) @@ -259,10 +259,10 @@ G2_IRA.blocs = dict([(irb.label, irb) for irb in [G2_IRB0, G2_IRB1, G2_IRB2]]) G3_IRA = IRATest() -G3_IRB0 = gen_irbloc(LBL0, [[ExprAff(C, CST1)]]) -G3_IRB1 = gen_irbloc(LBL1, [[ExprAff(B, CST2)]]) -G3_IRB2 = gen_irbloc(LBL2, [[ExprAff(B, CST3)]]) -G3_IRB3 = gen_irbloc(LBL3, [[ExprAff(A, B + C)]]) +G3_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) +G3_IRB1 = gen_irblock(LBL1, [[ExprAff(B, CST2)]]) +G3_IRB2 = gen_irblock(LBL2, [[ExprAff(B, CST3)]]) +G3_IRB3 = gen_irblock(LBL3, [[ExprAff(A, B + C)]]) G3_IRA.graph.add_uniq_edge(G3_IRB0.label, G3_IRB1.label) G3_IRA.graph.add_uniq_edge(G3_IRB0.label, G3_IRB2.label) @@ -276,13 +276,13 @@ G3_IRA.blocs = dict([(irb.label, irb) for irb in [G3_IRB0, G3_IRB1, G4_IRA = IRATest() -G4_IRB0 = gen_irbloc(LBL0, [[ExprAff(C, CST1)]]) -G4_IRB1 = gen_irbloc(LBL1, [[ExprAff(C, C + CST2)], - [ExprAff(G4_IRA.IRDst, - ExprCond(C, ExprId(LBL2), - ExprId(LBL1)))]]) +G4_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) +G4_IRB1 = gen_irblock(LBL1, [[ExprAff(C, C + CST2)], + [ExprAff(G4_IRA.IRDst, + ExprCond(C, ExprId(LBL2), + ExprId(LBL1)))]]) -G4_IRB2 = gen_irbloc(LBL2, [[ExprAff(A, B)]]) +G4_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B)]]) G4_IRA.graph.add_uniq_edge(G4_IRB0.label, G4_IRB1.label) G4_IRA.graph.add_uniq_edge(G4_IRB1.label, G4_IRB2.label) @@ -295,13 +295,13 @@ G4_IRA.blocs = dict([(irb.label, irb) for irb in [G4_IRB0, G4_IRB1, G4_IRB2]]) G5_IRA = IRATest() -G5_IRB0 = gen_irbloc(LBL0, [[ExprAff(B, CST1)]]) -G5_IRB1 = gen_irbloc(LBL1, [[ExprAff(B, B + CST2)], - [ExprAff(G5_IRA.IRDst, - ExprCond(B, ExprId(LBL2), - ExprId(LBL1)))]]) +G5_IRB0 = gen_irblock(LBL0, [[ExprAff(B, CST1)]]) +G5_IRB1 = gen_irblock(LBL1, [[ExprAff(B, B + CST2)], + [ExprAff(G5_IRA.IRDst, + ExprCond(B, ExprId(LBL2), + ExprId(LBL1)))]]) -G5_IRB2 = gen_irbloc(LBL2, [[ExprAff(A, B)]]) +G5_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B)]]) G5_IRA.graph.add_uniq_edge(G5_IRB0.label, G5_IRB1.label) G5_IRA.graph.add_uniq_edge(G5_IRB1.label, G5_IRB2.label) @@ -313,8 +313,8 @@ G5_IRA.blocs = dict([(irb.label, irb) for irb in [G5_IRB0, G5_IRB1, G5_IRB2]]) G6_IRA = IRATest() -G6_IRB0 = gen_irbloc(LBL0, [[ExprAff(B, CST1)]]) -G6_IRB1 = gen_irbloc(LBL1, [[ExprAff(A, B)]]) +G6_IRB0 = gen_irblock(LBL0, [[ExprAff(B, CST1)]]) +G6_IRB1 = gen_irblock(LBL1, [[ExprAff(A, B)]]) G6_IRA.graph.add_uniq_edge(G6_IRB0.label, G6_IRB1.label) G6_IRA.graph.add_uniq_edge(G6_IRB1.label, G6_IRB1.label) @@ -325,9 +325,9 @@ G6_IRA.blocs = dict([(irb.label, irb) for irb in [G6_IRB0, G6_IRB1]]) G7_IRA = IRATest() -G7_IRB0 = gen_irbloc(LBL0, [[ExprAff(C, CST1)]]) -G7_IRB1 = gen_irbloc(LBL1, [[ExprAff(B, C)], [ExprAff(A, B)]]) -G7_IRB2 = gen_irbloc(LBL2, [[ExprAff(D, A)]]) +G7_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) +G7_IRB1 = gen_irblock(LBL1, [[ExprAff(B, C)], [ExprAff(A, B)]]) +G7_IRB2 = gen_irblock(LBL2, [[ExprAff(D, A)]]) G7_IRA.graph.add_uniq_edge(G7_IRB0.label, G7_IRB1.label) G7_IRA.graph.add_uniq_edge(G7_IRB1.label, G7_IRB1.label) @@ -339,9 +339,9 @@ G7_IRA.blocs = dict([(irb.label, irb) for irb in [G7_IRB0, G7_IRB1, G7_IRB2]]) G8_IRA = IRATest() -G8_IRB0 = gen_irbloc(LBL0, [[ExprAff(C, CST1)]]) -G8_IRB1 = gen_irbloc(LBL1, [[ExprAff(B, C)], [ExprAff(C, D)]]) -G8_IRB2 = gen_irbloc(LBL2, [[ExprAff(A, B)]]) +G8_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) +G8_IRB1 = gen_irblock(LBL1, [[ExprAff(B, C)], [ExprAff(C, D)]]) +G8_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B)]]) G8_IRA.graph.add_uniq_edge(G8_IRB0.label, G8_IRB1.label) G8_IRA.graph.add_uniq_edge(G8_IRB1.label, G8_IRB1.label) @@ -355,8 +355,8 @@ G8_IRA.blocs = dict([(irb.label, irb) for irb in [G8_IRB0, G8_IRB1, G8_IRB2]]) G10_IRA = IRATest() -G10_IRB1 = gen_irbloc(LBL1, [[ExprAff(B, B + CST2)]]) -G10_IRB2 = gen_irbloc(LBL2, [[ExprAff(A, B)]]) +G10_IRB1 = gen_irblock(LBL1, [[ExprAff(B, B + CST2)]]) +G10_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B)]]) G10_IRA.graph.add_uniq_edge(G10_IRB1.label, G10_IRB2.label) G10_IRA.graph.add_uniq_edge(G10_IRB1.label, G10_IRB1.label) @@ -367,11 +367,11 @@ G10_IRA.blocs = dict([(irb.label, irb) for irb in [G10_IRB1, G10_IRB2]]) G11_IRA = IRATest() -G11_IRB0 = gen_irbloc(LBL0, [[ExprAff(A, CST1), - ExprAff(B, CST2)]]) -G11_IRB1 = gen_irbloc(LBL1, [[ExprAff(A, B), - ExprAff(B, A)]]) -G11_IRB2 = gen_irbloc(LBL2, [[ExprAff(A, A - B)]]) +G11_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1), + ExprAff(B, CST2)]]) +G11_IRB1 = gen_irblock(LBL1, [[ExprAff(A, B), + ExprAff(B, A)]]) +G11_IRB2 = gen_irblock(LBL2, [[ExprAff(A, A - B)]]) G11_IRA.graph.add_uniq_edge(G11_IRB0.label, G11_IRB1.label) G11_IRA.graph.add_uniq_edge(G11_IRB1.label, G11_IRB2.label) @@ -383,9 +383,9 @@ G11_IRA.blocs = dict([(irb.label, irb) G12_IRA = IRATest() -G12_IRB0 = gen_irbloc(LBL0, [[ExprAff(B, CST1)]]) -G12_IRB1 = gen_irbloc(LBL1, [[ExprAff(A, B)], [ExprAff(B, B + CST2)]]) -G12_IRB2 = gen_irbloc(LBL2, [[ExprAff(B, A)]]) +G12_IRB0 = gen_irblock(LBL0, [[ExprAff(B, CST1)]]) +G12_IRB1 = gen_irblock(LBL1, [[ExprAff(A, B)], [ExprAff(B, B + CST2)]]) +G12_IRB2 = gen_irblock(LBL2, [[ExprAff(B, A)]]) G12_IRA.graph.add_uniq_edge(G12_IRB0.label, G12_IRB1.label) G12_IRA.graph.add_uniq_edge(G12_IRB1.label, G12_IRB2.label) @@ -399,21 +399,21 @@ G12_IRA.blocs = dict([(irb.label, irb) for irb in [G12_IRB0, G12_IRB1, G13_IRA = IRATest() -G13_IRB0 = gen_irbloc(LBL0, [[ExprAff(A, CST1)], - #[ExprAff(B, A)], - [ExprAff(G13_IRA.IRDst, - ExprId(LBL1))]]) -G13_IRB1 = gen_irbloc(LBL1, [[ExprAff(C, A)], - #[ExprAff(A, A + CST1)], - [ExprAff(G13_IRA.IRDst, - ExprCond(R, ExprId(LBL2), - ExprId(LBL1)))]]) +G13_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)], + #[ExprAff(B, A)], + [ExprAff(G13_IRA.IRDst, + ExprId(LBL1))]]) +G13_IRB1 = gen_irblock(LBL1, [[ExprAff(C, A)], + #[ExprAff(A, A + CST1)], + [ExprAff(G13_IRA.IRDst, + ExprCond(R, ExprId(LBL2), + ExprId(LBL1)))]]) -G13_IRB2 = gen_irbloc(LBL2, [[ExprAff(B, A + CST3)], [ExprAff(A, B + CST3)], - [ExprAff(G13_IRA.IRDst, - ExprId(LBL1))]]) +G13_IRB2 = gen_irblock(LBL2, [[ExprAff(B, A + CST3)], [ExprAff(A, B + CST3)], + [ExprAff(G13_IRA.IRDst, + ExprId(LBL1))]]) -G13_IRB3 = gen_irbloc(LBL3, [[ExprAff(R, C)]]) +G13_IRB3 = gen_irblock(LBL3, [[ExprAff(R, C)]]) G13_IRA.graph.add_uniq_edge(G13_IRB0.label, G13_IRB1.label) G13_IRA.graph.add_uniq_edge(G13_IRB1.label, G13_IRB2.label) @@ -427,23 +427,23 @@ G13_IRA.blocs = dict([(irb.label, irb) for irb in [G13_IRB0, G13_IRB1, G14_IRA = IRATest() -G14_IRB0 = gen_irbloc(LBL0, [[ExprAff(A, CST1)], - [ExprAff(G14_IRA.IRDst, - ExprId(LBL1))] +G14_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)], + [ExprAff(G14_IRA.IRDst, + ExprId(LBL1))] ]) -G14_IRB1 = gen_irbloc(LBL1, [[ExprAff(B, A)], - [ExprAff(G14_IRA.IRDst, - ExprCond(C, ExprId(LBL2), - ExprId(LBL3)))] +G14_IRB1 = gen_irblock(LBL1, [[ExprAff(B, A)], + [ExprAff(G14_IRA.IRDst, + ExprCond(C, ExprId(LBL2), + ExprId(LBL3)))] ]) -G14_IRB2 = gen_irbloc(LBL2, [[ExprAff(D, A)], - [ExprAff(A, D + CST1)], - [ExprAff(G14_IRA.IRDst, - ExprId(LBL1))] +G14_IRB2 = gen_irblock(LBL2, [[ExprAff(D, A)], + [ExprAff(A, D + CST1)], + [ExprAff(G14_IRA.IRDst, + ExprId(LBL1))] ]) -G14_IRB3 = gen_irbloc(LBL3, [[ExprAff(R, D + B)]]) +G14_IRB3 = gen_irblock(LBL3, [[ExprAff(R, D + B)]]) G14_IRA.graph.add_uniq_edge(G14_IRB0.label, G14_IRB1.label) G14_IRA.graph.add_uniq_edge(G14_IRB1.label, G14_IRB2.label) @@ -457,11 +457,11 @@ G14_IRA.blocs = dict([(irb.label, irb) for irb in [G14_IRB0, G14_IRB1, G15_IRA = IRATest() -G15_IRB0 = gen_irbloc(LBL0, [[ExprAff(A, CST1)]]) -G15_IRB1 = gen_irbloc(LBL1, [[ExprAff(D, A + B)], - [ExprAff(C, D)], - [ExprAff(B, C)]]) -G15_IRB2 = gen_irbloc(LBL2, [[ExprAff(R, B)]]) +G15_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)]]) +G15_IRB1 = gen_irblock(LBL1, [[ExprAff(D, A + B)], + [ExprAff(C, D)], + [ExprAff(B, C)]]) +G15_IRB2 = gen_irblock(LBL2, [[ExprAff(R, B)]]) G15_IRA.graph.add_uniq_edge(G15_IRB0.label, G15_IRB1.label) G15_IRA.graph.add_uniq_edge(G15_IRB1.label, G15_IRB2.label) @@ -474,12 +474,12 @@ G15_IRA.blocs = dict([(irb.label, irb) for irb in [G15_IRB0, G15_IRB1, G16_IRA = IRATest() -G16_IRB0 = gen_irbloc(LBL0, [[ExprAff(A, CST1)]]) -G16_IRB1 = gen_irbloc(LBL1, [[ExprAff(R, D)]]) -G16_IRB2 = gen_irbloc(LBL2, [[ExprAff(D, A)]]) -G16_IRB3 = gen_irbloc(LBL3, [[ExprAff(R, D)]]) -G16_IRB4 = gen_irbloc(LBL4, [[ExprAff(R, A)]]) -G16_IRB5 = gen_irbloc(LBL5, [[ExprAff(R, A)]]) +G16_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)]]) +G16_IRB1 = gen_irblock(LBL1, [[ExprAff(R, D)]]) +G16_IRB2 = gen_irblock(LBL2, [[ExprAff(D, A)]]) +G16_IRB3 = gen_irblock(LBL3, [[ExprAff(R, D)]]) +G16_IRB4 = gen_irblock(LBL4, [[ExprAff(R, A)]]) +G16_IRB5 = gen_irblock(LBL5, [[ExprAff(R, A)]]) G16_IRA.graph.add_uniq_edge(G16_IRB0.label, G16_IRB1.label) G16_IRA.graph.add_uniq_edge(G16_IRB1.label, G16_IRB2.label) @@ -498,11 +498,11 @@ G16_IRA.blocs = dict([(irb.label, irb) for irb in [G16_IRB0, G16_IRB1, G17_IRA = IRATest() -G17_IRB0 = gen_irbloc(LBL0, [[ExprAff(A, CST1), - ExprAff(D, CST2)]]) -G17_IRB1 = gen_irbloc(LBL1, [[ExprAff(A, D), - ExprAff(B, D)]]) -G17_IRB2 = gen_irbloc(LBL2, [[ExprAff(A, A - B)]]) +G17_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1), + ExprAff(D, CST2)]]) +G17_IRB1 = gen_irblock(LBL1, [[ExprAff(A, D), + ExprAff(B, D)]]) +G17_IRB2 = gen_irblock(LBL2, [[ExprAff(A, A - B)]]) G17_IRA.graph.add_uniq_edge(G17_IRB0.label, G17_IRB1.label) G17_IRA.graph.add_uniq_edge(G17_IRB1.label, G17_IRB2.label) diff --git a/test/ir/analysis.py b/test/ir/analysis.py index 913d9c56..788586a0 100644 --- a/test/ir/analysis.py +++ b/test/ir/analysis.py @@ -2,7 +2,7 @@ from miasm2.expression.expression import ExprId, ExprInt32, ExprAff, ExprMem from miasm2.core.asmbloc import asm_label from miasm2.ir.analysis import ira -from miasm2.ir.ir import irbloc, AssignBlock +from miasm2.ir.ir import IRBlock, AssignBlock a = ExprId("a") b = ExprId("b") @@ -33,7 +33,7 @@ LBL6 = asm_label("lbl6") -def gen_irbloc(label, exprs_list): +def gen_irblock(label, exprs_list): lines = [None for _ in xrange(len(exprs_list))] irs = [] for exprs in exprs_list: @@ -42,7 +42,7 @@ def gen_irbloc(label, exprs_list): else: irs.append(AssignBlock(exprs)) - irbl = irbloc(label, irs, lines) + irbl = IRBlock(label, irs, lines) return irbl @@ -76,9 +76,9 @@ class IRATest(ira): G1_IRA = IRATest() -G1_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) -G1_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, b)]]) -G1_IRB2 = gen_irbloc(LBL2, [[ExprAff(r, a)]]) +G1_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) +G1_IRB1 = gen_irblock(LBL1, [[ExprAff(a, b)]]) +G1_IRB2 = gen_irblock(LBL2, [[ExprAff(r, a)]]) G1_IRA.graph.add_uniq_edge(G1_IRB0.label, G1_IRB1.label) G1_IRA.graph.add_uniq_edge(G1_IRB1.label, G1_IRB2.label) @@ -88,9 +88,9 @@ G1_IRA.blocs = {irb.label : irb for irb in [G1_IRB0, G1_IRB1, G1_IRB2]} # Expected output for graph 1 G1_EXP_IRA = IRATest() -G1_EXP_IRB0 = gen_irbloc(LBL0, [[], [ExprAff(b, CST2)]]) -G1_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, b)]]) -G1_EXP_IRB2 = gen_irbloc(LBL2, [[ExprAff(r, a)]]) +G1_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(b, CST2)]]) +G1_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(a, b)]]) +G1_EXP_IRB2 = gen_irblock(LBL2, [[ExprAff(r, a)]]) G1_EXP_IRA.blocs = {irb.label : irb for irb in [G1_EXP_IRB0, G1_EXP_IRB1, G1_EXP_IRB2]} @@ -99,9 +99,9 @@ G1_EXP_IRA.blocs = {irb.label : irb for irb in [G1_EXP_IRB0, G1_EXP_IRB1, G2_IRA = IRATest() -G2_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(r, CST1)]]) -G2_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, a+CST1)]]) -G2_IRB2 = gen_irbloc(LBL2, [[ExprAff(a, r)]]) +G2_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(r, CST1)]]) +G2_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) +G2_IRB2 = gen_irblock(LBL2, [[ExprAff(a, r)]]) G2_IRA.graph.add_uniq_edge(G2_IRB0.label, G2_IRB1.label) G2_IRA.graph.add_uniq_edge(G2_IRB1.label, G2_IRB2.label) @@ -112,9 +112,9 @@ G2_IRA.blocs = {irb.label : irb for irb in [G2_IRB0, G2_IRB1, G2_IRB2]} # Expected output for graph 2 G2_EXP_IRA = IRATest() -G2_EXP_IRB0 = gen_irbloc(LBL0, [[], [ExprAff(r, CST1)]]) -G2_EXP_IRB1 = gen_irbloc(LBL1, [[]]) -G2_EXP_IRB2 = gen_irbloc(LBL2, [[]]) +G2_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(r, CST1)]]) +G2_EXP_IRB1 = gen_irblock(LBL1, [[]]) +G2_EXP_IRB2 = gen_irblock(LBL2, [[]]) G2_EXP_IRA.blocs = {irb.label : irb for irb in [G2_EXP_IRB0, G2_EXP_IRB1, G2_EXP_IRB2]} @@ -123,9 +123,9 @@ G2_EXP_IRA.blocs = {irb.label : irb for irb in [G2_EXP_IRB0, G2_EXP_IRB1, G3_IRA = IRATest() -G3_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)]]) -G3_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, a+CST1)]]) -G3_IRB2 = gen_irbloc(LBL2, [[ExprAff(r, a)]]) +G3_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) +G3_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) +G3_IRB2 = gen_irblock(LBL2, [[ExprAff(r, a)]]) G3_IRA.graph.add_uniq_edge(G3_IRB0.label, G3_IRB1.label) G3_IRA.graph.add_uniq_edge(G3_IRB1.label, G3_IRB2.label) @@ -136,9 +136,9 @@ G3_IRA.blocs = {irb.label : irb for irb in [G3_IRB0, G3_IRB1, G3_IRB2]} # Expected output for graph 3 G3_EXP_IRA = IRATest() -G3_EXP_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)]]) -G3_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, a+CST1)]]) -G3_EXP_IRB2 = gen_irbloc(LBL2, [[ExprAff(r, a)]]) +G3_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) +G3_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) +G3_EXP_IRB2 = gen_irblock(LBL2, [[ExprAff(r, a)]]) G3_EXP_IRA.blocs = {irb.label : irb for irb in [G3_EXP_IRB0, G3_EXP_IRB1, G3_EXP_IRB2]} @@ -147,10 +147,10 @@ G3_EXP_IRA.blocs = {irb.label : irb for irb in [G3_EXP_IRB0, G3_EXP_IRB1, G4_IRA = IRATest() -G4_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)]]) -G4_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, a+CST1)]]) -G4_IRB2 = gen_irbloc(LBL2, [[ExprAff(a, a+CST2)]]) -G4_IRB3 = gen_irbloc(LBL3, [[ExprAff(a, CST3)], [ExprAff(r, a)]]) +G4_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) +G4_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) +G4_IRB2 = gen_irblock(LBL2, [[ExprAff(a, a+CST2)]]) +G4_IRB3 = gen_irblock(LBL3, [[ExprAff(a, CST3)], [ExprAff(r, a)]]) G4_IRA.graph.add_uniq_edge(G4_IRB0.label, G4_IRB1.label) G4_IRA.graph.add_uniq_edge(G4_IRB0.label, G4_IRB2.label) @@ -163,10 +163,10 @@ G4_IRA.blocs = {irb.label : irb for irb in [G4_IRB0, G4_IRB1, G4_IRB2, # Expected output for graph 4 G4_EXP_IRA = IRATest() -G4_EXP_IRB0 = gen_irbloc(LBL0, [[]]) -G4_EXP_IRB1 = gen_irbloc(LBL1, [[]]) -G4_EXP_IRB2 = gen_irbloc(LBL2, [[]]) -G4_EXP_IRB3 = gen_irbloc(LBL3, [[ExprAff(a, CST3)], [ExprAff(r, a)]]) +G4_EXP_IRB0 = gen_irblock(LBL0, [[]]) +G4_EXP_IRB1 = gen_irblock(LBL1, [[]]) +G4_EXP_IRB2 = gen_irblock(LBL2, [[]]) +G4_EXP_IRB3 = gen_irblock(LBL3, [[ExprAff(a, CST3)], [ExprAff(r, a)]]) G4_EXP_IRA.blocs = {irb.label : irb for irb in [G4_EXP_IRB0, G4_EXP_IRB1, G4_EXP_IRB2, G4_EXP_IRB3]} @@ -175,12 +175,12 @@ G4_EXP_IRA.blocs = {irb.label : irb for irb in [G4_EXP_IRB0, G4_EXP_IRB1, G5_IRA = IRATest() -G5_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)]]) -G5_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, CST2)]]) -G5_IRB2 = gen_irbloc(LBL2, [[ExprAff(a, a+CST2)]]) -G5_IRB3 = gen_irbloc(LBL3, [[ExprAff(a, a+CST3)]]) -G5_IRB4 = gen_irbloc(LBL4, [[ExprAff(a, a+CST1)]]) -G5_IRB5 = gen_irbloc(LBL5, [[ExprAff(a, r)]]) +G5_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) +G5_IRB1 = gen_irblock(LBL1, [[ExprAff(r, CST2)]]) +G5_IRB2 = gen_irblock(LBL2, [[ExprAff(a, a+CST2)]]) +G5_IRB3 = gen_irblock(LBL3, [[ExprAff(a, a+CST3)]]) +G5_IRB4 = gen_irblock(LBL4, [[ExprAff(a, a+CST1)]]) +G5_IRB5 = gen_irblock(LBL5, [[ExprAff(a, r)]]) G5_IRA.graph.add_uniq_edge(G5_IRB0.label, G5_IRB1.label) G5_IRA.graph.add_uniq_edge(G5_IRB1.label, G5_IRB2.label) @@ -196,12 +196,12 @@ G5_IRA.blocs = {irb.label : irb for irb in [G5_IRB0, G5_IRB1, G5_IRB2, G5_IRB3, # Expected output for graph 5 G5_EXP_IRA = IRATest() -G5_EXP_IRB0 = gen_irbloc(LBL0, [[]]) -G5_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, CST2)]]) -G5_EXP_IRB2 = gen_irbloc(LBL2, [[]]) -G5_EXP_IRB3 = gen_irbloc(LBL3, [[]]) -G5_EXP_IRB4 = gen_irbloc(LBL4, [[]]) -G5_EXP_IRB5 = gen_irbloc(LBL5, [[]]) +G5_EXP_IRB0 = gen_irblock(LBL0, [[]]) +G5_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, CST2)]]) +G5_EXP_IRB2 = gen_irblock(LBL2, [[]]) +G5_EXP_IRB3 = gen_irblock(LBL3, [[]]) +G5_EXP_IRB4 = gen_irblock(LBL4, [[]]) +G5_EXP_IRB5 = gen_irblock(LBL5, [[]]) G5_EXP_IRA.blocs = {irb.label : irb for irb in [G5_EXP_IRB0, G5_EXP_IRB1, G5_EXP_IRB2, G5_EXP_IRB3, @@ -212,10 +212,10 @@ G5_EXP_IRA.blocs = {irb.label : irb for irb in [G5_EXP_IRB0, G5_EXP_IRB1, G6_IRA = IRATest() -G6_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)]]) -G6_IRB1 = gen_irbloc(LBL1, [[ExprAff(b, a)]]) -G6_IRB2 = gen_irbloc(LBL2, [[ExprAff(a, b)]]) -G6_IRB3 = gen_irbloc(LBL3, [[ExprAff(r, CST2)]]) +G6_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) +G6_IRB1 = gen_irblock(LBL1, [[ExprAff(b, a)]]) +G6_IRB2 = gen_irblock(LBL2, [[ExprAff(a, b)]]) +G6_IRB3 = gen_irblock(LBL3, [[ExprAff(r, CST2)]]) G6_IRA.graph.add_uniq_edge(G6_IRB0.label, G6_IRB1.label) @@ -229,10 +229,10 @@ G6_IRA.blocs = {irb.label : irb for irb in [G6_IRB0, G6_IRB1, G6_IRB2, # Expected output for graph 6 G6_EXP_IRA = IRATest() -G6_EXP_IRB0 = gen_irbloc(LBL0, [[]]) -G6_EXP_IRB1 = gen_irbloc(LBL1, [[]]) -G6_EXP_IRB2 = gen_irbloc(LBL2, [[]]) -G6_EXP_IRB3 = gen_irbloc(LBL3, [[ExprAff(r, CST2)]]) +G6_EXP_IRB0 = gen_irblock(LBL0, [[]]) +G6_EXP_IRB1 = gen_irblock(LBL1, [[]]) +G6_EXP_IRB2 = gen_irblock(LBL2, [[]]) +G6_EXP_IRB3 = gen_irblock(LBL3, [[ExprAff(r, CST2)]]) G6_EXP_IRA.blocs = {irb.label : irb for irb in [G6_EXP_IRB0, G6_EXP_IRB1, G6_EXP_IRB2, G6_EXP_IRB3]} @@ -241,10 +241,10 @@ G6_EXP_IRA.blocs = {irb.label : irb for irb in [G6_EXP_IRB0, G6_EXP_IRB1, G7_IRA = IRATest() -G7_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(r, CST1)]]) -G7_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, a+CST1)]]) -G7_IRB2 = gen_irbloc(LBL2, [[ExprAff(a, a+CST2)]]) -G7_IRB3 = gen_irbloc(LBL3, [[ExprAff(a, r)]]) +G7_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(r, CST1)]]) +G7_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) +G7_IRB2 = gen_irblock(LBL2, [[ExprAff(a, a+CST2)]]) +G7_IRB3 = gen_irblock(LBL3, [[ExprAff(a, r)]]) G7_IRA.graph.add_uniq_edge(G7_IRB0.label, G7_IRB1.label) @@ -260,10 +260,10 @@ G7_IRA.blocs = {irb.label : irb for irb in [G7_IRB0, G7_IRB1, G7_IRB2, # Expected output for graph 7 G7_EXP_IRA = IRATest() -G7_EXP_IRB0 = gen_irbloc(LBL0, [[], [ExprAff(r, CST1)]]) -G7_EXP_IRB1 = gen_irbloc(LBL1, [[]]) -G7_EXP_IRB2 = gen_irbloc(LBL2, [[]]) -G7_EXP_IRB3 = gen_irbloc(LBL3, [[]]) +G7_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(r, CST1)]]) +G7_EXP_IRB1 = gen_irblock(LBL1, [[]]) +G7_EXP_IRB2 = gen_irblock(LBL2, [[]]) +G7_EXP_IRB3 = gen_irblock(LBL3, [[]]) G7_EXP_IRA.blocs = {irb.label : irb for irb in [G7_EXP_IRB0, G7_EXP_IRB1, G7_EXP_IRB2, G7_EXP_IRB3]} @@ -272,10 +272,10 @@ G7_EXP_IRA.blocs = {irb.label : irb for irb in [G7_EXP_IRB0, G7_EXP_IRB1, G8_IRA = IRATest() -G8_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST1)]]) -G8_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, a+CST1)]]) -G8_IRB2 = gen_irbloc(LBL2, [[ExprAff(b, b+CST2)]]) -G8_IRB3 = gen_irbloc(LBL3, [[ExprAff(a, b)]]) +G8_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST1)]]) +G8_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)]]) +G8_IRB2 = gen_irblock(LBL2, [[ExprAff(b, b+CST2)]]) +G8_IRB3 = gen_irblock(LBL3, [[ExprAff(a, b)]]) G8_IRA.graph.add_uniq_edge(G8_IRB0.label, G8_IRB1.label) @@ -292,10 +292,10 @@ G8_IRA.blocs = {irb.label : irb for irb in [G8_IRB0, G8_IRB1, G8_IRB2, G8_EXP_IRA = IRATest() -G8_EXP_IRB0 = gen_irbloc(LBL0, [[], []]) -G8_EXP_IRB1 = gen_irbloc(LBL1, [[]]) -G8_EXP_IRB2 = gen_irbloc(LBL2, [[]]) -G8_EXP_IRB3 = gen_irbloc(LBL3, [[]]) +G8_EXP_IRB0 = gen_irblock(LBL0, [[], []]) +G8_EXP_IRB1 = gen_irblock(LBL1, [[]]) +G8_EXP_IRB2 = gen_irblock(LBL2, [[]]) +G8_EXP_IRB3 = gen_irblock(LBL3, [[]]) G8_EXP_IRA.blocs = {irb.label : irb for irb in [G8_EXP_IRB0, G8_EXP_IRB1, G8_EXP_IRB2, G8_EXP_IRB3]} @@ -304,11 +304,11 @@ G8_EXP_IRA.blocs = {irb.label : irb for irb in [G8_EXP_IRB0, G8_EXP_IRB1, G9_IRA = IRATest() -G9_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST1)]]) -G9_IRB1 = gen_irbloc(LBL1, [[ExprAff(a, a+CST1)], [ExprAff(b, b+CST1)]]) -G9_IRB2 = gen_irbloc(LBL2, [[ExprAff(a, a+CST2)], [ExprAff(b, b+CST2)]]) -G9_IRB3 = gen_irbloc(LBL3, [[ExprAff(a, b)]]) -G9_IRB4 = gen_irbloc(LBL4, [[ExprAff(r, a)], [ExprAff(r, b)]]) +G9_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST1)]]) +G9_IRB1 = gen_irblock(LBL1, [[ExprAff(a, a+CST1)], [ExprAff(b, b+CST1)]]) +G9_IRB2 = gen_irblock(LBL2, [[ExprAff(a, a+CST2)], [ExprAff(b, b+CST2)]]) +G9_IRB3 = gen_irblock(LBL3, [[ExprAff(a, b)]]) +G9_IRB4 = gen_irblock(LBL4, [[ExprAff(r, a)], [ExprAff(r, b)]]) G9_IRA.graph.add_uniq_edge(G9_IRB0.label, G9_IRB4.label) @@ -328,11 +328,11 @@ G9_IRA.blocs = {irb.label : irb for irb in [G9_IRB0, G9_IRB1, G9_IRB2, G9_EXP_IRA = IRATest() -G9_EXP_IRB0 = gen_irbloc(LBL0, [[], [ExprAff(b, CST1)]]) -G9_EXP_IRB1 = gen_irbloc(LBL1, [[], [ExprAff(b, b+CST1)]]) -G9_EXP_IRB2 = gen_irbloc(LBL2, [[], [ExprAff(b, b+CST2)]]) -G9_EXP_IRB3 = gen_irbloc(LBL3, [[]]) -G9_EXP_IRB4 = gen_irbloc(LBL4, [[], [ExprAff(r, b)]]) +G9_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(b, CST1)]]) +G9_EXP_IRB1 = gen_irblock(LBL1, [[], [ExprAff(b, b+CST1)]]) +G9_EXP_IRB2 = gen_irblock(LBL2, [[], [ExprAff(b, b+CST2)]]) +G9_EXP_IRB3 = gen_irblock(LBL3, [[]]) +G9_EXP_IRB4 = gen_irblock(LBL4, [[], [ExprAff(r, b)]]) G9_EXP_IRA.blocs = {irb.label : irb for irb in [G9_EXP_IRB0, G9_EXP_IRB1, G9_EXP_IRB2, G9_EXP_IRB3, @@ -343,10 +343,10 @@ G9_EXP_IRA.blocs = {irb.label : irb for irb in [G9_EXP_IRB0, G9_EXP_IRB1, G10_IRA = IRATest() -G10_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)]]) -G10_IRB1 = gen_irbloc(LBL1, [[ExprAff(b, a)]]) -G10_IRB2 = gen_irbloc(LBL2, [[ExprAff(a, b)]]) -G10_IRB3 = gen_irbloc(LBL3, [[ExprAff(r, CST1)]]) +G10_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)]]) +G10_IRB1 = gen_irblock(LBL1, [[ExprAff(b, a)]]) +G10_IRB2 = gen_irblock(LBL2, [[ExprAff(a, b)]]) +G10_IRB3 = gen_irblock(LBL3, [[ExprAff(r, CST1)]]) G10_IRA.graph.add_uniq_edge(G10_IRB0.label, G10_IRB1.label) @@ -360,10 +360,10 @@ G10_IRA.blocs = {irb.label : irb for irb in [G10_IRB0, G10_IRB1, # Expected output for graph 10 G10_EXP_IRA = IRATest() -G10_EXP_IRB0 = gen_irbloc(LBL0, [[]]) -G10_EXP_IRB1 = gen_irbloc(LBL1, [[]]) -G10_EXP_IRB2 = gen_irbloc(LBL2, [[]]) -G10_EXP_IRB3 = gen_irbloc(LBL3, [[ExprAff(r, CST1)]]) +G10_EXP_IRB0 = gen_irblock(LBL0, [[]]) +G10_EXP_IRB1 = gen_irblock(LBL1, [[]]) +G10_EXP_IRB2 = gen_irblock(LBL2, [[]]) +G10_EXP_IRB3 = gen_irblock(LBL3, [[ExprAff(r, CST1)]]) G10_EXP_IRA.blocs = {irb.label : irb for irb in [G10_EXP_IRB0, G10_EXP_IRB1, G10_EXP_IRB2, G10_EXP_IRB3]} @@ -372,11 +372,11 @@ G10_EXP_IRA.blocs = {irb.label : irb for irb in [G10_EXP_IRB0, G10_EXP_IRB1, G11_IRA = IRATest() -G11_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, b)]]) -G11_IRB1 = gen_irbloc(LBL1, [[ExprAff(b, a)]]) -G11_IRB2 = gen_irbloc(LBL2, [[ExprAff(r, a)]]) -G11_IRB3 = gen_irbloc(LBL3, [[ExprAff(a, a+CST1)]]) -G11_IRB4 = gen_irbloc(LBL4, [[ExprAff(b, b+CST1)]]) +G11_IRB0 = gen_irblock(LBL0, [[ExprAff(a, b)]]) +G11_IRB1 = gen_irblock(LBL1, [[ExprAff(b, a)]]) +G11_IRB2 = gen_irblock(LBL2, [[ExprAff(r, a)]]) +G11_IRB3 = gen_irblock(LBL3, [[ExprAff(a, a+CST1)]]) +G11_IRB4 = gen_irblock(LBL4, [[ExprAff(b, b+CST1)]]) G11_IRA.graph.add_uniq_edge(G11_IRB0.label, G11_IRB1.label) @@ -390,11 +390,11 @@ G11_IRA.blocs = {irb.label : irb for irb in [G11_IRB0, G11_IRB1, G11_IRB2]} # Expected output for graph 11 G11_EXP_IRA = IRATest() -G11_EXP_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, b)]]) -G11_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(b, a)]]) -G11_EXP_IRB2 = gen_irbloc(LBL2, [[ExprAff(r, a)]]) -#G11_EXP_IRB3 = gen_irbloc(LBL3, [[ExprAff(a, a+CST1)]]) -#G11_EXP_IRB4 = gen_irbloc(LBL4, [[ExprAff(b, b+CST1)]]) +G11_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(a, b)]]) +G11_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(b, a)]]) +G11_EXP_IRB2 = gen_irblock(LBL2, [[ExprAff(r, a)]]) +#G11_EXP_IRB3 = gen_irblock(LBL3, [[ExprAff(a, a+CST1)]]) +#G11_EXP_IRB4 = gen_irblock(LBL4, [[ExprAff(b, b+CST1)]]) G11_EXP_IRA.blocs = {irb.label : irb for irb in [G11_EXP_IRB0, G11_EXP_IRB1, G11_EXP_IRB2]} @@ -404,12 +404,12 @@ G11_EXP_IRA.blocs = {irb.label : irb for irb in [G11_EXP_IRB0, G11_EXP_IRB1, G12_IRA = IRATest() -G12_IRB0 = gen_irbloc(LBL0, [[ExprAff(r, CST1)], [ExprAff(a, CST2)]]) -G12_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, CST2)]]) -G12_IRB2 = gen_irbloc(LBL2, [[ExprAff(r, a)], [ExprAff(b, CST3)]]) -G12_IRB3 = gen_irbloc(LBL3, [[ExprAff(r, CST3)]]) -G12_IRB4 = gen_irbloc(LBL4, [[ExprAff(r, CST2)]]) -G12_IRB5 = gen_irbloc(LBL5, [[ExprAff(r, b)]]) +G12_IRB0 = gen_irblock(LBL0, [[ExprAff(r, CST1)], [ExprAff(a, CST2)]]) +G12_IRB1 = gen_irblock(LBL1, [[ExprAff(r, CST2)]]) +G12_IRB2 = gen_irblock(LBL2, [[ExprAff(r, a)], [ExprAff(b, CST3)]]) +G12_IRB3 = gen_irblock(LBL3, [[ExprAff(r, CST3)]]) +G12_IRB4 = gen_irblock(LBL4, [[ExprAff(r, CST2)]]) +G12_IRB5 = gen_irblock(LBL5, [[ExprAff(r, b)]]) G12_IRA.graph.add_uniq_edge(G12_IRB0.label, G12_IRB1.label) G12_IRA.graph.add_uniq_edge(G12_IRB0.label, G12_IRB2.label) @@ -423,12 +423,12 @@ G12_IRA.blocs = {irb.label : irb for irb in [G12_IRB0, G12_IRB1, G12_IRB2, # Expected output for graph 12 G12_EXP_IRA = IRATest() -G12_EXP_IRB0 = gen_irbloc(LBL0, [[], []]) -G12_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, CST2)]]) -G12_EXP_IRB2 = gen_irbloc(LBL2, [[], [ExprAff(b, CST3)]]) -G12_EXP_IRB3 = gen_irbloc(LBL3, [[ExprAff(r, CST3)]]) -G12_EXP_IRB4 = gen_irbloc(LBL4, [[]]) -G12_EXP_IRB5 = gen_irbloc(LBL5, [[ExprAff(r, b)]]) +G12_EXP_IRB0 = gen_irblock(LBL0, [[], []]) +G12_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, CST2)]]) +G12_EXP_IRB2 = gen_irblock(LBL2, [[], [ExprAff(b, CST3)]]) +G12_EXP_IRB3 = gen_irblock(LBL3, [[ExprAff(r, CST3)]]) +G12_EXP_IRB4 = gen_irblock(LBL4, [[]]) +G12_EXP_IRB5 = gen_irblock(LBL5, [[ExprAff(r, b)]]) G12_EXP_IRA.blocs = {irb.label : irb for irb in [G12_EXP_IRB0, G12_EXP_IRB1, @@ -439,12 +439,12 @@ G12_EXP_IRA.blocs = {irb.label : irb for irb in [G12_EXP_IRB0, G12_EXP_IRB1, G13_IRA = IRATest() -G13_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) -G13_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, b)]]) -G13_IRB2 = gen_irbloc(LBL2, [[ExprAff(d, CST2)], [ExprAff(a, b+CST1), +G13_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) +G13_IRB1 = gen_irblock(LBL1, [[ExprAff(r, b)]]) +G13_IRB2 = gen_irblock(LBL2, [[ExprAff(d, CST2)], [ExprAff(a, b+CST1), ExprAff(c, a+b)]]) -G13_IRB3 = gen_irbloc(LBL3, [[]]) # lost son -G13_IRB4 = gen_irbloc(LBL4, [[ExprAff(b, CST2)]]) +G13_IRB3 = gen_irblock(LBL3, [[]]) # lost son +G13_IRB4 = gen_irblock(LBL4, [[ExprAff(b, CST2)]]) G13_IRA.graph.add_uniq_edge(G13_IRB0.label, G13_IRB1.label) G13_IRA.graph.add_uniq_edge(G13_IRB0.label, G13_IRB4.label) @@ -457,12 +457,12 @@ G13_IRA.blocs = {irb.label : irb for irb in [G13_IRB0, G13_IRB1, G13_IRB2, # Expected output for graph 13 G13_EXP_IRA = IRATest() -G13_EXP_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) -G13_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, b)]]) -G13_EXP_IRB2 = gen_irbloc(LBL2, [[ExprAff(d, CST2)], [ExprAff(a, b+CST1), - ExprAff(c, a+b)]]) -G13_EXP_IRB3 = gen_irbloc(LBL3, [[]]) -G13_EXP_IRB4 = gen_irbloc(LBL4, [[ExprAff(b, CST2)]]) +G13_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(b, CST2)]]) +G13_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, b)]]) +G13_EXP_IRB2 = gen_irblock(LBL2, [[ExprAff(d, CST2)], [ExprAff(a, b+CST1), + ExprAff(c, a+b)]]) +G13_EXP_IRB3 = gen_irblock(LBL3, [[]]) +G13_EXP_IRB4 = gen_irblock(LBL4, [[ExprAff(b, CST2)]]) G13_EXP_IRA.blocs = {irb.label: irb for irb in [G13_EXP_IRB0, G13_EXP_IRB1, G13_EXP_IRB2, G13_EXP_IRB4]} @@ -474,9 +474,9 @@ G13_EXP_IRA.blocs = {irb.label: irb for irb in [G13_EXP_IRB0, G13_EXP_IRB1, G14_IRA = IRATest() -G14_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(c, a)], - [ExprAff(a, CST2)]]) -G14_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, a+c)]]) +G14_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(c, a)], + [ExprAff(a, CST2)]]) +G14_IRB1 = gen_irblock(LBL1, [[ExprAff(r, a+c)]]) G14_IRA.graph.add_uniq_edge(G14_IRB0.label, G14_IRB1.label) @@ -485,9 +485,9 @@ G14_IRA.blocs = {irb.label : irb for irb in [G14_IRB0, G14_IRB1]} # Expected output for graph 1 G14_EXP_IRA = IRATest() -G14_EXP_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1)], [ExprAff(c, a)], - [ExprAff(a, CST2)]]) -G14_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, a+c)]]) +G14_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1)], [ExprAff(c, a)], + [ExprAff(a, CST2)]]) +G14_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, a+c)]]) G14_EXP_IRA.blocs = {irb.label: irb for irb in [G14_EXP_IRB0, G14_EXP_IRB1]} @@ -496,10 +496,10 @@ G14_EXP_IRA.blocs = {irb.label: irb for irb in [G14_EXP_IRB0, G14_EXP_IRB1]} G15_IRA = IRATest() -G15_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST2)], [ExprAff(a, CST1), - ExprAff(b, a+CST2), - ExprAff(c, CST1)]]) -G15_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, a)]]) +G15_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST2)], [ExprAff(a, CST1), + ExprAff(b, a+CST2), + ExprAff(c, CST1)]]) +G15_IRB1 = gen_irblock(LBL1, [[ExprAff(r, a)]]) G15_IRA.graph.add_uniq_edge(G15_IRB0.label, G15_IRB1.label) @@ -508,8 +508,8 @@ G15_IRA.blocs = {irb.label : irb for irb in [G15_IRB0, G15_IRB1]} # Expected output for graph 1 G15_EXP_IRA = IRATest() -G15_EXP_IRB0 = gen_irbloc(LBL0, [[], [ExprAff(a, CST1)]]) -G15_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, a)]]) +G15_EXP_IRB0 = gen_irblock(LBL0, [[], [ExprAff(a, CST1)]]) +G15_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, a)]]) G15_EXP_IRA.blocs = {irb.label: irb for irb in [G15_EXP_IRB0, G15_EXP_IRB1]} @@ -517,11 +517,11 @@ G15_EXP_IRA.blocs = {irb.label: irb for irb in [G15_EXP_IRB0, G15_EXP_IRB1]} G16_IRA = IRATest() -G16_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, CST1), ExprAff(b, CST2), - ExprAff(c, CST3)], [ExprAff(a, c+CST1), - ExprAff(b, c+CST2)]]) -G16_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, a+b)], [ExprAff(r, c+r)]]) -G16_IRB2 = gen_irbloc(LBL2, [[]]) +G16_IRB0 = gen_irblock(LBL0, [[ExprAff(a, CST1), ExprAff(b, CST2), + ExprAff(c, CST3)], [ExprAff(a, c+CST1), + ExprAff(b, c+CST2)]]) +G16_IRB1 = gen_irblock(LBL1, [[ExprAff(r, a+b)], [ExprAff(r, c+r)]]) +G16_IRB2 = gen_irblock(LBL2, [[]]) G16_IRA.graph.add_uniq_edge(G16_IRB0.label, G16_IRB1.label) G16_IRA.graph.add_uniq_edge(G16_IRB1.label, G16_IRB2.label) @@ -531,9 +531,9 @@ G16_IRA.blocs = {irb.label : irb for irb in [G16_IRB0, G16_IRB1]} # Expected output for graph 1 G16_EXP_IRA = IRATest() -G16_EXP_IRB0 = gen_irbloc(LBL0, [[ExprAff(c, CST3)], [ExprAff(a, c + CST1), - ExprAff(b, c + CST2)]]) -G16_EXP_IRB1 = gen_irbloc(LBL1, [[ExprAff(r, a+b)], [ExprAff(r, c+r)]]) +G16_EXP_IRB0 = gen_irblock(LBL0, [[ExprAff(c, CST3)], [ExprAff(a, c + CST1), + ExprAff(b, c + CST2)]]) +G16_EXP_IRB1 = gen_irblock(LBL1, [[ExprAff(r, a+b)], [ExprAff(r, c+r)]]) G16_EXP_IRA.blocs = {irb.label: irb for irb in [G16_EXP_IRB0, G16_EXP_IRB1]} @@ -541,7 +541,7 @@ G16_EXP_IRA.blocs = {irb.label: irb for irb in [G16_EXP_IRB0, G16_EXP_IRB1]} G17_IRA = IRATest() -G17_IRB0 = gen_irbloc(LBL0, [[ExprAff(a, a*b), +G17_IRB0 = gen_irblock(LBL0, [[ExprAff(a, a*b), ExprAff(b, c), ExprAff(c, CST1)], @@ -602,40 +602,40 @@ G17_IRA.graph.add_node(G17_IRB0.label) # Expected output for graph 17 G17_EXP_IRA = IRATest() -G17_EXP_IRB0 = gen_irbloc(LBL0, [[], +G17_EXP_IRB0 = gen_irblock(LBL0, [[], - [ExprAff(d, d+ CST2)], + [ExprAff(d, d+ CST2)], - [ExprAff(a, CST1)], + [ExprAff(a, CST1)], - [ExprAff(ExprMem(d+CST1), a)], + [ExprAff(ExprMem(d+CST1), a)], - [ExprAff(a, CST1)], + [ExprAff(a, CST1)], - [ExprAff(ExprMem(d+CST2), a)], + [ExprAff(ExprMem(d+CST2), a)], - [ExprAff(a, CST2)], + [ExprAff(a, CST2)], - [ExprAff(a, a+CST1)], + [ExprAff(a, a+CST1)], - [ExprAff(d, a)], + [ExprAff(d, a)], - [ExprAff(d, d+CST1)], + [ExprAff(d, d+CST1)], - [ExprAff(a, CST2)], + [ExprAff(a, CST2)], - [ExprAff(a, a+CST2)], + [ExprAff(a, a+CST2)], - [ExprAff(a, CST2), - ExprAff(b, a)], + [ExprAff(a, CST2), + ExprAff(b, a)], - [ExprAff(a, CST1), - ExprAff(b, a), - ExprAff(c, b)], + [ExprAff(a, CST1), + ExprAff(b, a), + ExprAff(c, b)], - G17_IRB0.irs[14] - # Trick because a+b+c != ((a+b)+c) - ]) + G17_IRB0.irs[14] + # Trick because a+b+c != ((a+b)+c) + ]) G17_EXP_IRA.blocs = {irb.label : irb for irb in [G17_EXP_IRB0]} |