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 5 6;; Note amswap.w is not available on loongarch32. 7 8define void @ZB(ptr %p) nounwind { 9; ASM-LABEL: ZB: 10; ASM: # %bb.0: 11; ASM-NEXT: #APP 12; ASM-NEXT: amswap.w $t0, $t1, $a0 13; ASM-NEXT: #NO_APP 14; ASM-NEXT: ret 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) 18 ret void 19} 20 21define void @ZB_constant_offset(ptr %p) nounwind { 22; ASM-LABEL: ZB_constant_offset: 23; ASM: # %bb.0: 24; ASM-NEXT: addi.d $a0, $a0, 1 25; ASM-NEXT: #APP 26; ASM-NEXT: amswap.w $t0, $t1, $a0 27; ASM-NEXT: #NO_APP 28; ASM-NEXT: ret 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) 33 ret void 34} 35 36define void @ZB_variable_offset(ptr %p, i32 signext %idx) nounwind { 37; ASM-LABEL: ZB_variable_offset: 38; ASM: # %bb.0: 39; ASM-NEXT: add.d $a0, $a0, $a1 40; ASM-NEXT: #APP 41; ASM-NEXT: amswap.w $t0, $t1, $a0 42; ASM-NEXT: #NO_APP 43; ASM-NEXT: ret 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) 48 ret void 49} 50 51define void @ZB_Input_Output(ptr %p) nounwind { 52; ASM-LABEL: ZB_Input_Output: 53; ASM: # %bb.0: 54; ASM-NEXT: #APP 55; ASM-NEXT: amadd_db.d $zero, $t1, $a0 56; ASM-NEXT: #NO_APP 57; ASM-NEXT: ret 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) 61 ret void 62} 63