fix spaces redundant trailing spaces and missing line break at EOF

This commit is contained in:
Siu Kwan Lam 2013-09-18 11:58:05 -05:00
commit 6e55bfc406
19 changed files with 594 additions and 594 deletions

View file

@ -211,7 +211,7 @@ class CCEnum(Enum):
CC_X86_THISCALL = ID.X86_ThisCall CC_X86_THISCALL = ID.X86_ThisCall
CC_PTX_KERNEL = ID.PTX_Kernel CC_PTX_KERNEL = ID.PTX_Kernel
CC_PTX_DEVICE = ID.PTX_Device CC_PTX_DEVICE = ID.PTX_Device
if llvm.version <= (3, 3): if llvm.version <= (3, 3):
CC_MBLAZE_INTR = ID.MBLAZE_INTR CC_MBLAZE_INTR = ID.MBLAZE_INTR
CC_MBLAZE_SVOL = ID.MBLAZE_SVOL CC_MBLAZE_SVOL = ID.MBLAZE_SVOL
@ -221,7 +221,7 @@ CCEnum.declare()
# int predicates # int predicates
class ICMPEnum(Enum): class ICMPEnum(Enum):
prefix = 'ICMP_' prefix = 'ICMP_'
Predicate = api.llvm.CmpInst.Predicate Predicate = api.llvm.CmpInst.Predicate
ICMP_EQ = Predicate.ICMP_EQ ICMP_EQ = Predicate.ICMP_EQ
@ -953,7 +953,7 @@ class StructType(Type):
def _get_name(self): def _get_name(self):
if self._ptr.isLiteral(): if self._ptr.isLiteral():
return "" return ""
else: else:
return self._ptr.getName() return self._ptr.getName()
name = property(_get_name, _set_name) name = property(_get_name, _set_name)
@ -1454,7 +1454,7 @@ class Argument(Value):
attrbldr.addAttribute(attr) attrbldr.addAttribute(attr)
attrs = api.llvm.AttributeSet.get(context, 0, attrbldr) attrs = api.llvm.AttributeSet.get(context, 0, attrbldr)
self._ptr.addAttr(attrs) self._ptr.addAttr(attrs)
if attr not in self: if attr not in self:
raise ValueError("Attribute %r is not valid for arg %s" % raise ValueError("Attribute %r is not valid for arg %s" %
(attr, self)) (attr, self))

View file

@ -38,7 +38,7 @@ def _replace_with(builder, inst, func):
def load(arch): def load(arch):
'''Load the LLRT module corresponding to the given architecture '''Load the LLRT module corresponding to the given architecture
Creates a new module and optimizes it using the information from Creates a new module and optimizes it using the information from
the host machine. the host machine.
''' '''
if arch != 'x86_64': if arch != 'x86_64':

View file

@ -191,12 +191,12 @@ class Disassembler(object):
where the instruction bytes are from (not an offset into where the instruction bytes are from (not an offset into
@bs). yields instructions in the form of (addr, data, inst) where @bs). yields instructions in the form of (addr, data, inst) where
addr is an integer, data is a tuple of integers and inst is an instance of addr is an integer, data is a tuple of integers and inst is an instance of
llvm.mc.Instr. @align specifies the byte alignment of instructions and llvm.mc.Instr. @align specifies the byte alignment of instructions and
is only used if an un-decodable instruction is encountered, in which is only used if an un-decodable instruction is encountered, in which
case the disassembler will skip the following bytes until the next case the disassembler will skip the following bytes until the next
aligned address. if @align is unspecified, the default alignment aligned address. if @align is unspecified, the default alignment
for the architecture will be used, however this may not be ideal for the architecture will be used, however this may not be ideal
for disassembly. for example, the default alignment for ARM is 1, but you for disassembly. for example, the default alignment for ARM is 1, but you
probably want it to be 4 for the purposes of disassembling ARM probably want it to be 4 for the purposes of disassembling ARM
instructions. instructions.
''' '''
@ -223,7 +223,7 @@ class Disassembler(object):
if amt_left >= size: if amt_left >= size:
data = code.readBytes(addr, size) data = code.readBytes(addr, size)
elif amt_left < 1: elif amt_left < 1:
break break
else: else:
data = code.readBytes(addr, amt_left) data = code.readBytes(addr, amt_left)

View file

@ -186,7 +186,7 @@ class TargetMachine(llvm.Wrapper):
@property @property
def feature_string(self): def feature_string(self):
return self._ptr.getTargetFeatureString() return self._ptr.getTargetFeatureString()
@property @property
def target(self): def target(self):
return self._ptr.getTarget() return self._ptr.getTarget()

View file

@ -1469,7 +1469,7 @@ class TestArith(TestCase):
cty = maptypes[ty] cty = maptypes[ty]
prototype = CFUNCTYPE(*[cty] * 3) prototype = CFUNCTYPE(*[cty] * 3)
callee = prototype(ptr) callee = prototype(ptr)
callee(12, 23) callee(12, 23)
def template(self, iop, fop): def template(self, iop, fop):
inttys = [Type.int(32), Type.int(64)] inttys = [Type.int(32), Type.int(64)]
@ -1487,7 +1487,7 @@ class TestArith(TestCase):
def test_sub(self): def test_sub(self):
self.template('sub', 'fsub') self.template('sub', 'fsub')
def test_mul(self): def test_mul(self):
self.template('mul', 'fmul') self.template('mul', 'fmul')

View file

@ -1,18 +1,18 @@
# This should be moved to llvmpy # This should be moved to llvmpy
# #
# There are different array kinds parameterized by eltype and nd # There are different array kinds parameterized by eltype and nd
# #
# Contiguous or Fortran # Contiguous or Fortran
# struct { # struct {
# eltype *data; # eltype *data;
# intp shape[nd]; # intp shape[nd];
# } contiguous_array(eltype, nd) # } contiguous_array(eltype, nd)
# #
# struct { # struct {
# eltype *data; # eltype *data;
# diminfo shape[nd]; # diminfo shape[nd];
# } strided_array(eltype, nd) # } strided_array(eltype, nd)
# #
# struct { # struct {
# eltype *data; # eltype *data;
# intp shape[nd]; # intp shape[nd];
@ -40,7 +40,7 @@
# int32 nd; # int32 nd;
# diminfo shape[nd]; # diminfo shape[nd];
# } strided_array_nd(eltype) # } strided_array_nd(eltype)
# #
# #
# Backward compatible but deprecated: # Backward compatible but deprecated:
# struct { # struct {
@ -50,25 +50,25 @@
# intp stride[nd]; # intp stride[nd];
# } strided_soa_array_nd(eltype) # } strided_soa_array_nd(eltype)
# #
# #
# The most general (where the kind of array is stored as well as number # The most general (where the kind of array is stored as well as number
# of dimensions) # of dimensions)
# Rarely needed. # Rarely needed.
# #
# struct { # struct {
# eltype *data; # eltype *data;
# int16 nd; # int16 nd;
# int16 dimkind; # int16 dimkind;
# ??? # ???
# } array_nd(eltype) # } array_nd(eltype)
# #
# where ??? is run-time interpreted based on the dimkind to either: # where ??? is run-time interpreted based on the dimkind to either:
# intp shape[nd]; for dimkind = C_CONTIGUOUS or F_CONTIGUOUS # intp shape[nd]; for dimkind = C_CONTIGUOUS or F_CONTIGUOUS
# #
# diminfo shape[nd]; for dimkind = STRIDED # diminfo shape[nd]; for dimkind = STRIDED
# #
# intp shape[ind]; # intp shape[ind];
# intp strides[ind]; dimkind = STRIDED_SOA # intp strides[ind]; dimkind = STRIDED_SOA
# #
import llvm.core as lc import llvm.core as lc
@ -95,7 +95,7 @@ STRIDED_DK = STRIDED + HAS_DIMKIND
STRIDED_SOA_DK = STRIDED_SOA + HAS_DIMKIND STRIDED_SOA_DK = STRIDED_SOA + HAS_DIMKIND
array_kinds = (C_CONTIGUOUS, F_CONTIGUOUS, STRIDED, STRIDED_SOA, array_kinds = (C_CONTIGUOUS, F_CONTIGUOUS, STRIDED, STRIDED_SOA,
C_CONTIGUOUS_ND, F_CONTIGUOUS_ND, STRIDED_ND, STRIDED_SOA_DK, C_CONTIGUOUS_ND, F_CONTIGUOUS_ND, STRIDED_ND, STRIDED_SOA_DK,
C_CONTIGUOUS_DK, F_CONTIGUOUS_DK, STRIDED_DK, STRIDED_SOA_DK) C_CONTIGUOUS_DK, F_CONTIGUOUS_DK, STRIDED_DK, STRIDED_SOA_DK)
_invmap = {} _invmap = {}
@ -105,7 +105,7 @@ def kind_to_str(kind):
if not _invmap: if not _invmap:
for key, value in globals().items(): for key, value in globals().items():
if isinstance(value, int) and value in array_kinds: if isinstance(value, int) and value in array_kinds:
_invmap[value] = key _invmap[value] = key
return _invmap[kind] return _invmap[kind]
def str_to_kind(str): def str_to_kind(str):
@ -157,7 +157,7 @@ def array_type(nd, kind, el_type=char_type):
terms.append(Type.array(intp_type, nd)) # shape terms.append(Type.array(intp_type, nd)) # shape
elif base == STRIDED: elif base == STRIDED:
terms.append(Type.array(diminfo_type, nd)) # diminfo terms.append(Type.array(diminfo_type, nd)) # diminfo
elif base == STRIDED_SOA: elif base == STRIDED_SOA:
terms.extend([Type.array(intp_type, nd), # shape terms.extend([Type.array(intp_type, nd), # shape
Type.array(intp_type, nd)]) # strides Type.array(intp_type, nd)]) # strides
@ -184,8 +184,8 @@ def _raw_check_array(arrtyp):
a0 = arrtyp.elements[0] a0 = arrtyp.elements[0]
a1 = arrtyp.elements[1] a1 = arrtyp.elements[1]
if not isinstance(a0, lc.PointerType) or \ if not isinstance(a0, lc.PointerType) or \
not (isinstance(a1, lc.ArrayType) or not (isinstance(a1, lc.ArrayType) or
(a1 == int32_type) or (a1 == int16_type)): (a1 == int32_type) or (a1 == int16_type)):
return None return None
data_type = a0.pointee data_type = a0.pointee
@ -214,7 +214,7 @@ def _raw_check_array(arrtyp):
c_contiguous = C_CONTIGUOUS_DK c_contiguous = C_CONTIGUOUS_DK
f_contiguous = F_CONTIGUOUS_DK f_contiguous = F_CONTIGUOUS_DK
else: else:
num = 1 num = 1
strided = STRIDED strided = STRIDED
strided_soa = STRIDED_SOA strided_soa = STRIDED_SOA
c_contiguous = C_CONTIGUOUS c_contiguous = C_CONTIGUOUS
@ -254,4 +254,4 @@ def test():
assert check_array(arr) == (STRIDED_SOA, 3, char_type) assert check_array(arr) == (STRIDED_SOA, 3, char_type)
if __name__ == '__main__': if __name__ == '__main__':
test() test()

View file

@ -21,14 +21,14 @@ if LLVM_VERSION >= (3, 3):
@Attribute @Attribute
class Attribute: class Attribute:
AttrKind = Enum('''None, Alignment, AlwaysInline, AttrKind = Enum('''None, Alignment, AlwaysInline,
ByVal, InlineHint, InReg, ByVal, InlineHint, InReg,
MinSize, Naked, Nest, NoAlias, MinSize, Naked, Nest, NoAlias,
NoBuiltin, NoCapture, NoDuplicate, NoImplicitFloat, NoBuiltin, NoCapture, NoDuplicate, NoImplicitFloat,
NoInline, NonLazyBind, NoRedZone, NoReturn, NoInline, NonLazyBind, NoRedZone, NoReturn,
NoUnwind, OptimizeForSize, ReadNone, ReadOnly, NoUnwind, OptimizeForSize, ReadNone, ReadOnly,
Returned, ReturnsTwice, SExt, StackAlignment, Returned, ReturnsTwice, SExt, StackAlignment,
StackProtect, StackProtectReq, StackProtectStrong, StructRet, StackProtect, StackProtectReq, StackProtectStrong, StructRet,
SanitizeAddress, SanitizeThread, SanitizeMemory, UWTable, SanitizeAddress, SanitizeThread, SanitizeMemory, UWTable,
ZExt, EndAttrKinds''') ZExt, EndAttrKinds''')
delete = Destructor() delete = Destructor()

View file

@ -4,7 +4,7 @@ from .namespace import llvm
ccs = ''' ccs = '''
C, Fast, Cold, GHC, FirstTargetCC, X86_StdCall, X86_FastCall, C, Fast, Cold, GHC, FirstTargetCC, X86_StdCall, X86_FastCall,
ARM_APCS, ARM_AAPCS, ARM_AAPCS_VFP, MSP430_INTR, X86_ThisCall, ARM_APCS, ARM_AAPCS, ARM_AAPCS_VFP, MSP430_INTR, X86_ThisCall,
PTX_Kernel, PTX_Device, PTX_Kernel, PTX_Device,
''' '''
if LLVM_VERSION <= (3, 3): if LLVM_VERSION <= (3, 3):

View file

@ -56,7 +56,7 @@ class DIBuilder:
) )
else: else:
createNullPtrType = Method(DIBasicType) createNullPtrType = Method(DIBasicType)
createBasicType = Method(DIType, createBasicType = Method(DIType,
stringref_arg, # Name stringref_arg, # Name
@ -204,7 +204,7 @@ class DIBuilder:
createObjectPointerType = Method(DIType, createObjectPointerType = Method(DIType,
ref(DIType), # Ty ref(DIType), # Ty
) )
#createTemporaryType = Method(DIType, ref(DIFile)).require_only(0) #createTemporaryType = Method(DIType, ref(DIFile)).require_only(0)
createForwardDecl = Method(DIType, createForwardDecl = Method(DIType,
@ -250,7 +250,7 @@ class DIBuilder:
bool_arg, # isLocalToUnit bool_arg, # isLocalToUnit
ptr(Value), # Val ptr(Value), # Val
) )
createLocalVariable = Method(DIVariable, createLocalVariable = Method(DIVariable,
unsigned_arg, # Tag, unsigned_arg, # Tag,
ref(DIDescriptor), # Scope, ref(DIDescriptor), # Scope,
@ -273,7 +273,7 @@ class DIBuilder:
ref(SmallVector_Value), # Addr, ref(SmallVector_Value), # Addr,
unsigned_arg, # ArgNo=0, unsigned_arg, # ArgNo=0,
).require_only(7) ).require_only(7)
createFunction = Method(DISubprogram, createFunction = Method(DISubprogram,
ref(DIDescriptor), # Scope ref(DIDescriptor), # Scope
stringref_arg, # Name stringref_arg, # Name
@ -318,7 +318,7 @@ class DIBuilder:
unsigned_arg, # LineNo unsigned_arg, # LineNo
) )
createLexicalBlockFile = Method(DILexicalBlockFile, createLexicalBlockFile = Method(DILexicalBlockFile,
ref(DIDescriptor), # Scope, ref(DIDescriptor), # Scope,
ref(DIFile), # File ref(DIFile), # File
) )
@ -329,7 +329,7 @@ class DIBuilder:
unsigned_arg, # Line, unsigned_arg, # Line,
unsigned_arg, # Col unsigned_arg, # Col
) )
_insertDeclare_1 = Method(ptr(Instruction), _insertDeclare_1 = Method(ptr(Instruction),
ptr(Value), # Storage, ptr(Value), # Storage,
ref(DIVariable), # VarInfo ref(DIVariable), # VarInfo

View file

@ -19,7 +19,7 @@ class Function:
_include_ = 'llvm/IR/Function.h' _include_ = 'llvm/IR/Function.h'
else: else:
_include_ = 'llvm/Function.h' _include_ = 'llvm/Function.h'
_downcast_ = GlobalValue, Constant, Value _downcast_ = GlobalValue, Constant, Value
getReturnType = Method(ptr(Type)) getReturnType = Method(ptr(Type))

View file

@ -1,4 +1,4 @@
#this file is not processed unless the llvm library is #this file is not processed unless the llvm library is
#version 3.4 or higher. see llvmpy/__init__.py for details. #version 3.4 or higher. see llvmpy/__init__.py for details.
from binding import * from binding import *
from ..namespace import llvm from ..namespace import llvm
@ -73,7 +73,7 @@ class MCOperand:
getImm = Method(cast(Int64, int)) getImm = Method(cast(Int64, int))
getFPImm = Method(cast(Double, float)) getFPImm = Method(cast(Double, float))
getExpr = Method(const(ownedptr(MCExpr))) getExpr = Method(const(ownedptr(MCExpr)))
@MCInst @MCInst
class MCInst: class MCInst:
_include_ = "llvm/MC/MCInst.h" _include_ = "llvm/MC/MCInst.h"
@ -148,7 +148,7 @@ class MCDisassembler:
DecodeStatus = Enum('Fail', 'SoftFail', 'Success') DecodeStatus = Enum('Fail', 'SoftFail', 'Success')
getInstruction = CustomMethod('MCDisassembler_getInstruction', getInstruction = CustomMethod('MCDisassembler_getInstruction',
PyObjectPtr, PyObjectPtr,
ref(MCInst), ref(MCInst),
ref(MemoryObject), ref(MemoryObject),

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ if LLVM_VERSION >= (3, 3):
cast(Bool, bool)) cast(Bool, bool))
else: else:
isLittleEndianHost = sys.Function('isLittleEndianHost', isLittleEndianHost = sys.Function('isLittleEndianHost',
cast(Bool, bool)) cast(Bool, bool))

View file

@ -16,7 +16,7 @@ if LLVM_VERSION >= (3, 4):
readBytes = CustomMethod('MemoryObject_readBytes', readBytes = CustomMethod('MemoryObject_readBytes',
PyObjectPtr, PyObjectPtr,
cast(int, Uint64), #address cast(int, Uint64), #address
cast(int, Uint64) #size cast(int, Uint64) #size
) )
@CustomPythonMethod @CustomPythonMethod
def readAll(self): def readAll(self):

View file

@ -58,7 +58,7 @@ class Target:
cast(str, StringRef), #cpu cast(str, StringRef), #cpu
cast(str, StringRef) #features cast(str, StringRef) #features
) )
createMCDisassembler = Method(ptr(MCDisassembler), ref(MCSubtargetInfo)) createMCDisassembler = Method(ptr(MCDisassembler), ref(MCSubtargetInfo))
createMCRegInfo = Method(ptr(MCRegisterInfo), createMCRegInfo = Method(ptr(MCRegisterInfo),

View file

@ -13,4 +13,4 @@ SplitBlockAndInsertIfThen = llvm.Function('SplitBlockAndInsertIfThen',
ReplaceInstWithInst = llvm.Function('ReplaceInstWithInst', ReplaceInstWithInst = llvm.Function('ReplaceInstWithInst',
Void, Void,
ptr(Instruction), # from ptr(Instruction), # from
ptr(Instruction)) # to ptr(Instruction)) # to

View file

@ -35,4 +35,4 @@ def main():
return 0 return 0
exit(main()) exit(main())

View file

@ -1,4 +1,4 @@
from llvmpy.api import llvm; from llvmpy.api import llvm;
llvm.InitializeAllTargets() llvm.InitializeAllTargets()
llvm.InitializeAllTargetInfos() llvm.InitializeAllTargetInfos()
llvm.InitializeAllTargetMCs() llvm.InitializeAllTargetMCs()

View file

@ -300,7 +300,7 @@ def do_function():
f.add_attribute(ATTR_NO_RETURN) f.add_attribute(ATTR_NO_RETURN)
f.add_attribute(ATTR_ALWAYS_INLINE) f.add_attribute(ATTR_ALWAYS_INLINE)
#for some reason removeFnAttr is just gone in 3.3 #for some reason removeFnAttr is just gone in 3.3
if version <= (3, 2): if version <= (3, 2):
f.remove_attribute(ATTR_NO_RETURN) f.remove_attribute(ATTR_NO_RETURN)
# LLVM misbehaves: # LLVM misbehaves: