Skip to content

Commit 113baa6

Browse files
authored
Merge pull request #21149 from Azoy/de-gyb-stdlib-part-1
[stdlib][Part 1] De-gyb almost everything
2 parents 3cc452e + e3a4401 commit 113baa6

14 files changed

+9154
-3491
lines changed

stdlib/public/core/BuiltinMath.swift

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
//===--- BuiltinMath.swift --------------------------------*- swift -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// Each of the following functions is ordered to match math.h
14+
15+
// These functions have a corresponding LLVM intrinsic.
16+
// Note, keep this up to date with Darwin/tgmath.swift.gyb
17+
18+
// Order of intrinsics: cos, sin, exp, exp2, log, log10, log2, nearbyint, rint
19+
20+
// Float Intrinsics (32 bits)
21+
22+
@_transparent
23+
public func _cos(_ x: Float) -> Float {
24+
return Float(Builtin.int_cos_FPIEEE32(x._value))
25+
}
26+
27+
@_transparent
28+
public func _sin(_ x: Float) -> Float {
29+
return Float(Builtin.int_sin_FPIEEE32(x._value))
30+
}
31+
32+
@_transparent
33+
public func _exp(_ x: Float) -> Float {
34+
return Float(Builtin.int_exp_FPIEEE32(x._value))
35+
}
36+
37+
@_transparent
38+
public func _exp2(_ x: Float) -> Float {
39+
return Float(Builtin.int_exp2_FPIEEE32(x._value))
40+
}
41+
42+
@_transparent
43+
public func _log(_ x: Float) -> Float {
44+
return Float(Builtin.int_log_FPIEEE32(x._value))
45+
}
46+
47+
@_transparent
48+
public func _log10(_ x: Float) -> Float {
49+
return Float(Builtin.int_log10_FPIEEE32(x._value))
50+
}
51+
52+
@_transparent
53+
public func _log2(_ x: Float) -> Float {
54+
return Float(Builtin.int_log2_FPIEEE32(x._value))
55+
}
56+
57+
@_transparent
58+
public func _nearbyint(_ x: Float) -> Float {
59+
return Float(Builtin.int_nearbyint_FPIEEE32(x._value))
60+
}
61+
62+
@_transparent
63+
public func _rint(_ x: Float) -> Float {
64+
return Float(Builtin.int_rint_FPIEEE32(x._value))
65+
}
66+
67+
// Double Intrinsics (64 bits)
68+
69+
@_transparent
70+
public func _cos(_ x: Double) -> Double {
71+
return Double(Builtin.int_cos_FPIEEE64(x._value))
72+
}
73+
74+
@_transparent
75+
public func _sin(_ x: Double) -> Double {
76+
return Double(Builtin.int_sin_FPIEEE64(x._value))
77+
}
78+
79+
@_transparent
80+
public func _exp(_ x: Double) -> Double {
81+
return Double(Builtin.int_exp_FPIEEE64(x._value))
82+
}
83+
84+
@_transparent
85+
public func _exp2(_ x: Double) -> Double {
86+
return Double(Builtin.int_exp2_FPIEEE64(x._value))
87+
}
88+
89+
@_transparent
90+
public func _log(_ x: Double) -> Double {
91+
return Double(Builtin.int_log_FPIEEE64(x._value))
92+
}
93+
94+
@_transparent
95+
public func _log10(_ x: Double) -> Double {
96+
return Double(Builtin.int_log10_FPIEEE64(x._value))
97+
}
98+
99+
@_transparent
100+
public func _log2(_ x: Double) -> Double {
101+
return Double(Builtin.int_log2_FPIEEE64(x._value))
102+
}
103+
104+
@_transparent
105+
public func _nearbyint(_ x: Double) -> Double {
106+
return Double(Builtin.int_nearbyint_FPIEEE64(x._value))
107+
}
108+
109+
@_transparent
110+
public func _rint(_ x: Double) -> Double {
111+
return Double(Builtin.int_rint_FPIEEE64(x._value))
112+
}
113+
114+
// Float80 Intrinsics (80 bits)
115+
116+
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
117+
@_transparent
118+
public func _cos(_ x: Float80) -> Float80 {
119+
return Float80(Builtin.int_cos_FPIEEE80(x._value))
120+
}
121+
122+
@_transparent
123+
public func _sin(_ x: Float80) -> Float80 {
124+
return Float80(Builtin.int_sin_FPIEEE80(x._value))
125+
}
126+
127+
@_transparent
128+
public func _exp(_ x: Float80) -> Float80 {
129+
return Float80(Builtin.int_exp_FPIEEE80(x._value))
130+
}
131+
132+
@_transparent
133+
public func _exp2(_ x: Float80) -> Float80 {
134+
return Float80(Builtin.int_exp2_FPIEEE80(x._value))
135+
}
136+
137+
@_transparent
138+
public func _log(_ x: Float80) -> Float80 {
139+
return Float80(Builtin.int_log_FPIEEE80(x._value))
140+
}
141+
142+
@_transparent
143+
public func _log10(_ x: Float80) -> Float80 {
144+
return Float80(Builtin.int_log10_FPIEEE80(x._value))
145+
}
146+
147+
@_transparent
148+
public func _log2(_ x: Float80) -> Float80 {
149+
return Float80(Builtin.int_log2_FPIEEE80(x._value))
150+
}
151+
152+
@_transparent
153+
public func _nearbyint(_ x: Float80) -> Float80 {
154+
return Float80(Builtin.int_nearbyint_FPIEEE80(x._value))
155+
}
156+
157+
@_transparent
158+
public func _rint(_ x: Float80) -> Float80 {
159+
return Float80(Builtin.int_rint_FPIEEE80(x._value))
160+
}
161+
#endif

stdlib/public/core/BuiltinMath.swift.gyb

Lines changed: 0 additions & 78 deletions
This file was deleted.

stdlib/public/core/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# This source file is part of the Swift.org open source project
44
#
5-
# Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5+
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
66
# Licensed under Apache License v2.0 with Runtime Library Exception
77
#
88
# See https://swift.org/LICENSE.txt for license information
@@ -37,8 +37,10 @@ set(SWIFTLIB_ESSENTIAL
3737
BridgeStorage.swift
3838
BridgingBuffer.swift
3939
Builtin.swift
40+
BuiltinMath.swift
4041
Character.swift
4142
CocoaArray.swift
43+
Codable.swift
4244
Collection.swift
4345
CollectionAlgorithms.swift
4446
Comparable.swift
@@ -61,6 +63,7 @@ set(SWIFTLIB_ESSENTIAL
6163
EmptyCollection.swift
6264
Equatable.swift
6365
ErrorType.swift
66+
ExistentialCollection.swift
6467
Filter.swift
6568
FixedArray.swift
6669
FlatMap.swift
@@ -91,6 +94,7 @@ set(SWIFTLIB_ESSENTIAL
9194
Map.swift
9295
MemoryLayout.swift
9396
UnicodeScalar.swift # ORDER DEPENDENCY: Must precede Mirrors.swift
97+
Mirrors.swift
9498
Misc.swift
9599
MutableCollection.swift
96100
NativeDictionary.swift
@@ -113,6 +117,7 @@ set(SWIFTLIB_ESSENTIAL
113117
REPL.swift
114118
Result.swift
115119
Reverse.swift
120+
Runtime.swift
116121
RuntimeFunctionCounters.swift
117122
SipHash.swift
118123
Sequence.swift
@@ -163,6 +168,7 @@ set(SWIFTLIB_ESSENTIAL
163168
SwiftNativeNSArray.swift
164169
ThreadLocalStorage.swift
165170
UIntBuffer.swift
171+
UnavailableStringAPIs.swift
166172
UnicodeEncoding.swift
167173
UnicodeHelpers.swift
168174
UnicodeParser.swift
@@ -185,14 +191,9 @@ set(SWIFTLIB_ESSENTIAL
185191

186192
set(SWIFTLIB_ESSENTIAL_GYB_SOURCES
187193
AtomicInt.swift.gyb
188-
BuiltinMath.swift.gyb
189-
Codable.swift.gyb
190194
FloatingPointParsing.swift.gyb
191195
FloatingPointTypes.swift.gyb
192196
IntegerTypes.swift.gyb
193-
Mirrors.swift.gyb
194-
Runtime.swift.gyb
195-
UnavailableStringAPIs.swift.gyb
196197
UnsafeBufferPointer.swift.gyb
197198
UnsafeRawBufferPointer.swift.gyb
198199
)
@@ -219,7 +220,6 @@ set(SWIFTLIB_SOURCES
219220

220221
set(SWIFTLIB_GYB_SOURCES
221222
${SWIFTLIB_ESSENTIAL_GYB_SOURCES}
222-
ExistentialCollection.swift.gyb
223223
SIMDVectorTypes.swift.gyb
224224
Tuple.swift.gyb
225225
)

0 commit comments

Comments
 (0)