Adding target specific passes.

This commit is contained in:
Siu Kwan Lam 2013-01-02 17:00:59 -06:00
commit 3b399f9d8b
5 changed files with 149 additions and 3 deletions

View file

@ -257,8 +257,21 @@ def get_host_cpu_name():
'''
return _core.LLVMGetHostCPUName()
def get_default_triple():
'''return the target triple of the host in str-rep
'''
return _core.LLVMDefaultTargetTriple()
class TargetMachine(object):
@staticmethod
def new(triple='', cpu='', features='', opt=2):
if not triple and not cpu:
triple = get_default_triple()
cpu = get_host_cpu_name()
ptr = _core.LLVMCreateTargetMachine(triple, cpu, features, opt)
return TargetMachine(ptr)
@staticmethod
def lookup(arch, cpu='', features='', opt=2):
'''create a targetmachine given an architecture name