Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland "[Clang][LoongArch] Add inline asm support for constraints k/m…
…/ZB/ZC" Reference: https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html k: A memory operand whose address is formed by a base register and (optionally scaled) index register. m: A memory operand whose address is formed by a base register and offset that is suitable for use in instructions with the same addressing mode as st.w and ld.w. ZB: An address that is held in a general-purpose register. The offset is zero. ZC: A memory operand whose address is formed by a base register and offset that is suitable for use in instructions with the same addressing mode as ll.w and sc.w. Note: The INLINEASM SDNode flags in below tests are updated because the new introduced enum `Constraint_k` is added before `Constraint_m`. llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-inline-asm.ll llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-inline-asm.ll llvm/test/CodeGen/X86/callbr-asm-kill.mir This patch passes `ninja check-all` on a X86 machine with all official targets and the LoongArch target enabled. Differential Revision: https://reviews.llvm.org/D134638
- Loading branch information
1 parent
4e62d02
commit 42b7079
Showing
17 changed files
with
570 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s \ | ||
; RUN: | FileCheck %s --check-prefix=ASM | ||
; RUN: llc --mtriple=loongarch64 --print-after-isel -o /dev/null 2>&1 < %s \ | ||
; RUN: | FileCheck %s --check-prefix=MACHINE-INSTR | ||
|
||
;; Note amswap.w is not available on loongarch32. | ||
|
||
define void @ZB(ptr %p) nounwind { | ||
; ASM-LABEL: ZB: | ||
; ASM: # %bb.0: | ||
; ASM-NEXT: #APP | ||
; ASM-NEXT: amswap.w $t0, $t1, $a0 | ||
; ASM-NEXT: #NO_APP | ||
; ASM-NEXT: ret | ||
;; Make sure machine instr with this "ZB" constraint is printed correctly. | ||
; MACHINE-INSTR: INLINEASM{{.*}}[mem:ZB] | ||
call void asm "amswap.w $$r12, $$r13, $0", "*^ZB"(ptr elementtype(i32) %p) | ||
ret void | ||
} | ||
|
||
define void @ZB_constant_offset(ptr %p) nounwind { | ||
; ASM-LABEL: ZB_constant_offset: | ||
; ASM: # %bb.0: | ||
; ASM-NEXT: addi.d $a0, $a0, 1 | ||
; ASM-NEXT: #APP | ||
; ASM-NEXT: amswap.w $t0, $t1, $a0 | ||
; ASM-NEXT: #NO_APP | ||
; ASM-NEXT: ret | ||
%1 = getelementptr inbounds i8, ptr %p, i32 1 | ||
;; Make sure machine instr with this "ZB" constraint is printed correctly. | ||
; MACHINE-INSTR: INLINEASM{{.*}}[mem:ZB] | ||
call void asm "amswap.w $$r12, $$r13, $0", "*^ZB"(ptr elementtype(i32) %1) | ||
ret void | ||
} | ||
|
||
define void @ZB_variable_offset(ptr %p, i32 signext %idx) nounwind { | ||
; ASM-LABEL: ZB_variable_offset: | ||
; ASM: # %bb.0: | ||
; ASM-NEXT: add.d $a0, $a0, $a1 | ||
; ASM-NEXT: #APP | ||
; ASM-NEXT: amswap.w $t0, $t1, $a0 | ||
; ASM-NEXT: #NO_APP | ||
; ASM-NEXT: ret | ||
%1 = getelementptr inbounds i8, ptr %p, i32 %idx | ||
;; Make sure machine instr with this "ZB" constraint is printed correctly. | ||
; MACHINE-INSTR: INLINEASM{{.*}}[mem:ZB] | ||
call void asm "amswap.w $$r12, $$r13, $0", "*^ZB"(ptr elementtype(i32) %1) | ||
ret void | ||
} |
Oops, something went wrong.