Skip to content

Commit b51cda9

Browse files
aykevldeadprogram
authored andcommitted
sync/atomic: add And* and Or* compiler intrinsics needed for Go 1.23
1 parent 4d60d67 commit b51cda9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compiler/atomic.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ func (b *builder) createAtomicOp(name string) llvm.Value {
1515
oldVal := b.CreateAtomicRMW(llvm.AtomicRMWBinOpAdd, ptr, val, llvm.AtomicOrderingSequentiallyConsistent, true)
1616
// Return the new value, not the original value returned by atomicrmw.
1717
return b.CreateAdd(oldVal, val, "")
18+
case "AndInt32", "AndInt64", "AndUint32", "AndUint64", "AndUintptr":
19+
ptr := b.getValue(b.fn.Params[0], getPos(b.fn))
20+
val := b.getValue(b.fn.Params[1], getPos(b.fn))
21+
oldVal := b.CreateAtomicRMW(llvm.AtomicRMWBinOpAnd, ptr, val, llvm.AtomicOrderingSequentiallyConsistent, true)
22+
return oldVal
23+
case "OrInt32", "OrInt64", "OrUint32", "OrUint64", "OrUintptr":
24+
ptr := b.getValue(b.fn.Params[0], getPos(b.fn))
25+
val := b.getValue(b.fn.Params[1], getPos(b.fn))
26+
oldVal := b.CreateAtomicRMW(llvm.AtomicRMWBinOpOr, ptr, val, llvm.AtomicOrderingSequentiallyConsistent, true)
27+
return oldVal
1828
case "SwapInt32", "SwapInt64", "SwapUint32", "SwapUint64", "SwapUintptr", "SwapPointer":
1929
ptr := b.getValue(b.fn.Params[0], getPos(b.fn))
2030
val := b.getValue(b.fn.Params[1], getPos(b.fn))

0 commit comments

Comments
 (0)