[clang] 7e60448 - [test] Improve x86 inline asm tests

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 11 23:35:52 PST 2024


Author: Fangrui Song
Date: 2024-01-11T23:35:46-08:00
New Revision: 7e604485e18d40be6ce6310e4a3e583ca0b7df47

URL: https://github.com/llvm/llvm-project/commit/7e604485e18d40be6ce6310e4a3e583ca0b7df47
DIFF: https://github.com/llvm/llvm-project/commit/7e604485e18d40be6ce6310e4a3e583ca0b7df47.diff

LOG: [test] Improve x86 inline asm tests

Reorganize *asm-modifier* and make other cleanups.

Added: 
    clang/test/CodeGen/X86/inline-asm-constraints.c
    llvm/test/CodeGen/X86/asm-modifier-32.ll
    llvm/test/CodeGen/X86/asm-modifier-macho.ll

Modified: 
    llvm/test/CodeGen/X86/asm-modifier-error.ll
    llvm/test/CodeGen/X86/asm-modifier.ll

Removed: 
    clang/test/CodeGen/X86/x86-inline-asm-v-constraint.c
    llvm/test/CodeGen/X86/2007-10-28-inlineasm-q-modifier.ll
    llvm/test/CodeGen/X86/inline-asm-bad-modifier.ll
    llvm/test/CodeGen/X86/inline-asm-modifier-V.ll
    llvm/test/CodeGen/X86/inline-asm-modifier-c.ll
    llvm/test/CodeGen/X86/inline-asm-modifier-n.ll
    llvm/test/CodeGen/X86/inline-asm-modifier-q.ll


################################################################################
diff  --git a/clang/test/CodeGen/X86/x86-inline-asm-v-constraint.c b/clang/test/CodeGen/X86/inline-asm-constraints.c
similarity index 100%
rename from clang/test/CodeGen/X86/x86-inline-asm-v-constraint.c
rename to clang/test/CodeGen/X86/inline-asm-constraints.c

diff  --git a/llvm/test/CodeGen/X86/2007-10-28-inlineasm-q-modifier.ll b/llvm/test/CodeGen/X86/2007-10-28-inlineasm-q-modifier.ll
deleted file mode 100644
index 335c0bcd5e411d..00000000000000
--- a/llvm/test/CodeGen/X86/2007-10-28-inlineasm-q-modifier.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: llc -no-integrated-as < %s
-; PR1748
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
-target triple = "x86_64-unknown-linux-gnu"
-
-define i32 @kernel_init(ptr %unused) {
-entry:
-	call void asm sideeffect "foo ${0:q}", "=*imr"( ptr elementtype( i64) null )
-	ret i32 0
-}
-

diff  --git a/llvm/test/CodeGen/X86/inline-asm-modifier-q.ll b/llvm/test/CodeGen/X86/asm-modifier-32.ll
similarity index 100%
rename from llvm/test/CodeGen/X86/inline-asm-modifier-q.ll
rename to llvm/test/CodeGen/X86/asm-modifier-32.ll

diff  --git a/llvm/test/CodeGen/X86/asm-modifier-error.ll b/llvm/test/CodeGen/X86/asm-modifier-error.ll
index d16ef65c7dc041..2d942c01fe0de2 100644
--- a/llvm/test/CodeGen/X86/asm-modifier-error.ll
+++ b/llvm/test/CodeGen/X86/asm-modifier-error.ll
@@ -7,3 +7,9 @@ entry:
   ret void
 }
 
+;CHECK: error: invalid operand in inline asm: 'vmovd ${1:k}, $0'
+define i32 @foo() {
+entry:
+  %0 = tail call i32 asm sideeffect "vmovd ${1:k}, $0", "=r,x,~{dirflag},~{fpsr},~{flags}"(<2 x i64> <i64 240518168632, i64 240518168632>)
+  ret i32 %0
+}

diff  --git a/llvm/test/CodeGen/X86/asm-modifier-macho.ll b/llvm/test/CodeGen/X86/asm-modifier-macho.ll
new file mode 100644
index 00000000000000..4f9124d8e225f1
--- /dev/null
+++ b/llvm/test/CodeGen/X86/asm-modifier-macho.ll
@@ -0,0 +1,41 @@
+; RUN: llc < %s | FileCheck %s
+; ModuleID = 'asm.c'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "i386-apple-darwin9.6"
+
+define i32 @test1() nounwind {
+entry:
+; CHECK-LABEL: test1:
+; CHECK: movw	%gs:6, %ax
+  %asmtmp.i = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 6) nounwind ; <i16> [#uses=1]
+  %0 = zext i16 %asmtmp.i to i32                  ; <i32> [#uses=1]
+  ret i32 %0
+}
+
+define zeroext i16 @test2(i32 %address) nounwind {
+entry:
+; CHECK-LABEL: test2:
+; CHECK: movw	%gs:(%eax), %ax
+  %asmtmp = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 %address) nounwind ; <i16> [#uses=1]
+  ret i16 %asmtmp
+}
+
+ at n = global i32 42                                ; <ptr> [#uses=3]
+ at y = common global i32 0                          ; <ptr> [#uses=3]
+
+define void @test3() nounwind {
+entry:
+; CHECK-LABEL: test3:
+; CHECK: movl _n, %eax
+  call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @n) nounwind
+  ret void
+}
+
+define void @test4() nounwind {
+entry:
+; CHECK-LABEL: test4:
+; CHECK: movl	L_y$non_lazy_ptr, %ecx
+; CHECK: movl (%ecx), %eax
+  call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @y) nounwind
+  ret void
+}

diff  --git a/llvm/test/CodeGen/X86/asm-modifier.ll b/llvm/test/CodeGen/X86/asm-modifier.ll
index 4f9124d8e225f1..c121b46f845065 100644
--- a/llvm/test/CodeGen/X86/asm-modifier.ll
+++ b/llvm/test/CodeGen/X86/asm-modifier.ll
@@ -1,41 +1,64 @@
-; RUN: llc < %s | FileCheck %s
-; ModuleID = 'asm.c'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
-target triple = "i386-apple-darwin9.6"
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
+; RUN: llc -mtriple=i686 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=x86_64 < %s | FileCheck %s --check-prefixes=CHECK,64
 
-define i32 @test1() nounwind {
-entry:
-; CHECK-LABEL: test1:
-; CHECK: movw	%gs:6, %ax
-  %asmtmp.i = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 6) nounwind ; <i16> [#uses=1]
-  %0 = zext i16 %asmtmp.i to i32                  ; <i32> [#uses=1]
-  ret i32 %0
-}
+ at var = internal global i32 0, align 4
 
-define zeroext i16 @test2(i32 %address) nounwind {
-entry:
-; CHECK-LABEL: test2:
-; CHECK: movw	%gs:(%eax), %ax
-  %asmtmp = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 %address) nounwind ; <i16> [#uses=1]
-  ret i16 %asmtmp
+define dso_local void @test_c() nounwind {
+; CHECK-LABEL: test_c:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    #APP
+; CHECK-NEXT:    #TEST 42
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:    #APP
+; CHECK-NEXT:    #TEST var
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:    ret{{[l|q]}}
+  tail call void asm sideeffect "#TEST ${0:c}", "i"(i32 42)
+  tail call void asm sideeffect "#TEST ${0:c}", "i"(ptr nonnull @var)
+  ret void
 }
 
- at n = global i32 42                                ; <ptr> [#uses=3]
- at y = common global i32 0                          ; <ptr> [#uses=3]
+define dso_local void @test_n() nounwind {
+; CHECK-LABEL: test_n:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    #APP
+; CHECK-NEXT:    #TEST 37
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:    ret{{[l|q]}}
+  tail call void asm sideeffect "#TEST ${0:n}", "i"(i32 -37)
+  ret void
+}
 
-define void @test3() nounwind {
+define void @test_q() {
+; CHECK-LABEL: test_q:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    #APP
+; CHECK-NEXT:    #TEST 0
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:    ret{{[l|q]}}
 entry:
-; CHECK-LABEL: test3:
-; CHECK: movl _n, %eax
-  call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @n) nounwind
+  call void asm sideeffect "#TEST ${0:q}", "=*imr"( ptr elementtype( i64) null )
   ret void
 }
 
-define void @test4() nounwind {
+define void @test_V(ptr %p) {
+; 32-LABEL: test_V:
+; 32:       # %bb.0: # %entry
+; 32-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; 32-NEXT:    #APP
+; 32-NEXT:    calll __x86_indirect_thunk_eax
+; 32-NEXT:    #NO_APP
+; 32-NEXT:    retl
+;
+; 64-LABEL: test_V:
+; 64:       # %bb.0: # %entry
+; 64-NEXT:    #APP
+; 64-NEXT:    callq __x86_indirect_thunk_rdi
+; 64-NEXT:    #NO_APP
+; 64-NEXT:    retq
 entry:
-; CHECK-LABEL: test4:
-; CHECK: movl	L_y$non_lazy_ptr, %ecx
-; CHECK: movl (%ecx), %eax
-  call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @y) nounwind
+  tail call void asm sideeffect "call __x86_indirect_thunk_${0:V}", "r,~{dirflag},~{fpsr},~{flags}"(ptr %p)
   ret void
 }
+

diff  --git a/llvm/test/CodeGen/X86/inline-asm-bad-modifier.ll b/llvm/test/CodeGen/X86/inline-asm-bad-modifier.ll
deleted file mode 100644
index 9f6e84f2f89c6d..00000000000000
--- a/llvm/test/CodeGen/X86/inline-asm-bad-modifier.ll
+++ /dev/null
@@ -1,8 +0,0 @@
-; RUN: not llc -mtriple=x86_64-- < %s 2>&1 | FileCheck %s
-
-;CHECK: error: invalid operand in inline asm: 'vmovd ${1:k}, $0'
-define i32 @foo() {
-entry:
-  %0 = tail call i32 asm sideeffect "vmovd ${1:k}, $0", "=r,x,~{dirflag},~{fpsr},~{flags}"(<2 x i64> <i64 240518168632, i64 240518168632>)
-  ret i32 %0
-}

diff  --git a/llvm/test/CodeGen/X86/inline-asm-modifier-V.ll b/llvm/test/CodeGen/X86/inline-asm-modifier-V.ll
deleted file mode 100644
index 25adc2e3b01a12..00000000000000
--- a/llvm/test/CodeGen/X86/inline-asm-modifier-V.ll
+++ /dev/null
@@ -1,14 +0,0 @@
-; RUN: llc < %s -mtriple=i686-- -no-integrated-as | FileCheck -check-prefix=X86 %s
-; RUN: llc < %s -mtriple=x86_64-- -no-integrated-as | FileCheck -check-prefix=X64 %s
-
-; If the target does not have 64-bit integer registers, emit 32-bit register
-; names.
-
-; X86: call __x86_indirect_thunk_e{{[abcd]}}x
-; X64: call __x86_indirect_thunk_r
-
-define void @q_modifier(ptr %p) {
-entry:
-  tail call void asm sideeffect "call __x86_indirect_thunk_${0:V}", "r,~{dirflag},~{fpsr},~{flags}"(ptr %p)
-  ret void
-}

diff  --git a/llvm/test/CodeGen/X86/inline-asm-modifier-c.ll b/llvm/test/CodeGen/X86/inline-asm-modifier-c.ll
deleted file mode 100644
index 95f62658483f11..00000000000000
--- a/llvm/test/CodeGen/X86/inline-asm-modifier-c.ll
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: llc -mtriple=x86_64-linux-gnu < %s | FileCheck %s
-
-; Test that %c works with immediates
-; CHECK-LABEL: test_inlineasm_c_output_template0
-; CHECK: #TEST 42
-define dso_local i32 @test_inlineasm_c_output_template0() {
-  tail call void asm sideeffect "#TEST ${0:c}", "i"(i32 42)
-  ret i32 42
-}
-
-; Test that %c works with global address
-; CHECK-LABEL: test_inlineasm_c_output_template1
-; CHECK: #TEST baz
- at baz = internal global i32 0, align 4
-define dso_local i32 @test_inlineasm_c_output_template1() {
-  tail call void asm sideeffect "#TEST ${0:c}", "i"(ptr nonnull @baz)
-  ret i32 42
-}

diff  --git a/llvm/test/CodeGen/X86/inline-asm-modifier-n.ll b/llvm/test/CodeGen/X86/inline-asm-modifier-n.ll
deleted file mode 100644
index 3df7112c8bc593..00000000000000
--- a/llvm/test/CodeGen/X86/inline-asm-modifier-n.ll
+++ /dev/null
@@ -1,15 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=i686-- -no-integrated-as | FileCheck %s
-; rdar://7008959
-
-define void @bork() nounwind {
-; CHECK-LABEL: bork:
-; CHECK:       # %bb.0: # %entry
-; CHECK-NEXT:    #APP
-; CHECK-NEXT:    BORK 37
-; CHECK-NEXT:    #NO_APP
-; CHECK-NEXT:    retl
-entry:
-	tail call void asm sideeffect "BORK ${0:n}", "i,~{dirflag},~{fpsr},~{flags}"(i32 -37) nounwind
-	ret void
-}


        


More information about the cfe-commits mailing list