Add downcast mapping
This commit is contained in:
parent
1b2a9dec9a
commit
8800ebac66
3 changed files with 64 additions and 51 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
from binding import *
|
from binding import *
|
||||||
from .namespace import llvm
|
from .namespace import llvm
|
||||||
from .Value import Value
|
from .Value import Value, User
|
||||||
from .Value import Constant, UndefValue, ConstantInt, ConstantFP, ConstantArray
|
from .Value import Constant, UndefValue, ConstantInt, ConstantFP, ConstantArray
|
||||||
from .Value import ConstantStruct, ConstantVector, ConstantVector
|
from .Value import ConstantStruct, ConstantVector, ConstantVector
|
||||||
from .Value import ConstantDataSequential, ConstantDataArray, ConstantExpr
|
from .Value import ConstantDataSequential, ConstantDataArray, ConstantExpr
|
||||||
|
|
@ -12,7 +12,7 @@ from .Instruction import CmpInst
|
||||||
|
|
||||||
@Constant
|
@Constant
|
||||||
class Constant:
|
class Constant:
|
||||||
_downcast_ = Value
|
_downcast_ = Value, User
|
||||||
|
|
||||||
isNullValue = Method(cast(bool, Bool))
|
isNullValue = Method(cast(bool, Bool))
|
||||||
isAllOnesValue = Method(cast(bool, Bool))
|
isAllOnesValue = Method(cast(bool, Bool))
|
||||||
|
|
@ -72,7 +72,7 @@ class UndefValue:
|
||||||
|
|
||||||
@ConstantInt
|
@ConstantInt
|
||||||
class ConstantInt:
|
class ConstantInt:
|
||||||
_downcast_ = Constant, Value
|
_downcast_ = Constant, User, Value
|
||||||
|
|
||||||
get = StaticMethod(ptr(ConstantInt),
|
get = StaticMethod(ptr(ConstantInt),
|
||||||
ptr(IntegerType),
|
ptr(IntegerType),
|
||||||
|
|
@ -88,7 +88,7 @@ class ConstantInt:
|
||||||
|
|
||||||
@ConstantFP
|
@ConstantFP
|
||||||
class ConstantFP:
|
class ConstantFP:
|
||||||
_downcast_ = Constant, Value
|
_downcast_ = Constant, User, Value
|
||||||
|
|
||||||
get = StaticMethod(ptr(Constant), ptr(Type), cast(float, Double))
|
get = StaticMethod(ptr(Constant), ptr(Type), cast(float, Double))
|
||||||
getNegativeZero = StaticMethod(ptr(ConstantFP), ptr(Type))
|
getNegativeZero = StaticMethod(ptr(ConstantFP), ptr(Type))
|
||||||
|
|
@ -102,7 +102,7 @@ class ConstantFP:
|
||||||
|
|
||||||
@ConstantArray
|
@ConstantArray
|
||||||
class ConstantArray:
|
class ConstantArray:
|
||||||
_downcast_ = Constant, Value
|
_downcast_ = Constant, User, Value
|
||||||
|
|
||||||
get = CustomStaticMethod('ConstantArray_get',
|
get = CustomStaticMethod('ConstantArray_get',
|
||||||
PyObjectPtr, # ptr(Constant),
|
PyObjectPtr, # ptr(Constant),
|
||||||
|
|
@ -113,7 +113,7 @@ class ConstantArray:
|
||||||
|
|
||||||
@ConstantStruct
|
@ConstantStruct
|
||||||
class ConstantStruct:
|
class ConstantStruct:
|
||||||
_downcast_ = Constant, Value
|
_downcast_ = Constant, User, Value
|
||||||
|
|
||||||
get = CustomStaticMethod('ConstantStruct_get',
|
get = CustomStaticMethod('ConstantStruct_get',
|
||||||
PyObjectPtr, # ptr(Constant)
|
PyObjectPtr, # ptr(Constant)
|
||||||
|
|
@ -129,7 +129,7 @@ class ConstantStruct:
|
||||||
|
|
||||||
@ConstantVector
|
@ConstantVector
|
||||||
class ConstantVector:
|
class ConstantVector:
|
||||||
_downcast_ = Constant, Value
|
_downcast_ = Constant, User, Value
|
||||||
|
|
||||||
get = CustomStaticMethod('ConstantVector_get',
|
get = CustomStaticMethod('ConstantVector_get',
|
||||||
PyObjectPtr, # ptr(Constant)
|
PyObjectPtr, # ptr(Constant)
|
||||||
|
|
@ -139,12 +139,12 @@ class ConstantVector:
|
||||||
|
|
||||||
@ConstantDataSequential
|
@ConstantDataSequential
|
||||||
class ConstantDataSequential:
|
class ConstantDataSequential:
|
||||||
_downcast_ = Constant, Value
|
_downcast_ = Constant, User, Value
|
||||||
|
|
||||||
|
|
||||||
@ConstantDataArray
|
@ConstantDataArray
|
||||||
class ConstantDataArray:
|
class ConstantDataArray:
|
||||||
_downcast_ = Constant, Value
|
_downcast_ = Constant, User, Value
|
||||||
|
|
||||||
getString = StaticMethod(ptr(Constant),
|
getString = StaticMethod(ptr(Constant),
|
||||||
ref(LLVMContext),
|
ref(LLVMContext),
|
||||||
|
|
@ -177,7 +177,7 @@ def _factory_const_type():
|
||||||
|
|
||||||
@ConstantExpr
|
@ConstantExpr
|
||||||
class ConstantExpr:
|
class ConstantExpr:
|
||||||
_downcast_ = Constant, Value
|
_downcast_ = Constant, User, Value
|
||||||
|
|
||||||
getAlignOf = _factory(ptr(Type))
|
getAlignOf = _factory(ptr(Type))
|
||||||
getSizeOf = _factory(ptr(Type))
|
getSizeOf = _factory(ptr(Type))
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,11 @@ GlobalVariable = llvm.Class(GlobalValue)
|
||||||
from .Module import Module
|
from .Module import Module
|
||||||
from .Type import Type
|
from .Type import Type
|
||||||
from .ADT.StringRef import StringRef
|
from .ADT.StringRef import StringRef
|
||||||
from .Value import Constant
|
from .Value import Value, User, Constant
|
||||||
|
|
||||||
@GlobalVariable
|
@GlobalVariable
|
||||||
class GlobalVariable:
|
class GlobalVariable:
|
||||||
|
_downcast_ = Value, User
|
||||||
ThreadLocalMode = Enum('''NotThreadLocal, GeneralDynamicTLSModel,
|
ThreadLocalMode = Enum('''NotThreadLocal, GeneralDynamicTLSModel,
|
||||||
LocalDynamicTLSModel, InitialExecTLSModel,
|
LocalDynamicTLSModel, InitialExecTLSModel,
|
||||||
LocalExecTLSModel
|
LocalExecTLSModel
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,9 @@ class Instruction:
|
||||||
|
|
||||||
clone = Method(ptr(Instruction))
|
clone = Method(ptr(Instruction))
|
||||||
|
|
||||||
|
getNextNode = Method(ptr(Instruction))
|
||||||
|
getPrevNode = Method(ptr(Instruction))
|
||||||
|
|
||||||
# LLVM 3.3
|
# LLVM 3.3
|
||||||
# hasUnsafeAlgebra = Method(cast(Bool, bool))
|
# hasUnsafeAlgebra = Method(cast(Bool, bool))
|
||||||
# hasNoNans = Method(cast(Bool, bool))
|
# hasNoNans = Method(cast(Bool, bool))
|
||||||
|
|
@ -120,17 +123,17 @@ class Instruction:
|
||||||
|
|
||||||
@AtomicCmpXchgInst
|
@AtomicCmpXchgInst
|
||||||
class AtomicCmpXchgInst:
|
class AtomicCmpXchgInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@AtomicRMWInst
|
@AtomicRMWInst
|
||||||
class AtomicRMWInst:
|
class AtomicRMWInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
BinOp = Enum('Xchg', 'Add', 'Sub', 'And', 'Nand', 'Or', 'Xor', 'Max', 'Min',
|
BinOp = Enum('Xchg', 'Add', 'Sub', 'And', 'Nand', 'Or', 'Xor', 'Max', 'Min',
|
||||||
'UMax', 'UMin', 'FIRST_BINOP', 'LAST_BINOP', 'BAD_BINOP')
|
'UMax', 'UMin', 'FIRST_BINOP', 'LAST_BINOP', 'BAD_BINOP')
|
||||||
|
|
||||||
@BinaryOperator
|
@BinaryOperator
|
||||||
class BinaryOperator:
|
class BinaryOperator:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@CallInst
|
@CallInst
|
||||||
class CallInst:
|
class CallInst:
|
||||||
|
|
@ -160,7 +163,7 @@ class CallInst:
|
||||||
|
|
||||||
@CmpInst
|
@CmpInst
|
||||||
class CmpInst:
|
class CmpInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
Predicate = Enum('FCMP_FALSE', 'FCMP_OEQ', 'FCMP_OGT', 'FCMP_OGE',
|
Predicate = Enum('FCMP_FALSE', 'FCMP_OEQ', 'FCMP_OGT', 'FCMP_OGE',
|
||||||
'FCMP_OLT', 'FCMP_OLE', 'FCMP_ONE', 'FCMP_ORD', 'FCMP_UNO',
|
'FCMP_OLT', 'FCMP_OLE', 'FCMP_ONE', 'FCMP_ORD', 'FCMP_UNO',
|
||||||
'FCMP_UEQ', 'FCMP_UGT', 'FCMP_UGE', 'FCMP_ULT', 'FCMP_ULE',
|
'FCMP_UEQ', 'FCMP_UGT', 'FCMP_UGE', 'FCMP_ULT', 'FCMP_ULE',
|
||||||
|
|
@ -177,31 +180,31 @@ class CmpInst:
|
||||||
|
|
||||||
@ExtractElementInst
|
@ExtractElementInst
|
||||||
class ExtractElementInst:
|
class ExtractElementInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@FenceInst
|
@FenceInst
|
||||||
class FenceInst:
|
class FenceInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@GetElementPtrInst
|
@GetElementPtrInst
|
||||||
class GetElementPtrInst:
|
class GetElementPtrInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@InsertElementInst
|
@InsertElementInst
|
||||||
class InsertElementInst:
|
class InsertElementInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@InsertValueInst
|
@InsertValueInst
|
||||||
class InsertValueInst:
|
class InsertValueInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@LandingPadInst
|
@LandingPadInst
|
||||||
class LandingPadInst:
|
class LandingPadInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@PHINode
|
@PHINode
|
||||||
class PHINode:
|
class PHINode:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
getNumIncomingValues = Method(cast(Unsigned, int))
|
getNumIncomingValues = Method(cast(Unsigned, int))
|
||||||
getIncomingValue = Method(ptr(Value), cast(int, Unsigned))
|
getIncomingValue = Method(ptr(Value), cast(int, Unsigned))
|
||||||
setIncomingValue = Method(Void, cast(int, Unsigned), ptr(Value))
|
setIncomingValue = Method(Void, cast(int, Unsigned), ptr(Value))
|
||||||
|
|
@ -213,15 +216,15 @@ class PHINode:
|
||||||
|
|
||||||
@SelectInst
|
@SelectInst
|
||||||
class SelectInst:
|
class SelectInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@ShuffleVectorInst
|
@ShuffleVectorInst
|
||||||
class ShuffleVectorInst:
|
class ShuffleVectorInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@StoreInst
|
@StoreInst
|
||||||
class StoreInst:
|
class StoreInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
isVolatile = Method(cast(Bool, bool))
|
isVolatile = Method(cast(Bool, bool))
|
||||||
isSimple = Method(cast(Bool, bool))
|
isSimple = Method(cast(Bool, bool))
|
||||||
isUnordered = Method(cast(Bool, bool))
|
isUnordered = Method(cast(Bool, bool))
|
||||||
|
|
@ -240,40 +243,40 @@ class StoreInst:
|
||||||
|
|
||||||
@TerminatorInst
|
@TerminatorInst
|
||||||
class TerminatorInst:
|
class TerminatorInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
getNumSuccessors = Method(cast(Unsigned, int))
|
getNumSuccessors = Method(cast(Unsigned, int))
|
||||||
getSuccessor = Method(ptr(BasicBlock), cast(int, Unsigned))
|
getSuccessor = Method(ptr(BasicBlock), cast(int, Unsigned))
|
||||||
setSuccessor = Method(Void, cast(int, Unsigned), ptr(BasicBlock))
|
setSuccessor = Method(Void, cast(int, Unsigned), ptr(BasicBlock))
|
||||||
|
|
||||||
@UnaryInstruction
|
@UnaryInstruction
|
||||||
class UnaryInstruction:
|
class UnaryInstruction:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
#call
|
#call
|
||||||
|
|
||||||
@IntrinsicInst
|
@IntrinsicInst
|
||||||
class IntrinsicInst:
|
class IntrinsicInst:
|
||||||
_include_ = 'llvm/IntrinsicInst.h'
|
_include_ = 'llvm/IntrinsicInst.h'
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
#compare
|
#compare
|
||||||
|
|
||||||
@FCmpInst
|
@FCmpInst
|
||||||
class FCmpInst:
|
class FCmpInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@ICmpInst
|
@ICmpInst
|
||||||
class ICmpInst:
|
class ICmpInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
# terminator
|
# terminator
|
||||||
@BranchInst
|
@BranchInst
|
||||||
class BranchInst:
|
class BranchInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@IndirectBrInst
|
@IndirectBrInst
|
||||||
class IndirectBrInst:
|
class IndirectBrInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@InvokeInst
|
@InvokeInst
|
||||||
class InvokeInst:
|
class InvokeInst:
|
||||||
|
|
@ -289,15 +292,17 @@ class InvokeInst:
|
||||||
|
|
||||||
@ResumeInst
|
@ResumeInst
|
||||||
class ResumeInst:
|
class ResumeInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@ReturnInst
|
@ReturnInst
|
||||||
class ReturnInst:
|
class ReturnInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction, TerminatorInst
|
||||||
|
getReturnValue = Method(ptr(Value))
|
||||||
|
getNumSuccessors = Method(cast(Unsigned, int))
|
||||||
|
|
||||||
@SwitchInst
|
@SwitchInst
|
||||||
class SwitchInst:
|
class SwitchInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
getCondition = Method(ptr(Value))
|
getCondition = Method(ptr(Value))
|
||||||
setCondition = Method(Void, ptr(Value))
|
setCondition = Method(Void, ptr(Value))
|
||||||
|
|
@ -309,24 +314,29 @@ class SwitchInst:
|
||||||
|
|
||||||
@UnreachableInst
|
@UnreachableInst
|
||||||
class UnreachableInst:
|
class UnreachableInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
# unary
|
# unary
|
||||||
@AllocaInst
|
@AllocaInst
|
||||||
class AllocaInst:
|
class AllocaInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
isArrayAllocation = Method(cast(Bool, bool))
|
||||||
|
isStaticAlloca = Method(cast(Bool, bool))
|
||||||
|
getArraySize = Method(ptr(Value))
|
||||||
|
getAllocatedType = Method(ptr(Type))
|
||||||
|
|
||||||
|
|
||||||
@CastInst
|
@CastInst
|
||||||
class CastInst:
|
class CastInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@ExtractValueInst
|
@ExtractValueInst
|
||||||
class ExtractValueInst:
|
class ExtractValueInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@LoadInst
|
@LoadInst
|
||||||
class LoadInst:
|
class LoadInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
isVolatile = Method(cast(Bool, bool))
|
isVolatile = Method(cast(Bool, bool))
|
||||||
isSimple = Method(cast(Bool, bool))
|
isSimple = Method(cast(Bool, bool))
|
||||||
isUnordered = Method(cast(Bool, bool))
|
isUnordered = Method(cast(Bool, bool))
|
||||||
|
|
@ -341,50 +351,52 @@ class LoadInst:
|
||||||
AtomicOrdering,
|
AtomicOrdering,
|
||||||
SynchronizationScope).require_only(1)
|
SynchronizationScope).require_only(1)
|
||||||
|
|
||||||
|
getPointerOperand = Method(ptr(Value))
|
||||||
|
|
||||||
classof = StaticMethod(cast(Bool, bool), ptr(Value))
|
classof = StaticMethod(cast(Bool, bool), ptr(Value))
|
||||||
|
|
||||||
@VAArgInst
|
@VAArgInst
|
||||||
class VAArgInst:
|
class VAArgInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
# intrinsic
|
# intrinsic
|
||||||
@DbgInfoIntrinsic
|
@DbgInfoIntrinsic
|
||||||
class DbgInfoIntrinsic:
|
class DbgInfoIntrinsic:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@MemIntrinsic
|
@MemIntrinsic
|
||||||
class MemIntrinsic:
|
class MemIntrinsic:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@VACopyInst
|
@VACopyInst
|
||||||
class VACopyInst:
|
class VACopyInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@VAEndInst
|
@VAEndInst
|
||||||
class VAEndInst:
|
class VAEndInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@VAStartInst
|
@VAStartInst
|
||||||
class VAStartInst:
|
class VAStartInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@BitCastInst
|
@BitCastInst
|
||||||
class BitCastInst:
|
class BitCastInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@FPExtInst
|
@FPExtInst
|
||||||
class FPExtInst:
|
class FPExtInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@FPToSIInst
|
@FPToSIInst
|
||||||
class FPToSIInst:
|
class FPToSIInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@FPToUIInst
|
@FPToUIInst
|
||||||
class FPToUIInst:
|
class FPToUIInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
@FPTruncInst
|
@FPTruncInst
|
||||||
class FPTruncInst:
|
class FPTruncInst:
|
||||||
_downcast_ = Value, Instruction
|
_downcast_ = Value, User, Instruction
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue