Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
tests:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
enable_wasm_sdk_build: true
wasm_sdk_build_command: swift build --target Numerics
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
Expand Down
5 changes: 5 additions & 0 deletions Sources/RealModule/Float16+Real.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ extension Float16: Real {
}
#endif

#if !arch(wasm32)
// WASM doesn't have _Float16 on the C side, so we can't define the C hooks
// that these use. TODO: implement these as Swift builtins instead.

@_transparent
public static func _relaxedAdd(_ a: Float16, _ b: Float16) -> Float16 {
_numerics_relaxed_addf16(a, b)
Expand All @@ -182,6 +186,7 @@ extension Float16: Real {
public static func _relaxedMul(_ a: Float16, _ b: Float16) -> Float16 {
_numerics_relaxed_mulf16(a, b)
}
#endif
}

#endif
2 changes: 2 additions & 0 deletions Sources/_NumericsShims/include/_NumericsShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ HEADER_SHIM long double libm_lgammal(long double x, int *signp) {
// MARK: - math inlines with relaxed semantics to support optimization.
#define CLANG_RELAX_FP _Pragma("clang fp reassociate(on) contract(fast)")

#if !defined __wasm__ // No _Float16 on wasm
/// a + b with the "allow reassociation" and "allow FMA formation" flags
/// set in the IR.
HEADER_SHIM _Float16 _numerics_relaxed_addf16(_Float16 a, _Float16 b) {
Expand All @@ -402,6 +403,7 @@ HEADER_SHIM _Float16 _numerics_relaxed_mulf16(_Float16 a, _Float16 b) {
CLANG_RELAX_FP
return a * b;
}
#endif

/// a + b with the "allow reassociation" and "allow FMA formation" flags
/// set in the IR.
Expand Down
Loading