1
1
package compiler
2
2
3
3
import (
4
- "fmt"
5
- "strings"
6
-
7
4
"tinygo.org/x/go-llvm"
8
5
)
9
6
@@ -15,20 +12,6 @@ func (b *builder) createAtomicOp(name string) llvm.Value {
15
12
case "AddInt32" , "AddInt64" , "AddUint32" , "AddUint64" , "AddUintptr" :
16
13
ptr := b .getValue (b .fn .Params [0 ], getPos (b .fn ))
17
14
val := b .getValue (b .fn .Params [1 ], getPos (b .fn ))
18
- if strings .HasPrefix (b .Triple , "avr" ) {
19
- // AtomicRMW does not work on AVR as intended:
20
- // - There are some register allocation issues (fixed by https://reviews.llvm.org/D97127 which is not yet in a usable LLVM release)
21
- // - The result is the new value instead of the old value
22
- vType := val .Type ()
23
- name := fmt .Sprintf ("__sync_fetch_and_add_%d" , vType .IntTypeWidth ()/ 8 )
24
- fn := b .mod .NamedFunction (name )
25
- if fn .IsNil () {
26
- fn = llvm .AddFunction (b .mod , name , llvm .FunctionType (vType , []llvm.Type {ptr .Type (), vType }, false ))
27
- }
28
- oldVal := b .createCall (fn .GlobalValueType (), fn , []llvm.Value {ptr , val }, "" )
29
- // Return the new value, not the original value returned.
30
- return b .CreateAdd (oldVal , val , "" )
31
- }
32
15
oldVal := b .CreateAtomicRMW (llvm .AtomicRMWBinOpAdd , ptr , val , llvm .AtomicOrderingSequentiallyConsistent , true )
33
16
// Return the new value, not the original value returned by atomicrmw.
34
17
return b .CreateAdd (oldVal , val , "" )
0 commit comments