diff options
Diffstat (limited to 'miasm2/jitter/llvmconvert.py')
| -rw-r--r-- | miasm2/jitter/llvmconvert.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/miasm2/jitter/llvmconvert.py b/miasm2/jitter/llvmconvert.py index b2e1e957..e7a1d6bc 100644 --- a/miasm2/jitter/llvmconvert.py +++ b/miasm2/jitter/llvmconvert.py @@ -1003,10 +1003,10 @@ class LLVMFunction(): # Reactivate object caching self.main_stream = current_main_stream - def gen_pre_code(self, attributes): - if attributes.log_mn: - self.printf("%.8X %s\n" % (attributes.instr.offset, - attributes.instr)) + def gen_pre_code(self, instr_attrib): + if instr_attrib.log_mn: + self.printf("%.8X %s\n" % (instr_attrib.instr.offset, + instr_attrib.instr)) def gen_post_code(self, attributes): if attributes.log_regs: @@ -1110,19 +1110,20 @@ class LLVMFunction(): self.set_ret(dst) - def gen_irblock(self, attrib, instr, instr_offsets, irblock): + def gen_irblock(self, instr_attrib, attributes, instr_offsets, irblock): """ Generate the code for an @irblock - @instr: the current instruction to translate - @irblock: an irbloc instance - @attrib: an Attributs instance + @instr_attrib: an Attributs instance or the instruction to translate + @attributes: list of Attributs corresponding to irblock assignments @instr_offsets: offset of all asmblock's instructions + @irblock: an irblock instance """ case2dst = None case_value = None + instr = instr_attrib.instr - for assignblk in irblock.irs: + for index, assignblk in enumerate(irblock.irs): # Enable cache self.main_stream = True self.expr_cache = {} @@ -1141,12 +1142,12 @@ class LLVMFunction(): values[dst] = self.add_ir(src) # Check memory access exception - if assignblk.mem_read: + if attributes[index].mem_read: self.check_memory_exception(instr.offset, restricted_exception=True) # Check operation exception - if assignblk.op_set_exception: + if attributes[index].op_set_exception: self.check_cpu_exception(instr.offset, restricted_exception=True) # Update the memory @@ -1155,7 +1156,7 @@ class LLVMFunction(): self.affect(src, dst) # Check memory write exception - if assignblk.mem_write: + if attributes[index].mem_write: self.check_memory_exception(instr.offset, restricted_exception=True) @@ -1165,14 +1166,14 @@ class LLVMFunction(): self.affect(src, dst) # Check post assignblk exception flags - if assignblk.set_exception: + if attributes[index].set_exception: self.check_cpu_exception(instr.offset, restricted_exception=True) # Destination assert case2dst is not None if len(case2dst) == 1: # Avoid switch in this common case - self.gen_jump2dst(attrib, instr_offsets, case2dst.values()[0]) + self.gen_jump2dst(instr_attrib, instr_offsets, case2dst.values()[0]) else: current_bbl = self.builder.basic_block @@ -1184,7 +1185,7 @@ class LLVMFunction(): bbl = self.append_basic_block(name) case2bbl[case] = bbl self.builder.position_at_start(bbl) - self.gen_jump2dst(attrib, instr_offsets, dst) + self.gen_jump2dst(instr_attrib, instr_offsets, dst) # Jump on the correct output self.builder.position_at_end(current_bbl) @@ -1311,8 +1312,8 @@ class LLVMFunction(): for instr, irblocks in zip(asmblock.lines, irblocks_list): - attrib = codegen.get_attributes(instr, irblocks, self.log_mn, - self.log_regs) + instr_attrib, irblocks_attributes = codegen.get_attributes(instr, irblocks, self.log_mn, + self.log_regs) # Pre-create basic blocks for irblock in irblocks: @@ -1328,8 +1329,8 @@ class LLVMFunction(): self.builder.position_at_end(self.get_basic_bloc_by_label(name)) if index == 0: - self.gen_pre_code(attrib) - self.gen_irblock(attrib, instr, instr_offsets, irblock) + self.gen_pre_code(instr_attrib) + self.gen_irblock(instr_attrib, irblocks_attributes[index], instr_offsets, irblock) # Gen finalize (see codegen::CGen) is unrecheable, except with delayslot self.gen_finalize(asmblock, codegen) |