1 ; RUN: llc --mtriple=loongarch64 -mattr=+d --verify-machineinstrs < %s \
2 ; RUN: | FileCheck %s --check-prefix=ASM
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d --print-after-isel -o /dev/null 2>&1 < %s \
4 ; RUN: | FileCheck %s --check-prefix=MACHINE-INSTR
6 ;; Note amswap.w is not available on loongarch32.
8 define void @ZB(ptr %p) nounwind {
12 ; ASM-NEXT: amswap.w $t0, $t1, $a0
15 ;; Make sure machine instr with this "ZB" constraint is printed correctly.
16 ; MACHINE-INSTR: INLINEASM{{.*}}[mem:ZB]
17 call void asm "amswap.w $$r12, $$r13, $0", "*^ZB"(ptr elementtype(i32) %p)
21 define void @ZB_constant_offset(ptr %p) nounwind {
22 ; ASM-LABEL: ZB_constant_offset:
24 ; ASM-NEXT: addi.d $a0, $a0, 1
26 ; ASM-NEXT: amswap.w $t0, $t1, $a0
29 %1 = getelementptr inbounds i8, ptr %p, i32 1
30 ;; Make sure machine instr with this "ZB" constraint is printed correctly.
31 ; MACHINE-INSTR: INLINEASM{{.*}}[mem:ZB]
32 call void asm "amswap.w $$r12, $$r13, $0", "*^ZB"(ptr elementtype(i32) %1)
36 define void @ZB_variable_offset(ptr %p, i32 signext %idx) nounwind {
37 ; ASM-LABEL: ZB_variable_offset:
39 ; ASM-NEXT: add.d $a0, $a0, $a1
41 ; ASM-NEXT: amswap.w $t0, $t1, $a0
44 %1 = getelementptr inbounds i8, ptr %p, i32 %idx
45 ;; Make sure machine instr with this "ZB" constraint is printed correctly.
46 ; MACHINE-INSTR: INLINEASM{{.*}}[mem:ZB]
47 call void asm "amswap.w $$r12, $$r13, $0", "*^ZB"(ptr elementtype(i32) %1)
51 define void @ZB_Input_Output(ptr %p) nounwind {
52 ; ASM-LABEL: ZB_Input_Output:
55 ; ASM-NEXT: amadd_db.d $zero, $t1, $a0
58 ;; Make sure machine instr with this "ZB" constraint is printed correctly.
59 ; MACHINE-INSTR: INLINEASM{{.*}}[mem:ZB], %0:gpr, 0
60 call void asm "amadd_db.d $$zero, $$r13, $0", "=*^ZB,*^ZB,~{memory}"(ptr elementtype(i64) %p, ptr elementtype(i64) %p)