remove excess whitespace
This commit is contained in:
parent
ba759b59d0
commit
f8deae06dd
22 changed files with 69 additions and 70 deletions
34
llvm/core.py
34
llvm/core.py
|
|
@ -388,7 +388,7 @@ class Module(llvm.Wrapper):
|
|||
return str(self) == str(rhs)
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def __ne__(self, rhs):
|
||||
return not (self == rhs)
|
||||
|
||||
|
|
@ -429,7 +429,7 @@ class Module(llvm.Wrapper):
|
|||
|
||||
The `other' module is no longer valid after this method is
|
||||
invoked, all refs to it should be dropped.
|
||||
|
||||
|
||||
In the future, this API might be replaced with a full-fledged
|
||||
Linker class.
|
||||
"""
|
||||
|
|
@ -560,7 +560,7 @@ class Module(llvm.Wrapper):
|
|||
pm = PassManager.new()._ptr
|
||||
formatted
|
||||
failed = tm.addPassesToEmitFile(pm, fileobj, cgft, False)
|
||||
|
||||
|
||||
if failed:
|
||||
raise llvm.LLVMException("Failed to write native object file")
|
||||
if ret:
|
||||
|
|
@ -664,7 +664,7 @@ class Type(llvm.Wrapper):
|
|||
context = api.llvm.getGlobalContext()
|
||||
ptr = api.llvm.Type.getFP128Ty(context)
|
||||
return Type(ptr)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def ppc_fp128():
|
||||
"""Create a 128-bit floating point type (two 64-bits)."""
|
||||
|
|
@ -920,7 +920,7 @@ class PointerType(Type):
|
|||
|
||||
class VectorType(Type):
|
||||
_type_ = api.llvm.VectorType
|
||||
|
||||
|
||||
@property
|
||||
def element(self):
|
||||
return Type(self._ptr.getVectorElementType())
|
||||
|
|
@ -989,7 +989,7 @@ class Value(llvm.Wrapper):
|
|||
@property
|
||||
def use_count(self):
|
||||
return self._ptr.getNumUses()
|
||||
|
||||
|
||||
@property
|
||||
def uses(self):
|
||||
return list(map(_make_value, self._ptr.list_use()))
|
||||
|
|
@ -1263,7 +1263,7 @@ class GlobalValue(Constant):
|
|||
|
||||
def _set_linkage(self, value):
|
||||
self._ptr.setLinkage(value)
|
||||
|
||||
|
||||
linkage = property(_get_linkage, _set_linkage)
|
||||
|
||||
def _get_section(self):
|
||||
|
|
@ -1287,7 +1287,7 @@ class GlobalValue(Constant):
|
|||
|
||||
def _set_alignment(self, value):
|
||||
return self._ptr.setAlignment(value)
|
||||
|
||||
|
||||
alignment = property(_get_alignment, _set_alignment)
|
||||
|
||||
@property
|
||||
|
|
@ -1490,7 +1490,7 @@ class Function(GlobalValue):
|
|||
@property
|
||||
def basic_blocks(self):
|
||||
return list(map(_make_value, self._ptr.getBasicBlockList()))
|
||||
|
||||
|
||||
def viewCFG(self):
|
||||
return self._ptr.viewCFG()
|
||||
|
||||
|
|
@ -1510,7 +1510,7 @@ class Function(GlobalValue):
|
|||
def verify(self):
|
||||
# Although we're just asking LLVM to return the success or
|
||||
# failure, it appears to print result to stderr and abort.
|
||||
|
||||
|
||||
# Note: LLVM has a bug in preverifier that will always abort
|
||||
# the process upon failure.
|
||||
actions = api.llvm.VerifierFailureAction
|
||||
|
|
@ -1528,7 +1528,7 @@ class Function(GlobalValue):
|
|||
|
||||
class InlineAsm(Value):
|
||||
_type_ = api.llvm.InlineAsm
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get(functype, asm, constrains, side_effect=False,
|
||||
align_stack=False, dialect=api.llvm.InlineAsm.AsmDialect.AD_ATT):
|
||||
|
|
@ -1609,7 +1609,7 @@ class NamedMetaData(llvm.Wrapper):
|
|||
def delete(self):
|
||||
_ValueFactory.delete(self._ptr)
|
||||
self._ptr.eraseFromParent()
|
||||
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._ptr.getName()
|
||||
|
|
@ -1639,7 +1639,7 @@ class Instruction(User):
|
|||
@property
|
||||
def is_binary_op(self):
|
||||
return self._ptr.isBinaryOp()
|
||||
|
||||
|
||||
@property
|
||||
def is_shift(self):
|
||||
return self._ptr.isShift()
|
||||
|
|
@ -1663,7 +1663,7 @@ class Instruction(User):
|
|||
@property
|
||||
def is_commutative(self):
|
||||
return self._ptr.isCommutative()
|
||||
|
||||
|
||||
@property
|
||||
def is_volatile(self):
|
||||
"""True if this is a volatile load or store."""
|
||||
|
|
@ -1925,7 +1925,7 @@ class Builder(llvm.Wrapper):
|
|||
def ret_void(self):
|
||||
self._guard_terminators()
|
||||
return _make_value(self._ptr.CreateRetVoid())
|
||||
|
||||
|
||||
def ret(self, value):
|
||||
self._guard_terminators()
|
||||
return _make_value(self._ptr.CreateRet(value._ptr))
|
||||
|
|
@ -2039,7 +2039,7 @@ class Builder(llvm.Wrapper):
|
|||
"")
|
||||
inst = self._ptr.Insert(malloc, name)
|
||||
return _make_value(inst)
|
||||
|
||||
|
||||
def malloc_array(self, ty, size, name=""):
|
||||
context = api.llvm.getGlobalContext()
|
||||
allocsz = api.llvm.ConstantExpr.getSizeOf(ty._ptr)
|
||||
|
|
@ -2242,7 +2242,7 @@ class Builder(llvm.Wrapper):
|
|||
|
||||
def atomic_umin(self, *args, **kwargs):
|
||||
return self.atomic_rmw('umin', *args, **kwargs)
|
||||
|
||||
|
||||
def atomic_load(self, ptr, ordering, align=1, crossthread=True,
|
||||
volatile=False, name=""):
|
||||
inst = self.load(ptr, align=align, volatile=volatile, name=name)
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class EngineBuilder(llvm.Wrapper):
|
|||
|
||||
def select_target(self, *args):
|
||||
'''get the corresponding target machine
|
||||
|
||||
|
||||
Accept no arguments or (triple, march, mcpu, mattrs)
|
||||
'''
|
||||
if args:
|
||||
|
|
@ -338,7 +338,7 @@ class TargetMachine(llvm.Wrapper):
|
|||
@property
|
||||
def cpu(self):
|
||||
return self._ptr.getTargetCPU()
|
||||
|
||||
|
||||
@property
|
||||
def feature_string(self):
|
||||
return self._ptr.getTargetFeatureString()
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class PassManagerBuilder(llvm.Wrapper):
|
|||
@vectorize.setter
|
||||
def vectorize(self, enable):
|
||||
self._ptr.Vectorize = enable
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def loop_vectorize(self):
|
||||
|
|
@ -200,7 +200,7 @@ class Pass(llvm.Wrapper):
|
|||
try:
|
||||
return self.__name
|
||||
except AttributeError:
|
||||
return
|
||||
return
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Capsule(object):
|
|||
"Wraps PyCapsule so that we can build weakref of it."
|
||||
|
||||
from ._capsule import check, getClassName, getName, getPointer
|
||||
|
||||
|
||||
def __init__(self, capsule):
|
||||
assert Capsule.valid(capsule)
|
||||
self.capsule = capsule
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ class Class(SubModule, _Type):
|
|||
|
||||
class Enum(object):
|
||||
format = 'O'
|
||||
|
||||
|
||||
def __init__(self, *value_names):
|
||||
self.parent = None
|
||||
if len(value_names) == 1:
|
||||
|
|
@ -507,7 +507,7 @@ class Method(object):
|
|||
def is_return_ownedptr(self):
|
||||
retty = self.signatures[0][0]
|
||||
return isinstance(retty, ownedptr)
|
||||
|
||||
|
||||
def process_ownedptr_args(self, writer, unwrapped):
|
||||
argtys = self.signatures[0][1:]
|
||||
for i, ty in enumerate(argtys):
|
||||
|
|
@ -525,7 +525,7 @@ class CustomMethod(Method):
|
|||
ret = writer.call(self.methodname, retty.fullname, *args)
|
||||
writer.return_value(retty.wrap(writer, ret))
|
||||
|
||||
|
||||
|
||||
class StaticMethod(Method):
|
||||
|
||||
def compile_cpp_body(self, writer, retty, argtys):
|
||||
|
|
@ -544,7 +544,7 @@ class StaticMethod(Method):
|
|||
with decl as varargs:
|
||||
unwrapped = writer.unwrap_many(varargs)
|
||||
self.process_ownedptr_args(writer, unwrapped)
|
||||
|
||||
|
||||
func = '.'.join([self.parent.py_name, self.name])
|
||||
ret = writer.call('_api.%s' % func, varargs=unwrapped)
|
||||
wrapped = writer.wrap(ret, self.is_return_ownedptr())
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ static
|
|||
}
|
||||
'''
|
||||
println(fmt % locals())
|
||||
|
||||
|
||||
fn.generate_cpp(println)
|
||||
|
||||
println('static')
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ class Argument:
|
|||
addAttr = Method(Void, ref(Attributes))
|
||||
removeAttr = Method(Void, ref(Attributes))
|
||||
getParamAlignment = Method(cast(Unsigned, int))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class BasicBlock:
|
|||
|
||||
getParent = Method(ptr(Function))
|
||||
getTerminator = Method(ptr(TerminatorInst))
|
||||
|
||||
|
||||
empty = Method(cast(Bool, bool))
|
||||
dropAllReferences = Method()
|
||||
isLandingPad = Method(cast(Bool, bool))
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class UndefValue:
|
|||
@ConstantInt
|
||||
class ConstantInt:
|
||||
_downcast_ = Constant, Value
|
||||
|
||||
|
||||
get = StaticMethod(ptr(ConstantInt),
|
||||
ptr(IntegerType),
|
||||
cast(int, Uint64),
|
||||
|
|
@ -89,7 +89,7 @@ class ConstantInt:
|
|||
@ConstantFP
|
||||
class ConstantFP:
|
||||
_downcast_ = Constant, Value
|
||||
|
||||
|
||||
get = StaticMethod(ptr(Constant), ptr(Type), cast(float, Double))
|
||||
getNegativeZero = StaticMethod(ptr(ConstantFP), ptr(Type))
|
||||
getInfinity = StaticMethod(ptr(ConstantFP), ptr(Type), cast(bool, Bool))
|
||||
|
|
@ -103,7 +103,7 @@ class ConstantFP:
|
|||
@ConstantArray
|
||||
class ConstantArray:
|
||||
_downcast_ = Constant, Value
|
||||
|
||||
|
||||
get = CustomStaticMethod('ConstantArray_get',
|
||||
PyObjectPtr, # ptr(Constant),
|
||||
ptr(ArrayType),
|
||||
|
|
@ -114,7 +114,7 @@ class ConstantArray:
|
|||
@ConstantStruct
|
||||
class ConstantStruct:
|
||||
_downcast_ = Constant, Value
|
||||
|
||||
|
||||
get = CustomStaticMethod('ConstantStruct_get',
|
||||
PyObjectPtr, # ptr(Constant)
|
||||
ptr(StructType),
|
||||
|
|
@ -130,7 +130,7 @@ class ConstantStruct:
|
|||
@ConstantVector
|
||||
class ConstantVector:
|
||||
_downcast_ = Constant, Value
|
||||
|
||||
|
||||
get = CustomStaticMethod('ConstantVector_get',
|
||||
PyObjectPtr, # ptr(Constant)
|
||||
PyObjectPtr, # constants
|
||||
|
|
@ -145,7 +145,7 @@ class ConstantDataSequential:
|
|||
@ConstantDataArray
|
||||
class ConstantDataArray:
|
||||
_downcast_ = Constant, Value
|
||||
|
||||
|
||||
getString = StaticMethod(ptr(Constant),
|
||||
ref(LLVMContext),
|
||||
cast(str, StringRef),
|
||||
|
|
@ -178,7 +178,7 @@ def _factory_const_type():
|
|||
@ConstantExpr
|
||||
class ConstantExpr:
|
||||
_downcast_ = Constant, Value
|
||||
|
||||
|
||||
getAlignOf = _factory(ptr(Type))
|
||||
getSizeOf = _factory(ptr(Type))
|
||||
getOffsetOf = _factory(ptr(Type), ptr(Constant))
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class ExecutionEngine:
|
|||
'llvm/ExecutionEngine/JIT.h') # force linking of jit
|
||||
|
||||
delete = Destructor()
|
||||
|
||||
|
||||
create = CustomStaticMethod('ExecutionEngine_create',
|
||||
ptr(ExecutionEngine),
|
||||
ownedptr(Module), cast(bool, Bool),
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@ class GenericValue:
|
|||
|
||||
toFloat = _accessor('ToFloat', cast(Double, float), ptr(Type))
|
||||
|
||||
toPointer = _accessor('ToPointer', cast(VoidPtr, int))
|
||||
toPointer = _accessor('ToPointer', cast(VoidPtr, int))
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@ class GlobalValue:
|
|||
_include_ = 'llvm/GlobalValue.h'
|
||||
|
||||
LinkageTypes = Enum('''
|
||||
ExternalLinkage, AvailableExternallyLinkage, LinkOnceAnyLinkage,
|
||||
LinkOnceODRLinkage, LinkOnceODRAutoHideLinkage, WeakAnyLinkage,
|
||||
WeakODRLinkage, AppendingLinkage, InternalLinkage, PrivateLinkage,
|
||||
LinkerPrivateLinkage, LinkerPrivateWeakLinkage, DLLImportLinkage,
|
||||
ExternalLinkage, AvailableExternallyLinkage, LinkOnceAnyLinkage,
|
||||
LinkOnceODRLinkage, LinkOnceODRAutoHideLinkage, WeakAnyLinkage,
|
||||
WeakODRLinkage, AppendingLinkage, InternalLinkage, PrivateLinkage,
|
||||
LinkerPrivateLinkage, LinkerPrivateWeakLinkage, DLLImportLinkage,
|
||||
DLLExportLinkage, ExternalWeakLinkage, CommonLinkage
|
||||
''')
|
||||
|
||||
VisibilityTypes = Enum('''DefaultVisibility,
|
||||
HiddenVisibility,
|
||||
VisibilityTypes = Enum('''DefaultVisibility,
|
||||
HiddenVisibility,
|
||||
ProtectedVisibility''')
|
||||
|
||||
setLinkage = Method(Void, LinkageTypes)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from .Value import Constant
|
|||
|
||||
@GlobalVariable
|
||||
class GlobalVariable:
|
||||
ThreadLocalMode = Enum('''NotThreadLocal, GeneralDynamicTLSModel,
|
||||
ThreadLocalMode = Enum('''NotThreadLocal, GeneralDynamicTLSModel,
|
||||
LocalDynamicTLSModel, InitialExecTLSModel,
|
||||
LocalExecTLSModel
|
||||
''')
|
||||
|
|
@ -46,4 +46,3 @@ class GlobalVariable:
|
|||
# setExternallyinitialized = Method(Void, cast(bool, Bool))
|
||||
|
||||
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ class IRBuilder:
|
|||
cast(bool, Bool)]
|
||||
op = Method(*sig).require_only(2)
|
||||
return op
|
||||
|
||||
|
||||
CreateUDiv = _binop_is_exact()
|
||||
CreateSDiv = _binop_is_exact()
|
||||
CreateLShr = _binop_is_exact()
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class Instruction:
|
|||
insertBefore = Method(Void, ptr(Instruction))
|
||||
insertAfter = Method(Void, ptr(Instruction))
|
||||
moveBefore = Method(Void, ptr(Instruction))
|
||||
|
||||
|
||||
isTerminator = Method(cast(Bool, bool))
|
||||
isBinaryOp = Method(cast(Bool, bool))
|
||||
isShift = Method(cast(Bool, bool))
|
||||
|
|
@ -135,7 +135,7 @@ class BinaryOperator:
|
|||
@CallInst
|
||||
class CallInst:
|
||||
_downcast_ = Value, User, Instruction
|
||||
|
||||
|
||||
getCallingConv = Method(CallingConv.ID)
|
||||
setCallingConv = Method(Void, CallingConv.ID)
|
||||
getParamAlignment = Method(cast(Unsigned, int), cast(int, Unsigned))
|
||||
|
|
@ -298,7 +298,7 @@ class ReturnInst:
|
|||
@SwitchInst
|
||||
class SwitchInst:
|
||||
_downcast_ = Value, Instruction
|
||||
|
||||
|
||||
getCondition = Method(ptr(Value))
|
||||
setCondition = Method(Void, ptr(Value))
|
||||
getDefaultDest = Method(ptr(BasicBlock))
|
||||
|
|
|
|||
|
|
@ -51,4 +51,4 @@ class NamedMDNode:
|
|||
from llvmpy import extra
|
||||
os = extra.make_raw_ostream_for_printing()
|
||||
self.print_(os, None)
|
||||
return os.str()
|
||||
return os.str()
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ class PassRegistry:
|
|||
|
||||
# This is a custom method that wraps enumerateWith
|
||||
# Returns list of tuples of (pass-arg, pass-name)
|
||||
enumerate = CustomMethod('PassRegistry_enumerate', PyObjectPtr)
|
||||
enumerate = CustomMethod('PassRegistry_enumerate', PyObjectPtr)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ LibFunc.Enum('Func', '''
|
|||
ZdaPv, ZdlPv, Znaj, ZnajRKSt9nothrow_t,
|
||||
Znam, ZnamRKSt9nothrow_t, Znwj, ZnwjRKSt9nothrow_t,
|
||||
Znwm, ZnwmRKSt9nothrow_t, cxa_atexit, cxa_guard_abort,
|
||||
cxa_guard_acquire, cxa_guard_release, memcpy_chk,
|
||||
cxa_guard_acquire, cxa_guard_release, memcpy_chk,
|
||||
acos, acosf, acosh, acoshf,
|
||||
acoshl, acosl, asin, asinf,
|
||||
asinh, asinhf, asinhl, asinl,
|
||||
|
|
@ -38,17 +38,17 @@ LibFunc.Enum('Func', '''
|
|||
powl, putchar, puts,
|
||||
realloc, reallocf, rint, rintf,
|
||||
rintl, round, roundf, roundl,
|
||||
sin, sinf, sinh, sinhf,
|
||||
sinhl, sinl, siprintf,
|
||||
sqrt, sqrtf, sqrtl, stpcpy,
|
||||
strcat, strchr, strcmp, strcpy,
|
||||
strcspn, strdup, strlen, strncat,
|
||||
strncmp, strncpy, strndup, strnlen,
|
||||
strpbrk, strrchr, strspn, strstr,
|
||||
strtod, strtof, strtol, strtold,
|
||||
sin, sinf, sinh, sinhf,
|
||||
sinhl, sinl, siprintf,
|
||||
sqrt, sqrtf, sqrtl, stpcpy,
|
||||
strcat, strchr, strcmp, strcpy,
|
||||
strcspn, strdup, strlen, strncat,
|
||||
strncmp, strncpy, strndup, strnlen,
|
||||
strpbrk, strrchr, strspn, strstr,
|
||||
strtod, strtof, strtol, strtold,
|
||||
strtoll, strtoul, strtoull, tan,
|
||||
tanf, tanh, tanhf, tanhl,
|
||||
tanl, trunc, truncf,
|
||||
tanf, tanh, tanhf, tanhl,
|
||||
tanl, trunc, truncf,
|
||||
truncl, valloc, NumLibFuncs''')
|
||||
# not in llvm-3.2 abs, ffs, ffsl, ffsll, fprintf, isascii,
|
||||
# isdigit, labs, llabs, printf, sprintf, toascii
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from src.Pass import Pass
|
|||
@PassManagerBuilder
|
||||
class PassManagerBuilder:
|
||||
_include_ = 'llvm/Transforms/IPO/PassManagerBuilder.h'
|
||||
|
||||
|
||||
new = Constructor()
|
||||
delete = Destructor()
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ class StructType:
|
|||
).require_only(1)
|
||||
getNumElements = Method(cast(Unsigned, int))
|
||||
getElementType = Method(ptr(Type), cast(int, Unsigned))
|
||||
|
||||
|
||||
create = StaticMethod(ptr(StructType),
|
||||
ref(LLVMContext),
|
||||
cast(str, StringRef),
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ class Value:
|
|||
ValueTy = Enum('''
|
||||
ArgumentVal, BasicBlockVal, FunctionVal, GlobalAliasVal,
|
||||
GlobalVariableVal, UndefValueVal, BlockAddressVal, ConstantExprVal,
|
||||
ConstantAggregateZeroVal, ConstantDataArrayVal, ConstantDataVectorVal,
|
||||
ConstantIntVal, ConstantFPVal, ConstantArrayVal, ConstantStructVal,
|
||||
ConstantVectorVal, ConstantPointerNullVal, MDNodeVal, MDStringVal,
|
||||
InlineAsmVal, PseudoSourceValueVal, FixedStackPseudoSourceValueVal,
|
||||
ConstantAggregateZeroVal, ConstantDataArrayVal, ConstantDataVectorVal,
|
||||
ConstantIntVal, ConstantFPVal, ConstantArrayVal, ConstantStructVal,
|
||||
ConstantVectorVal, ConstantPointerNullVal, MDNodeVal, MDStringVal,
|
||||
InlineAsmVal, PseudoSourceValueVal, FixedStackPseudoSourceValueVal,
|
||||
InstructionVal, ConstantFirstVal, ConstantLastVal
|
||||
''')
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ def test_basic_jit_use():
|
|||
fpm.doInitialization()
|
||||
fpm.run(fn)
|
||||
fpm.doFinalization()
|
||||
|
||||
|
||||
pm.run(m)
|
||||
|
||||
print(m)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue