Begin to expose Pass class.
This commit is contained in:
parent
b22c023301
commit
ff92a05858
6 changed files with 182 additions and 259 deletions
75
llvm/ee.py
75
llvm/ee.py
|
|
@ -40,6 +40,10 @@ import logging
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# re-export TargetData for backward compatibility.
|
||||
from llvm.passes import TargetData
|
||||
|
||||
#===----------------------------------------------------------------------===
|
||||
# Enumerations
|
||||
#===----------------------------------------------------------------------===
|
||||
|
|
@ -48,76 +52,6 @@ BO_BIG_ENDIAN = 0
|
|||
BO_LITTLE_ENDIAN = 1
|
||||
|
||||
|
||||
#===----------------------------------------------------------------------===
|
||||
# Target data
|
||||
#===----------------------------------------------------------------------===
|
||||
|
||||
class TargetData(llvm.Ownable):
|
||||
|
||||
@staticmethod
|
||||
def new(strrep):
|
||||
return TargetData(_core.LLVMCreateTargetData(strrep))
|
||||
|
||||
def __init__(self, ptr):
|
||||
llvm.Ownable.__init__(self, ptr, _core.LLVMDisposeTargetData)
|
||||
|
||||
def __str__(self):
|
||||
return _core.LLVMTargetDataAsString(self.ptr)
|
||||
|
||||
@property
|
||||
def byte_order(self):
|
||||
return _core.LLVMByteOrder(self.ptr)
|
||||
|
||||
@property
|
||||
def pointer_size(self):
|
||||
return _core.LLVMPointerSize(self.ptr)
|
||||
|
||||
@property
|
||||
def target_integer_type(self):
|
||||
ptr = _core.LLVMIntPtrType(self.ptr);
|
||||
return core.IntegerType(ptr, core.TYPE_INTEGER)
|
||||
|
||||
def size(self, ty):
|
||||
core.check_is_type(ty)
|
||||
return _core.LLVMSizeOfTypeInBits(self.ptr, ty.ptr)
|
||||
|
||||
def store_size(self, ty):
|
||||
core.check_is_type(ty)
|
||||
return _core.LLVMStoreSizeOfType(self.ptr, ty.ptr)
|
||||
|
||||
def abi_size(self, ty):
|
||||
core.check_is_type(ty)
|
||||
return _core.LLVMABISizeOfType(self.ptr, ty.ptr)
|
||||
|
||||
def abi_alignment(self, ty):
|
||||
core.check_is_type(ty)
|
||||
return _core.LLVMABIAlignmentOfType(self.ptr, ty.ptr)
|
||||
|
||||
def callframe_alignment(self, ty):
|
||||
core.check_is_type(ty)
|
||||
return _core.LLVMCallFrameAlignmentOfType(self.ptr, ty.ptr)
|
||||
|
||||
def preferred_alignment(self, ty_or_gv):
|
||||
if isinstance(ty_or_gv, core.Type):
|
||||
return _core.LLVMPreferredAlignmentOfType(self.ptr,
|
||||
ty_or_gv.ptr)
|
||||
elif isinstance(ty_or_gv, core.GlobalVariable):
|
||||
return _core.LLVMPreferredAlignmentOfGlobal(self.ptr,
|
||||
ty_or_gv.ptr)
|
||||
else:
|
||||
raise core.LLVMException("argument is neither a type nor a global variable")
|
||||
|
||||
def element_at_offset(self, ty, ofs):
|
||||
core.check_is_type_struct(ty)
|
||||
ofs = int(ofs) # ofs is unsigned long long
|
||||
return _core.LLVMElementAtOffset(self.ptr, ty.ptr, ofs)
|
||||
|
||||
def offset_of_element(self, ty, el):
|
||||
core.check_is_type_struct(ty)
|
||||
el = int(el) # el should be an int
|
||||
return _core.LLVMOffsetOfElement(self.ptr, ty.ptr, el)
|
||||
|
||||
|
||||
#===----------------------------------------------------------------------===
|
||||
# Generic value
|
||||
#===----------------------------------------------------------------------===
|
||||
|
|
@ -383,3 +317,4 @@ class TargetMachine(object):
|
|||
@property
|
||||
def feature_string(self):
|
||||
return _core.LLVMTargetMachineGetFS(self.ptr)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue