IntType

public struct IntType : IRType
extension IntType: Equatable

The IntType represents an integral value of a specified bit width.

The IntType is a very simple type that simply specifies an arbitrary bit width for the integer type desired. Any bit width from 1 bit to (2^23)-1 (about 8 million) can be specified.

  • Retrieves the bit width of this integer type.

    Declaration

    Swift

    public let width: Int
  • Returns the context associated with this type.

    Declaration

    Swift

    public let context: Context
  • Creates an integer type with the specified bit width.

    Declaration

    Swift

    public init(width: Int, in context: Context = Context.global)

    Parameters

    width

    The width in bits of the integer type

    context

    The context to create this type in

  • Retrieves the i1 type.

    Declaration

    Swift

    public static let int1: IntType
  • Retrieves the i8 type.

    Declaration

    Swift

    public static let int8: IntType
  • Retrieves the i16 type.

    Declaration

    Swift

    public static let int16: IntType
  • Retrieves the i32 type.

    Declaration

    Swift

    public static let int32: IntType
  • Retrieves the i64 type.

    Declaration

    Swift

    public static let int64: IntType
  • Retrieves the i128 type.

    Declaration

    Swift

    public static let int128: IntType
  • Retrieves an integer value of this type’s bit width consisting of all zero-bits.

    Declaration

    Swift

    public func zero() -> IRConstant

    Return Value

    A value consisting of all zero-bits of this type’s bit width.

  • Creates an unsigned integer constant value with the given Swift integer value.

    Declaration

    Swift

    public func constant<IntTy>(_ value: IntTy, signExtend: Bool = false) -> Constant<Unsigned> where IntTy : UnsignedInteger

    Parameters

    value

    A Swift integer value.

    signExtend

    Whether to sign-extend this value to fit this type’s bit width. Defaults to false.

    Return Value

    A value representing an unsigned integer constant initialized with the given Swift integer value.

  • Creates a signed integer constant value with the given Swift integer value.

    Declaration

    Swift

    public func constant<IntTy>(_ value: IntTy, signExtend: Bool = false) -> Constant<Signed> where IntTy : SignedInteger

    Parameters

    value

    A Swift integer value.

    signExtend

    Whether to sign-extend this value to fit this type’s bit width. Defaults to false.

    Return Value

    A value representing a signed integer constant initialized with the given Swift integer value.

  • Creates a constant integer value of this type parsed from a string.

    Declaration

    Swift

    public func constant(_ value: String, radix: Int = 10) -> Constant<Signed>

    Parameters

    value

    A string value containing an integer.

    radix

    The radix, or base, to use for converting text to an integer value. Defaults to 10.

    Return Value

    A value representing a constant initialized with the result of parsing the string as a signed integer.

  • Retrieves an integer value of this type’s bit width consisting of all one-bits.

    Declaration

    Swift

    public func allOnes() -> IRConstant

    Return Value

    A value consisting of all one-bits of this type’s bit width.

  • Retrieves the underlying LLVM type object.

    Declaration

    Swift

    public func asLLVM() -> LLVMTypeRef
  • Declaration

    Swift

    public static func == (lhs: IntType, rhs: IntType) -> Bool