1 ; RUN: llc -mattr=avr6 < %s -march=avr | FileCheck %s 2 3 ; Tests atomic operations on AVR 4 5 ; CHECK-LABEL: atomic_load8 6 ; CHECK: in r0, 63 7 ; CHECK-NEXT: cli 8 ; CHECK-NEXT: ld [[RR:r[0-9]+]], [[RD:(X|Y|Z)]] 9 ; CHECK-NEXT: out 63, r0 10 define i8 @atomic_load8(i8* %foo) { 11 %val = load atomic i8, i8* %foo unordered, align 1 12 ret i8 %val 13 } 14 15 ; CHECK-LABEL: atomic_load_swap8 16 ; CHECK: call __sync_lock_test_and_set_1 17 define i8 @atomic_load_swap8(i8* %foo) { 18 %val = atomicrmw xchg i8* %foo, i8 13 seq_cst 19 ret i8 %val 20 } 21 22 ; CHECK-LABEL: atomic_load_cmp_swap8 23 ; CHECK: call __sync_val_compare_and_swap_1 24 define i8 @atomic_load_cmp_swap8(i8* %foo) { 25 %val = cmpxchg i8* %foo, i8 5, i8 10 acq_rel monotonic 26 %value_loaded = extractvalue { i8, i1 } %val, 0 27 ret i8 %value_loaded 28 } 29 30 ; CHECK-LABEL: atomic_load_add8 31 ; CHECK: in r0, 63 32 ; CHECK-NEXT: cli 33 ; CHECK-NEXT: ld [[RD:r[0-9]+]], [[RR:(X|Y|Z)]] 34 ; CHECK-NEXT: add [[RD]], [[RR1:r[0-9]+]] 35 ; CHECK-NEXT: st [[RR]], [[RD]] 36 ; CHECK-NEXT: out 63, r0 37 define i8 @atomic_load_add8(i8* %foo) { 38 %val = atomicrmw add i8* %foo, i8 13 seq_cst 39 ret i8 %val 40 } 41 42 ; CHECK-LABEL: atomic_load_sub8 43 ; CHECK: in r0, 63 44 ; CHECK-NEXT: cli 45 ; CHECK-NEXT: ld [[RD:r[0-9]+]], [[RR:(X|Y|Z)]] 46 ; CHECK-NEXT: sub [[RD]], [[RR1:r[0-9]+]] 47 ; CHECK-NEXT: st [[RR]], [[RD]] 48 ; CHECK-NEXT: out 63, r0 49 define i8 @atomic_load_sub8(i8* %foo) { 50 %val = atomicrmw sub i8* %foo, i8 13 seq_cst 51 ret i8 %val 52 } 53 54 ; CHECK-LABEL: atomic_load_and8 55 ; CHECK: in r0, 63 56 ; CHECK-NEXT: cli 57 ; CHECK-NEXT: ld [[RD:r[0-9]+]], [[RR:(X|Y|Z)]] 58 ; CHECK-NEXT: and [[RD]], [[RR1:r[0-9]+]] 59 ; CHECK-NEXT: st [[RR]], [[RD]] 60 ; CHECK-NEXT: out 63, r0 61 define i8 @atomic_load_and8(i8* %foo) { 62 %val = atomicrmw and i8* %foo, i8 13 seq_cst 63 ret i8 %val 64 } 65 66 ; CHECK-LABEL: atomic_load_or8 67 ; CHECK: in r0, 63 68 ; CHECK-NEXT: cli 69 ; CHECK-NEXT: ld [[RD:r[0-9]+]], [[RR:(X|Y|Z)]] 70 ; CHECK-NEXT: or [[RD]], [[RR1:r[0-9]+]] 71 ; CHECK-NEXT: st [[RR]], [[RD]] 72 ; CHECK-NEXT: out 63, r0 73 define i8 @atomic_load_or8(i8* %foo) { 74 %val = atomicrmw or i8* %foo, i8 13 seq_cst 75 ret i8 %val 76 } 77 78 ; CHECK-LABEL: atomic_load_xor8 79 ; CHECK: in r0, 63 80 ; CHECK-NEXT: cli 81 ; CHECK-NEXT: ld [[RD:r[0-9]+]], [[RR:(X|Y|Z)]] 82 ; CHECK-NEXT: eor [[RD]], [[RR1:r[0-9]+]] 83 ; CHECK-NEXT: st [[RR]], [[RD]] 84 ; CHECK-NEXT: out 63, r0 85 define i8 @atomic_load_xor8(i8* %foo) { 86 %val = atomicrmw xor i8* %foo, i8 13 seq_cst 87 ret i8 %val 88 } 89 90 ; CHECK-LABEL: atomic_load_nand8 91 ; CHECK: call __sync_fetch_and_nand_1 92 define i8 @atomic_load_nand8(i8* %foo) { 93 %val = atomicrmw nand i8* %foo, i8 13 seq_cst 94 ret i8 %val 95 } 96 97 ; CHECK-LABEL: atomic_load_max8 98 ; CHECK: call __sync_fetch_and_max_1 99 define i8 @atomic_load_max8(i8* %foo) { 100 %val = atomicrmw max i8* %foo, i8 13 seq_cst 101 ret i8 %val 102 } 103 104 ; CHECK-LABEL: atomic_load_min8 105 ; CHECK: call __sync_fetch_and_min_1 106 define i8 @atomic_load_min8(i8* %foo) { 107 %val = atomicrmw min i8* %foo, i8 13 seq_cst 108 ret i8 %val 109 } 110 111 ; CHECK-LABEL: atomic_load_umax8 112 ; CHECK: call __sync_fetch_and_umax_1 113 define i8 @atomic_load_umax8(i8* %foo) { 114 %val = atomicrmw umax i8* %foo, i8 13 seq_cst 115 ret i8 %val 116 } 117 118 ; CHECK-LABEL: atomic_load_umin8 119 ; CHECK: call __sync_fetch_and_umin_1 120 define i8 @atomic_load_umin8(i8* %foo) { 121 %val = atomicrmw umin i8* %foo, i8 13 seq_cst 122 ret i8 %val 123 } 124 125