Skip to content

Disable and rewrite Metadata and Token type inits #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/LLVM/IRType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ internal func convertType(_ type: LLVMTypeRef) -> IRType {
let count = Int(LLVMGetVectorSize(type))
return VectorType(elementType: elementType, count: count)
case LLVMMetadataTypeKind:
return MetadataType(llvm: type)
return MetadataType(in: context)
case LLVMX86_MMXTypeKind:
return X86MMXType(in: context)
case LLVMTokenTypeKind:
return TokenType(llvm: type)
return TokenType(in: context)
default: fatalError("unknown type kind for type \(type)")
}
}
12 changes: 8 additions & 4 deletions Sources/LLVM/MetadataType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import cllvm
/// The `MetadataType` type represents embedded metadata. No derived types may
/// be created from metadata except for function arguments.
public struct MetadataType: IRType {
internal let llvm: LLVMTypeRef
/// Returns the context associated with this type.
public let context: Context

/// Creates an embedded metadata type for the given LLVM type object.
public init(llvm: LLVMTypeRef) {
self.llvm = llvm
///
/// - parameter context: The context to create this type in
/// - SeeAlso: http://llvm.org/docs/ProgrammersManual.html#achieving-isolation-with-llvmcontext
public init(in context: Context = Context.global) {
self.context = context
}

/// Retrieves the underlying LLVM type object.
public func asLLVM() -> LLVMTypeRef {
return llvm
fatalError("This version of LLVM does not support the creation of MetadataType objects")
}
}
12 changes: 9 additions & 3 deletions Sources/LLVM/TokenType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import cllvm
/// uses of the value must not attempt to introspect or obscure it. As such, it
/// is not appropriate to have a `PHI` or `select` of type `TokenType`.
public struct TokenType: IRType {
internal let llvm: LLVMTypeRef
/// Returns the context associated with this type.
public let context: Context

/// Initializes a token type from the given LLVM type object.
public init(llvm: LLVMTypeRef) { self.llvm = llvm }
///
/// - parameter context: The context to create this type in
/// - SeeAlso: http://llvm.org/docs/ProgrammersManual.html#achieving-isolation-with-llvmcontext
public init(in context: Context = Context.global) {
self.context = context
}

/// Retrieves the underlying LLVM type object.
public func asLLVM() -> LLVMTypeRef {
return llvm
fatalError("This version of LLVM does not support the creation of TokenType objects")
}
}