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

Public Member Functions

def __init__
 
def add_memlookups
 
def add_get_exceptionflag
 
def add_op
 
def add_log_functions
 
def set_vmcpu
 
def set_IR_transformation
 
def optimise_level
 
def get_execengine
 
def get_passmanager
 
def get_module
 
def add_shared_library
 
def add_fc
 

Public Attributes

 vmcpu
 
 IR_transformation_functions
 
 mod
 
 pass_manager
 
 exec_engine
 

Static Public Attributes

dictionary known_fc = {}
 

Detailed Description

Definition at line 120 of file llvmconvert.py.

Constructor & Destructor Documentation

def miasm2.jitter.llvmconvert.LLVMContext_JIT.__init__ (   self,
  library_filenames,
  name = "mod" 
)

Definition at line 124 of file llvmconvert.py.

125  def __init__(self, library_filenames, name="mod"):
126  "Init a LLVMContext object, and load the mem management shared library"
127  LLVMContext.__init__(self, name)
128  for lib_fname in library_filenames:
129  self.add_shared_library(lib_fname)
130  self.add_memlookups()
131  self.add_get_exceptionflag()
132  self.add_op()
134  self.vmcpu = {}

+ Here is the call graph for this function:

Member Function Documentation

def miasm2.jitter.llvmconvert.LLVMContext.add_fc (   self,
  fc 
)
inherited

Definition at line 111 of file llvmconvert.py.

112  def add_fc(self, fc):
113  "Add function into known_fc"
114 
115  for name, detail in fc.items():
116  self.mod.add_function(LLVMType.function(detail["ret"],
117  detail["args"]),
118  name)
119 

+ Here is the caller graph for this function:

def miasm2.jitter.llvmconvert.LLVMContext_JIT.add_get_exceptionflag (   self)

Definition at line 152 of file llvmconvert.py.

153  def add_get_exceptionflag(self):
154  "Add 'get_exception_flag' function"
155  p8 = llvm_c.PointerType.pointer(LLVMType.int(8))
156  self.add_fc({"get_exception_flag": {"ret": LLVMType.int(64),
157  "args": [p8]}})

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.jitter.llvmconvert.LLVMContext_JIT.add_log_functions (   self)

Definition at line 196 of file llvmconvert.py.

197  def add_log_functions(self):
198  "Add functions for state logging"
199 
200  p8 = llvm_c.PointerType.pointer(LLVMType.int(8))
201  self.add_fc({"dump_gpregs": {"ret": LLVMType.void(),
202  "args": [p8]}})

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.jitter.llvmconvert.LLVMContext_JIT.add_memlookups (   self)

Definition at line 135 of file llvmconvert.py.

136  def add_memlookups(self):
137  "Add MEM_LOOKUP functions"
138 
139  fc = {}
140  p8 = llvm_c.PointerType.pointer(LLVMType.int(8))
141  for i in [8, 16, 32, 64]:
142  fc["MEM_LOOKUP_%02d" % i] = {"ret": LLVMType.int(i),
143  "args": [p8,
144  LLVMType.int(64)]}
145 
146  fc["MEM_WRITE_%02d" % i] = {"ret": LLVMType.void(),
147  "args": [p8,
148  LLVMType.int(64),
149  LLVMType.int(i)]}
150 
151  self.add_fc(fc)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.jitter.llvmconvert.LLVMContext_JIT.add_op (   self)

Definition at line 158 of file llvmconvert.py.

159  def add_op(self):
160  "Add operations functions"
161 
162  p8 = llvm_c.PointerType.pointer(LLVMType.int(8))
163  self.add_fc({"parity": {"ret": LLVMType.int(),
164  "args": [LLVMType.int()]}})
165  self.add_fc({"rot_left": {"ret": LLVMType.int(),
166  "args": [LLVMType.int(),
167  LLVMType.int(),
168  LLVMType.int()]}})
169  self.add_fc({"rot_right": {"ret": LLVMType.int(),
170  "args": [LLVMType.int(),
171  LLVMType.int(),
172  LLVMType.int()]}})
173 
174  self.add_fc({"segm2addr": {"ret": LLVMType.int(64),
175  "args": [p8,
176  LLVMType.int(64),
177  LLVMType.int(64)]}})
178 
179  for k in [8, 16]:
180  self.add_fc({"bcdadd_%s" % k: {"ret": LLVMType.int(k),
181  "args": [LLVMType.int(k),
182  LLVMType.int(k)]}})
183  self.add_fc({"bcdadd_cf_%s" % k: {"ret": LLVMType.int(k),
184  "args": [LLVMType.int(k),
185  LLVMType.int(k)]}})
186 
187  for k in [16, 32, 64]:
188  self.add_fc({"imod%s" % k: {"ret": LLVMType.int(k),
189  "args": [p8,
190  LLVMType.int(k),
191  LLVMType.int(k)]}})
192  self.add_fc({"idiv%s" % k: {"ret": LLVMType.int(k),
193  "args": [p8,
194  LLVMType.int(k),
195  LLVMType.int(k)]}})

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.jitter.llvmconvert.LLVMContext.add_shared_library (   self,
  filename 
)
inherited

Definition at line 107 of file llvmconvert.py.

108  def add_shared_library(self, filename):
109  "Load the shared library 'filename'"
110  return llvm_c.load_library_permanently(filename)

+ Here is the caller graph for this function:

def miasm2.jitter.llvmconvert.LLVMContext.get_execengine (   self)
inherited

Definition at line 95 of file llvmconvert.py.

95 
96  def get_execengine(self):
97  "Return the Execution Engine associated with this context"
98  return self.exec_engine
def miasm2.jitter.llvmconvert.LLVMContext.get_module (   self)
inherited

Definition at line 103 of file llvmconvert.py.

104  def get_module(self):
105  "Return the module associated with this context"
106  return self.mod
def miasm2.jitter.llvmconvert.LLVMContext.get_passmanager (   self)
inherited

Definition at line 99 of file llvmconvert.py.

99 
100  def get_passmanager(self):
101  "Return the Pass Manager associated with this context"
102  return self.exec_engine
def miasm2.jitter.llvmconvert.LLVMContext.optimise_level (   self,
  classic_passes = True,
  dead_passes = True 
)
inherited
Set the optimisation level :
classic_passes :
 - combine instruction
 - reassociate
 - global value numbering
 - simplify cfg

dead_passes :
 - dead code
 - dead store
 - dead instructions

Definition at line 66 of file llvmconvert.py.

66 
67  def optimise_level(self, classic_passes=True, dead_passes=True):
68  """Set the optimisation level :
69  classic_passes :
70  - combine instruction
71  - reassociate
72  - global value numbering
73  - simplify cfg
74 
75  dead_passes :
76  - dead code
77  - dead store
78  - dead instructions
79  """
80 
81  # Set up the optimiser pipeline
82 
83  if classic_passes is True:
84  # self.pass_manager.add(llvm_p.PASS_INSTCOMBINE)
85  self.pass_manager.add(llvm_p.PASS_REASSOCIATE)
86  self.pass_manager.add(llvm_p.PASS_GVN)
87  self.pass_manager.add(llvm_p.PASS_SIMPLIFYCFG)
88 
89  if dead_passes is True:
90  self.pass_manager.add(llvm_p.PASS_DCE)
91  self.pass_manager.add(llvm_p.PASS_DSE)
92  self.pass_manager.add(llvm_p.PASS_DIE)
93 
94  self.pass_manager.initialize()
def miasm2.jitter.llvmconvert.LLVMContext_JIT.set_IR_transformation (   self,
  args 
)
Set a list of transformation to apply on expression before their
treatments.
args: function Expr(Expr)

Definition at line 208 of file llvmconvert.py.

209  def set_IR_transformation(self, *args):
210  """Set a list of transformation to apply on expression before their
211  treatments.
212  args: function Expr(Expr)"""
213  self.IR_transformation_functions = args
214 
def miasm2.jitter.llvmconvert.LLVMContext_JIT.set_vmcpu (   self,
  lookup_table 
)

Definition at line 203 of file llvmconvert.py.

204  def set_vmcpu(self, lookup_table):
205  "Set the correspondance between register name and vmcpu offset"
206 
207  self.vmcpu = lookup_table

Member Data Documentation

miasm2.jitter.llvmconvert.LLVMContext.exec_engine
inherited

Definition at line 63 of file llvmconvert.py.

miasm2.jitter.llvmconvert.LLVMContext_JIT.IR_transformation_functions

Definition at line 212 of file llvmconvert.py.

dictionary miasm2.jitter.llvmconvert.LLVMContext.known_fc = {}
staticinherited

Definition at line 57 of file llvmconvert.py.

miasm2.jitter.llvmconvert.LLVMContext.mod
inherited

Definition at line 61 of file llvmconvert.py.

miasm2.jitter.llvmconvert.LLVMContext.pass_manager
inherited

Definition at line 62 of file llvmconvert.py.

miasm2.jitter.llvmconvert.LLVMContext_JIT.vmcpu

Definition at line 133 of file llvmconvert.py.


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