Skip to content

[stdlib][Part 1] De-gyb almost everything #21149

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 8 commits into from
Dec 10, 2019
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
161 changes: 161 additions & 0 deletions stdlib/public/core/BuiltinMath.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
//===--- BuiltinMath.swift --------------------------------*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

// Each of the following functions is ordered to match math.h

// These functions have a corresponding LLVM intrinsic.
// Note, keep this up to date with Darwin/tgmath.swift.gyb

// Order of intrinsics: cos, sin, exp, exp2, log, log10, log2, nearbyint, rint

// Float Intrinsics (32 bits)

@_transparent
public func _cos(_ x: Float) -> Float {
return Float(Builtin.int_cos_FPIEEE32(x._value))
}

@_transparent
public func _sin(_ x: Float) -> Float {
return Float(Builtin.int_sin_FPIEEE32(x._value))
}

@_transparent
public func _exp(_ x: Float) -> Float {
return Float(Builtin.int_exp_FPIEEE32(x._value))
}

@_transparent
public func _exp2(_ x: Float) -> Float {
return Float(Builtin.int_exp2_FPIEEE32(x._value))
}

@_transparent
public func _log(_ x: Float) -> Float {
return Float(Builtin.int_log_FPIEEE32(x._value))
}

@_transparent
public func _log10(_ x: Float) -> Float {
return Float(Builtin.int_log10_FPIEEE32(x._value))
}

@_transparent
public func _log2(_ x: Float) -> Float {
return Float(Builtin.int_log2_FPIEEE32(x._value))
}

@_transparent
public func _nearbyint(_ x: Float) -> Float {
return Float(Builtin.int_nearbyint_FPIEEE32(x._value))
}

@_transparent
public func _rint(_ x: Float) -> Float {
return Float(Builtin.int_rint_FPIEEE32(x._value))
}

// Double Intrinsics (64 bits)

@_transparent
public func _cos(_ x: Double) -> Double {
return Double(Builtin.int_cos_FPIEEE64(x._value))
}

@_transparent
public func _sin(_ x: Double) -> Double {
return Double(Builtin.int_sin_FPIEEE64(x._value))
}

@_transparent
public func _exp(_ x: Double) -> Double {
return Double(Builtin.int_exp_FPIEEE64(x._value))
}

@_transparent
public func _exp2(_ x: Double) -> Double {
return Double(Builtin.int_exp2_FPIEEE64(x._value))
}

@_transparent
public func _log(_ x: Double) -> Double {
return Double(Builtin.int_log_FPIEEE64(x._value))
}

@_transparent
public func _log10(_ x: Double) -> Double {
return Double(Builtin.int_log10_FPIEEE64(x._value))
}

@_transparent
public func _log2(_ x: Double) -> Double {
return Double(Builtin.int_log2_FPIEEE64(x._value))
}

@_transparent
public func _nearbyint(_ x: Double) -> Double {
return Double(Builtin.int_nearbyint_FPIEEE64(x._value))
}

@_transparent
public func _rint(_ x: Double) -> Double {
return Double(Builtin.int_rint_FPIEEE64(x._value))
}

// Float80 Intrinsics (80 bits)

#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
@_transparent
public func _cos(_ x: Float80) -> Float80 {
return Float80(Builtin.int_cos_FPIEEE80(x._value))
}

@_transparent
public func _sin(_ x: Float80) -> Float80 {
return Float80(Builtin.int_sin_FPIEEE80(x._value))
}

@_transparent
public func _exp(_ x: Float80) -> Float80 {
return Float80(Builtin.int_exp_FPIEEE80(x._value))
}

@_transparent
public func _exp2(_ x: Float80) -> Float80 {
return Float80(Builtin.int_exp2_FPIEEE80(x._value))
}

@_transparent
public func _log(_ x: Float80) -> Float80 {
return Float80(Builtin.int_log_FPIEEE80(x._value))
}

@_transparent
public func _log10(_ x: Float80) -> Float80 {
return Float80(Builtin.int_log10_FPIEEE80(x._value))
}

@_transparent
public func _log2(_ x: Float80) -> Float80 {
return Float80(Builtin.int_log2_FPIEEE80(x._value))
}

@_transparent
public func _nearbyint(_ x: Float80) -> Float80 {
return Float80(Builtin.int_nearbyint_FPIEEE80(x._value))
}

@_transparent
public func _rint(_ x: Float80) -> Float80 {
return Float80(Builtin.int_rint_FPIEEE80(x._value))
}
#endif
78 changes: 0 additions & 78 deletions stdlib/public/core/BuiltinMath.swift.gyb

This file was deleted.

14 changes: 7 additions & 7 deletions stdlib/public/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -37,8 +37,10 @@ set(SWIFTLIB_ESSENTIAL
BridgeStorage.swift
BridgingBuffer.swift
Builtin.swift
BuiltinMath.swift
Character.swift
CocoaArray.swift
Codable.swift
Collection.swift
CollectionAlgorithms.swift
Comparable.swift
Expand All @@ -61,6 +63,7 @@ set(SWIFTLIB_ESSENTIAL
EmptyCollection.swift
Equatable.swift
ErrorType.swift
ExistentialCollection.swift
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't fix the test failure, but you could move ExistentialCollection.swift to the SWIFTLIB_SOURCES list (at line 210) if it isn't an "essential" source; and also change the copyright year of CMakeLists.txt (from 2018 to 2019).

Filter.swift
FixedArray.swift
FlatMap.swift
Expand Down Expand Up @@ -91,6 +94,7 @@ set(SWIFTLIB_ESSENTIAL
Map.swift
MemoryLayout.swift
UnicodeScalar.swift # ORDER DEPENDENCY: Must precede Mirrors.swift
Mirrors.swift
Misc.swift
MutableCollection.swift
NativeDictionary.swift
Expand All @@ -113,6 +117,7 @@ set(SWIFTLIB_ESSENTIAL
REPL.swift
Result.swift
Reverse.swift
Runtime.swift
RuntimeFunctionCounters.swift
SipHash.swift
Sequence.swift
Expand Down Expand Up @@ -163,6 +168,7 @@ set(SWIFTLIB_ESSENTIAL
SwiftNativeNSArray.swift
ThreadLocalStorage.swift
UIntBuffer.swift
UnavailableStringAPIs.swift
UnicodeEncoding.swift
UnicodeHelpers.swift
UnicodeParser.swift
Expand All @@ -185,14 +191,9 @@ set(SWIFTLIB_ESSENTIAL

set(SWIFTLIB_ESSENTIAL_GYB_SOURCES
AtomicInt.swift.gyb
BuiltinMath.swift.gyb
Codable.swift.gyb
FloatingPointParsing.swift.gyb
FloatingPointTypes.swift.gyb
IntegerTypes.swift.gyb
Mirrors.swift.gyb
Runtime.swift.gyb
UnavailableStringAPIs.swift.gyb
UnsafeBufferPointer.swift.gyb
UnsafeRawBufferPointer.swift.gyb
)
Expand All @@ -219,7 +220,6 @@ set(SWIFTLIB_SOURCES

set(SWIFTLIB_GYB_SOURCES
${SWIFTLIB_ESSENTIAL_GYB_SOURCES}
ExistentialCollection.swift.gyb
SIMDVectorTypes.swift.gyb
Tuple.swift.gyb
)
Expand Down
Loading