Skip to content

Remove Attribute API #10

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
Jan 9, 2017
Merged
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
40 changes: 0 additions & 40 deletions Sources/LLVMSwift/Function.swift
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
import cllvm

public enum Attribute {
case zExt, sExt, noReturn, inReg, structRet, noUnwind, noAlias
case byVal, nest, readOnly, noInline, alwaysInline, optimizeForSize
case stackProtect, stackProtectReq, alignment, noCapture, noRedZone
case noImplicitFloat, naked, inlineHint, stackAlignment, returnsTwice
case uwTable, nonLazyBind

/* FIXME: These attributes are currently not included in the C API as
a temporary measure until the API/ABI impact to the C API is understood
and the path forward agreed upon.
case sanitizeAddress, stackProtectStrong, cold, optimizeNone, inAlloca
case nonNull, jumpTable, convergent, safeStack, swiftSelf, swiftError
*/

private static let mapping: [Attribute: LLVMAttribute] = [
.zExt: LLVMZExtAttribute, .sExt: LLVMSExtAttribute, .noReturn: LLVMNoReturnAttribute,
.inReg: LLVMInRegAttribute, .structRet: LLVMStructRetAttribute, .noUnwind: LLVMNoUnwindAttribute,
.noAlias: LLVMNoAliasAttribute, .byVal: LLVMByValAttribute, .nest: LLVMNestAttribute,
.readOnly: LLVMReadOnlyAttribute, .noInline: LLVMNoInlineAttribute, .alwaysInline: LLVMAlwaysInlineAttribute,
.optimizeForSize: LLVMOptimizeForSizeAttribute, .stackProtect: LLVMStackProtectAttribute,
.stackProtectReq: LLVMStackProtectReqAttribute, .alignment: LLVMAlignment,
.noCapture: LLVMNoCaptureAttribute, .noRedZone: LLVMNoRedZoneAttribute,
.noImplicitFloat: LLVMNoImplicitFloatAttribute, .naked: LLVMNakedAttribute,
.inlineHint: LLVMInlineHintAttribute, .stackAlignment: LLVMStackAlignment,
.returnsTwice: LLVMReturnsTwice, .uwTable: LLVMUWTable, .nonLazyBind: LLVMNonLazyBind
]

public func asLLVM() -> LLVMAttribute {
return Attribute.mapping[self]!
}
}

public class Function: IRValue {
internal let llvm: LLVMValueRef
internal init(llvm: LLVMValueRef) {
Expand Down Expand Up @@ -106,14 +74,6 @@ public class Function: IRValue {
public struct Parameter: IRValue {
internal let llvm: LLVMValueRef

func addAttribute(_ attr: Attribute) {
LLVMAddAttribute(asLLVM(), attr.asLLVM())
}

func removeAttribute(_ attr: Attribute) {
LLVMRemoveAttribute(asLLVM(), attr.asLLVM())
}

public func next() -> Parameter? {
guard let param = LLVMGetNextParam(llvm) else { return nil }
return Parameter(llvm: param)
Expand Down