diff --git a/llvm/core.py b/llvm/core.py index bed5763..bbe5d01 100644 --- a/llvm/core.py +++ b/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) diff --git a/llvm/ee.py b/llvm/ee.py index 36c0bbf..9531427 100644 --- a/llvm/ee.py +++ b/llvm/ee.py @@ -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() diff --git a/llvm/passes.py b/llvm/passes.py index 9f706d8..6216724 100644 --- a/llvm/passes.py +++ b/llvm/passes.py @@ -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): diff --git a/llvmpy/capsule.py b/llvmpy/capsule.py index ec6fdde..e3b9537 100644 --- a/llvmpy/capsule.py +++ b/llvmpy/capsule.py @@ -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 diff --git a/llvmpy/gen/binding.py b/llvmpy/gen/binding.py index 1b9c799..eeccab1 100644 --- a/llvmpy/gen/binding.py +++ b/llvmpy/gen/binding.py @@ -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()) diff --git a/llvmpy/gen/gen.py b/llvmpy/gen/gen.py index 263c289..cd63b68 100644 --- a/llvmpy/gen/gen.py +++ b/llvmpy/gen/gen.py @@ -80,7 +80,7 @@ static } ''' println(fmt % locals()) - + fn.generate_cpp(println) println('static') diff --git a/llvmpy/src/Argument.py b/llvmpy/src/Argument.py index 4f0b7a4..babbd1c 100644 --- a/llvmpy/src/Argument.py +++ b/llvmpy/src/Argument.py @@ -12,4 +12,4 @@ class Argument: addAttr = Method(Void, ref(Attributes)) removeAttr = Method(Void, ref(Attributes)) getParamAlignment = Method(cast(Unsigned, int)) - + diff --git a/llvmpy/src/BasicBlock.py b/llvmpy/src/BasicBlock.py index 77eaf01..868b3c9 100644 --- a/llvmpy/src/BasicBlock.py +++ b/llvmpy/src/BasicBlock.py @@ -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)) diff --git a/llvmpy/src/Constant.py b/llvmpy/src/Constant.py index 70dc3bf..8a091b5 100644 --- a/llvmpy/src/Constant.py +++ b/llvmpy/src/Constant.py @@ -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)) diff --git a/llvmpy/src/ExecutionEngine/ExecutionEngine.py b/llvmpy/src/ExecutionEngine/ExecutionEngine.py index 038d344..3208269 100644 --- a/llvmpy/src/ExecutionEngine/ExecutionEngine.py +++ b/llvmpy/src/ExecutionEngine/ExecutionEngine.py @@ -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), diff --git a/llvmpy/src/GenericValue.py b/llvmpy/src/GenericValue.py index e587b5f..4dc50d8 100644 --- a/llvmpy/src/GenericValue.py +++ b/llvmpy/src/GenericValue.py @@ -31,4 +31,4 @@ class GenericValue: toFloat = _accessor('ToFloat', cast(Double, float), ptr(Type)) - toPointer = _accessor('ToPointer', cast(VoidPtr, int)) \ No newline at end of file + toPointer = _accessor('ToPointer', cast(VoidPtr, int)) diff --git a/llvmpy/src/GlobalValue.py b/llvmpy/src/GlobalValue.py index 2583c6a..ff499f7 100644 --- a/llvmpy/src/GlobalValue.py +++ b/llvmpy/src/GlobalValue.py @@ -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) diff --git a/llvmpy/src/GlobalVariable.py b/llvmpy/src/GlobalVariable.py index c38df27..8b196c0 100644 --- a/llvmpy/src/GlobalVariable.py +++ b/llvmpy/src/GlobalVariable.py @@ -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)) - \ No newline at end of file diff --git a/llvmpy/src/IRBuilder.py b/llvmpy/src/IRBuilder.py index afd78a0..c0766e9 100644 --- a/llvmpy/src/IRBuilder.py +++ b/llvmpy/src/IRBuilder.py @@ -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() diff --git a/llvmpy/src/Instruction.py b/llvmpy/src/Instruction.py index beb94f1..16f57c2 100644 --- a/llvmpy/src/Instruction.py +++ b/llvmpy/src/Instruction.py @@ -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)) diff --git a/llvmpy/src/Metadata.py b/llvmpy/src/Metadata.py index cfeb6ce..65aac03 100644 --- a/llvmpy/src/Metadata.py +++ b/llvmpy/src/Metadata.py @@ -51,4 +51,4 @@ class NamedMDNode: from llvmpy import extra os = extra.make_raw_ostream_for_printing() self.print_(os, None) - return os.str() \ No newline at end of file + return os.str() diff --git a/llvmpy/src/PassRegistry.py b/llvmpy/src/PassRegistry.py index ede026c..f48e7f0 100644 --- a/llvmpy/src/PassRegistry.py +++ b/llvmpy/src/PassRegistry.py @@ -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) \ No newline at end of file + enumerate = CustomMethod('PassRegistry_enumerate', PyObjectPtr) diff --git a/llvmpy/src/Target/TargetLibraryInfo.py b/llvmpy/src/Target/TargetLibraryInfo.py index 9c47814..3562fa7 100644 --- a/llvmpy/src/Target/TargetLibraryInfo.py +++ b/llvmpy/src/Target/TargetLibraryInfo.py @@ -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 diff --git a/llvmpy/src/Transforms/PassManagerBuilder.py b/llvmpy/src/Transforms/PassManagerBuilder.py index c940062..86be4fb 100644 --- a/llvmpy/src/Transforms/PassManagerBuilder.py +++ b/llvmpy/src/Transforms/PassManagerBuilder.py @@ -10,7 +10,7 @@ from src.Pass import Pass @PassManagerBuilder class PassManagerBuilder: _include_ = 'llvm/Transforms/IPO/PassManagerBuilder.h' - + new = Constructor() delete = Destructor() diff --git a/llvmpy/src/Type.py b/llvmpy/src/Type.py index ea1f0e5..874201e 100644 --- a/llvmpy/src/Type.py +++ b/llvmpy/src/Type.py @@ -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), diff --git a/llvmpy/src/Value.py b/llvmpy/src/Value.py index 669ed80..f9fddae 100644 --- a/llvmpy/src/Value.py +++ b/llvmpy/src/Value.py @@ -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 ''') diff --git a/llvmpy/test_binding.py b/llvmpy/test_binding.py index aee0167..0e833e3 100644 --- a/llvmpy/test_binding.py +++ b/llvmpy/test_binding.py @@ -112,7 +112,7 @@ def test_basic_jit_use(): fpm.doInitialization() fpm.run(fn) fpm.doFinalization() - + pm.run(m) print(m)