diff --git a/Sources/LLVM/IRType.swift b/Sources/LLVM/IRType.swift index fee2dd0e..b2953f52 100644 --- a/Sources/LLVM/IRType.swift +++ b/Sources/LLVM/IRType.swift @@ -11,7 +11,7 @@ public protocol IRType { public extension IRType { /// Returns the special `null` value for this type. - public func null() -> IRConstant { + func null() -> IRConstant { return Constant(llvm: LLVMConstNull(asLLVM())) } @@ -20,18 +20,18 @@ public extension IRType { /// The `undef` value can be used anywhere a constant is expected, and /// indicates that the user of the value may receive an unspecified /// bit-pattern. - public func undef() -> IRValue { + func undef() -> IRValue { return LLVMGetUndef(asLLVM()) } /// Returns the special LLVM constant `null` pointer value for this type /// initialized to `null`. - public func constPointerNull() -> IRConstant { + func constPointerNull() -> IRConstant { return Constant(llvm: LLVMConstPointerNull(asLLVM())) } /// Returns the context associated with this type - public var context: Context { + var context: Context { return Context(llvm: LLVMGetTypeContext(asLLVM())) } } diff --git a/Sources/LLVM/IRValue+Kinds.swift b/Sources/LLVM/IRValue+Kinds.swift index 30e73b35..72f0b461 100644 --- a/Sources/LLVM/IRValue+Kinds.swift +++ b/Sources/LLVM/IRValue+Kinds.swift @@ -7,392 +7,392 @@ import cllvm public extension IRValue { /// Whether or not the underlying LLVM value is an `Argument` - public var isAArgument: Bool { + var isAArgument: Bool { return LLVMIsAArgument(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `BasicBlock` - public var isABasicBlock: Bool { + var isABasicBlock: Bool { return LLVMIsABasicBlock(asLLVM()) != nil } /// Whether or not the underlying LLVM value is `InlineAsm` - public var isAInlineAsm: Bool { + var isAInlineAsm: Bool { return LLVMIsAInlineAsm(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `User` - public var isAUser: Bool { + var isAUser: Bool { return LLVMIsAUser(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `Constant` - public var isAConstant: Bool { + var isAConstant: Bool { return LLVMIsAConstant(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `BlockAddress` - public var isABlockAddress: Bool { + var isABlockAddress: Bool { return LLVMIsABlockAddress(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantAggregateZero` - public var isAConstantAggregateZero: Bool { + var isAConstantAggregateZero: Bool { return LLVMIsAConstantAggregateZero(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantArray` - public var isAConstantArray: Bool { + var isAConstantArray: Bool { return LLVMIsAConstantArray(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantDataSequential` - public var isAConstantDataSequential: Bool { + var isAConstantDataSequential: Bool { return LLVMIsAConstantDataSequential(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantDataArray` - public var isAConstantDataArray: Bool { + var isAConstantDataArray: Bool { return LLVMIsAConstantDataArray(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantDataVector` - public var isAConstantDataVector: Bool { + var isAConstantDataVector: Bool { return LLVMIsAConstantDataVector(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantExpr` - public var isAConstantExpr: Bool { + var isAConstantExpr: Bool { return LLVMIsAConstantExpr(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantFP` - public var isAConstantFP: Bool { + var isAConstantFP: Bool { return LLVMIsAConstantFP(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantInt` - public var isAConstantInt: Bool { + var isAConstantInt: Bool { return LLVMIsAConstantInt(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantPointerNull` - public var isAConstantPointerNull: Bool { + var isAConstantPointerNull: Bool { return LLVMIsAConstantPointerNull(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantStruct` - public var isAConstantStruct: Bool { + var isAConstantStruct: Bool { return LLVMIsAConstantStruct(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantTokenNone` - public var isAConstantTokenNone: Bool { + var isAConstantTokenNone: Bool { return LLVMIsAConstantTokenNone(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ConstantVector` - public var isAConstantVector: Bool { + var isAConstantVector: Bool { return LLVMIsAConstantVector(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `GlobalValue` - public var isAGlobalValue: Bool { + var isAGlobalValue: Bool { return LLVMIsAGlobalValue(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `GlobalAlias` - public var isAGlobalAlias: Bool { + var isAGlobalAlias: Bool { return LLVMIsAGlobalAlias(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `GlobalObject` - public var isAGlobalObject: Bool { + var isAGlobalObject: Bool { return LLVMIsAGlobalObject(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `Function` - public var isAFunction: Bool { + var isAFunction: Bool { return LLVMIsAFunction(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `GlobalVariable` - public var isAGlobalVariable: Bool { + var isAGlobalVariable: Bool { return LLVMIsAGlobalVariable(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `UndefValue` - public var isAUndefValue: Bool { + var isAUndefValue: Bool { return LLVMIsAUndefValue(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `Instruction` - public var isAInstruction: Bool { + var isAInstruction: Bool { return LLVMIsAInstruction(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `BinaryOperator` - public var isABinaryOperator: Bool { + var isABinaryOperator: Bool { return LLVMIsABinaryOperator(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `CallInst` - public var isACallInst: Bool { + var isACallInst: Bool { return LLVMIsACallInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `IntrinsicInst` - public var isAIntrinsicInst: Bool { + var isAIntrinsicInst: Bool { return LLVMIsAIntrinsicInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `DbgInfoIntrinsic` - public var isADbgInfoIntrinsic: Bool { + var isADbgInfoIntrinsic: Bool { return LLVMIsADbgInfoIntrinsic(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `DbgDeclareInst` - public var isADbgDeclareInst: Bool { + var isADbgDeclareInst: Bool { return LLVMIsADbgDeclareInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `MemIntrinsic` - public var isAMemIntrinsic: Bool { + var isAMemIntrinsic: Bool { return LLVMIsAMemIntrinsic(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `MemCpyInst` - public var isAMemCpyInst: Bool { + var isAMemCpyInst: Bool { return LLVMIsAMemCpyInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `MemMoveInst` - public var isAMemMoveInst: Bool { + var isAMemMoveInst: Bool { return LLVMIsAMemMoveInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `MemSetInst` - public var isAMemSetInst: Bool { + var isAMemSetInst: Bool { return LLVMIsAMemSetInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `CmpInst` - public var isACmpInst: Bool { + var isACmpInst: Bool { return LLVMIsACmpInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `FCmpInst` - public var isAFCmpInst: Bool { + var isAFCmpInst: Bool { return LLVMIsAFCmpInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `ICmpInst` - public var isAICmpInst: Bool { + var isAICmpInst: Bool { return LLVMIsAICmpInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `ExtractElementInst` - public var isAExtractElementInst: Bool { + var isAExtractElementInst: Bool { return LLVMIsAExtractElementInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `GetElementPtrInst` - public var isAGetElementPtrInst: Bool { + var isAGetElementPtrInst: Bool { return LLVMIsAGetElementPtrInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `InsertElementInst` - public var isAInsertElementInst: Bool { + var isAInsertElementInst: Bool { return LLVMIsAInsertElementInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `InsertValueInst` - public var isAInsertValueInst: Bool { + var isAInsertValueInst: Bool { return LLVMIsAInsertValueInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `LandingPadInst` - public var isALandingPadInst: Bool { + var isALandingPadInst: Bool { return LLVMIsALandingPadInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `PHINode` - public var isAPHINode: Bool { + var isAPHINode: Bool { return LLVMIsAPHINode(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `SelectInst` - public var isASelectInst: Bool { + var isASelectInst: Bool { return LLVMIsASelectInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ShuffleVectorInst` - public var isAShuffleVectorInst: Bool { + var isAShuffleVectorInst: Bool { return LLVMIsAShuffleVectorInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `StoreInst` - public var isAStoreInst: Bool { + var isAStoreInst: Bool { return LLVMIsAStoreInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `TerminatorInst` - public var isATerminatorInst: Bool { + var isATerminatorInst: Bool { return LLVMIsATerminatorInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `BranchInst` - public var isABranchInst: Bool { + var isABranchInst: Bool { return LLVMIsABranchInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `IndirectBrInst` - public var isAIndirectBrInst: Bool { + var isAIndirectBrInst: Bool { return LLVMIsAIndirectBrInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `InvokeInst` - public var isAInvokeInst: Bool { + var isAInvokeInst: Bool { return LLVMIsAInvokeInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ReturnInst` - public var isAReturnInst: Bool { + var isAReturnInst: Bool { return LLVMIsAReturnInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `SwitchInst` - public var isASwitchInst: Bool { + var isASwitchInst: Bool { return LLVMIsASwitchInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `UnreachableInst` - public var isAUnreachableInst: Bool { + var isAUnreachableInst: Bool { return LLVMIsAUnreachableInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ResumeInst` - public var isAResumeInst: Bool { + var isAResumeInst: Bool { return LLVMIsAResumeInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `CleanupReturnInst` - public var isACleanupReturnInst: Bool { + var isACleanupReturnInst: Bool { return LLVMIsACleanupReturnInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `CatchReturnInst` - public var isACatchReturnInst: Bool { + var isACatchReturnInst: Bool { return LLVMIsACatchReturnInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `FuncletPadInst` - public var isAFuncletPadInst: Bool { + var isAFuncletPadInst: Bool { return LLVMIsAFuncletPadInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `CatchPadInst` - public var isACatchPadInst: Bool { + var isACatchPadInst: Bool { return LLVMIsACatchPadInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `CleanupPadInst` - public var isACleanupPadInst: Bool { + var isACleanupPadInst: Bool { return LLVMIsACleanupPadInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `UnaryInstruction` - public var isAUnaryInstruction: Bool { + var isAUnaryInstruction: Bool { return LLVMIsAUnaryInstruction(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `AllocaInst` - public var isAAllocaInst: Bool { + var isAAllocaInst: Bool { return LLVMIsAAllocaInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `CastInst` - public var isACastInst: Bool { + var isACastInst: Bool { return LLVMIsACastInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `AddrSpaceCastInst` - public var isAAddrSpaceCastInst: Bool { + var isAAddrSpaceCastInst: Bool { return LLVMIsAAddrSpaceCastInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `BitCastInst` - public var isABitCastInst: Bool { + var isABitCastInst: Bool { return LLVMIsABitCastInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `FPExtInst` - public var isAFPExtInst: Bool { + var isAFPExtInst: Bool { return LLVMIsAFPExtInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `FPToSIInst` - public var isAFPToSIInst: Bool { + var isAFPToSIInst: Bool { return LLVMIsAFPToSIInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `FPToUIInst` - public var isAFPToUIInst: Bool { + var isAFPToUIInst: Bool { return LLVMIsAFPToUIInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `FPTruncInst` - public var isAFPTruncInst: Bool { + var isAFPTruncInst: Bool { return LLVMIsAFPTruncInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is an `IntToPtrInst` - public var isAIntToPtrInst: Bool { + var isAIntToPtrInst: Bool { return LLVMIsAIntToPtrInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `PtrToIntInst` - public var isAPtrToIntInst: Bool { + var isAPtrToIntInst: Bool { return LLVMIsAPtrToIntInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `SExtInst` - public var isASExtInst: Bool { + var isASExtInst: Bool { return LLVMIsASExtInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `SIToFPInst` - public var isASIToFPInst: Bool { + var isASIToFPInst: Bool { return LLVMIsASIToFPInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `TruncInst` - public var isATruncInst: Bool { + var isATruncInst: Bool { return LLVMIsATruncInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `UIToFPInst` - public var isAUIToFPInst: Bool { + var isAUIToFPInst: Bool { return LLVMIsAUIToFPInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ZExtInst` - public var isAZExtInst: Bool { + var isAZExtInst: Bool { return LLVMIsAZExtInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `ExtractValueInst` - public var isAExtractValueInst: Bool { + var isAExtractValueInst: Bool { return LLVMIsAExtractValueInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `LoadInst` - public var isALoadInst: Bool { + var isALoadInst: Bool { return LLVMIsALoadInst(asLLVM()) != nil } /// Whether or not the underlying LLVM value is a `VAArgInst` - public var isAVAArgInst: Bool { + var isAVAArgInst: Bool { return LLVMIsAVAArgInst(asLLVM()) != nil } } diff --git a/Sources/LLVM/IRValue.swift b/Sources/LLVM/IRValue.swift index 019c1ada..8a7b55c9 100644 --- a/Sources/LLVM/IRValue.swift +++ b/Sources/LLVM/IRValue.swift @@ -11,12 +11,12 @@ public protocol IRValue { public extension IRValue { /// Retrieves the type of this value. - public var type: IRType { + var type: IRType { return convertType(LLVMTypeOf(asLLVM())) } /// Returns whether this value is a constant. - public var isConstant: Bool { + var isConstant: Bool { return LLVMIsConstant(asLLVM()) != 0 } @@ -26,12 +26,12 @@ public extension IRValue { /// The `undef` value can be used anywhere a constant is expected, and /// indicates that the user of the value may receive an unspecified /// bit-pattern. - public var isUndef: Bool { + var isUndef: Bool { return LLVMIsUndef(asLLVM()) != 0 } /// Gets and sets the name for this value. - public var name: String { + var name: String { get { let ptr = LLVMGetValueName(asLLVM())! return String(cString: ptr) @@ -44,17 +44,17 @@ public extension IRValue { /// Replaces all uses of this value with the specified value. /// /// - parameter value: The new value to swap in. - public func replaceAllUses(with value: IRValue) { + func replaceAllUses(with value: IRValue) { LLVMReplaceAllUsesWith(asLLVM(), value.asLLVM()) } /// Dumps a representation of this value to stderr. - public func dump() { + func dump() { LLVMDumpValue(asLLVM()) } /// The kind of this value. - public var kind: IRValueKind { + var kind: IRValueKind { return IRValueKind(llvm: LLVMGetValueKind(asLLVM())) } }