Skip to content
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
20 changes: 20 additions & 0 deletions stdlib/public/Synchronization/Mutex/SpinLoopHint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var _tries: Int {
100
}

#if arch(arm)

// The following are acceptable operands to the aarch64 hint intrinsic from
// 'llvm-project/llvm/lib/Target/ARM/ARMInstrInfo.td':
//
Expand All @@ -28,9 +30,27 @@ var _tries: Int {
// `sevl` = 5
//
// There are others, but for the sake of spin loops, we only care about 'wfe'.
@_extern(c, "llvm.arm.hint")
func _hint(_: UInt32)

#else

// The following are acceptable operands to the aarch64 hint intrinsic from
// 'llvm-project/llvm/lib/Target/AArch64/AArch64InstrInfo.td':
//
// `nop` = 0
// `yield` = 1
// `wfe` = 2
// `wfi` = 3
// `sev` = 4
// `sevl` = 5
//
// There are others, but for the sake of spin loops, we only care about 'wfe'.
@_extern(c, "llvm.aarch64.hint")
func _hint(_: UInt32)

#endif

@inline(__always)
func _wfe() {
_hint(2)
Expand Down