[llvm-branch-commits] [llvm] ae61485 - [UpdateTestChecks] Fix PowerPC RE to support AIX assembly

Qiu Chaofan via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 4 18:32:11 PST 2021


Author: Qiu Chaofan
Date: 2021-01-05T10:28:00+08:00
New Revision: ae614851631387f86cb7ab1f33a4851a6549c279

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

LOG: [UpdateTestChecks] Fix PowerPC RE to support AIX assembly

Current update_llc_test_checks.py cannot generate checks for AIX
(powerpc64-ibm-aix-xcoff) properly. Assembly generated is little bit
different from Linux. So I use begin function comment here to capture
function name.

Reviewed By: MaskRay, steven.zhang

Differential Revision: https://reviews.llvm.org/D93676

Added: 
    

Modified: 
    llvm/test/CodeGen/PowerPC/aix-lr.ll
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected
    llvm/utils/UpdateTestChecks/asm.py

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/PowerPC/aix-lr.ll b/llvm/test/CodeGen/PowerPC/aix-lr.ll
index ea92daf04f07..38ebf297e591 100644
--- a/llvm/test/CodeGen/PowerPC/aix-lr.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-lr.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff < %s | \
 ; RUN: FileCheck --check-prefix=32BIT %s
 
@@ -5,25 +6,32 @@
 ; RUN: FileCheck --check-prefix=64BIT %s
 
 define void @bar() {
+; 32BIT-LABEL: bar:
+; 32BIT:       # %bb.0: # %entry
+; 32BIT-NEXT:    mflr 0
+; 32BIT-NEXT:    stw 0, 8(1)
+; 32BIT-NEXT:    stwu 1, -64(1)
+; 32BIT-NEXT:    bl .foo[PR]
+; 32BIT-NEXT:    nop
+; 32BIT-NEXT:    addi 1, 1, 64
+; 32BIT-NEXT:    lwz 0, 8(1)
+; 32BIT-NEXT:    mtlr 0
+; 32BIT-NEXT:    blr
+;
+; 64BIT-LABEL: bar:
+; 64BIT:       # %bb.0: # %entry
+; 64BIT-NEXT:    mflr 0
+; 64BIT-NEXT:    std 0, 16(1)
+; 64BIT-NEXT:    stdu 1, -112(1)
+; 64BIT-NEXT:    bl .foo[PR]
+; 64BIT-NEXT:    nop
+; 64BIT-NEXT:    addi 1, 1, 112
+; 64BIT-NEXT:    ld 0, 16(1)
+; 64BIT-NEXT:    mtlr 0
+; 64BIT-NEXT:    blr
 entry:
 
-; 32BIT: mflr 0
-; 32BIT: stw 0, 8(1)
-; 32BIT: stwu 1, -64(1)
-; 32BIT: bl .foo
-; 32BIT: nop
-; 32BIT: addi 1, 1, 64
-; 32BIT: lwz 0, 8(1)
-; 32BIT: mtlr 0
 
-; 64BIT: mflr 0
-; 64BIT: std 0, 16(1)
-; 64BIT: stdu 1, -112(1)
-; 64BIT: bl .foo
-; 64BIT: nop
-; 64BIT: addi 1, 1, 112
-; 64BIT: ld 0, 16(1)
-; 64BIT: mtlr 0
 
   call void bitcast (void (...)* @foo to void ()*)()
   ret void

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll
index cd545199697f..d31a3361635a 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -enable-machine-outliner -mtriple=ppc32-unknown-linux < %s | FileCheck %s
+; RUN: llc -enable-machine-outliner -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s -check-prefix=AIX
 ;
 ; NOTE: Machine outliner doesn't run.
 @x = global i32 0, align 4

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected
index 57298fa6e019..1fca598d23fe 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --include-generated-funcs
 ; RUN: llc -enable-machine-outliner -mtriple=ppc32-unknown-linux < %s | FileCheck %s
+; RUN: llc -enable-machine-outliner -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s -check-prefix=AIX
 ; NOTE: Machine outliner doesn't run.
 @x = global i32 0, align 4
 
@@ -127,3 +128,62 @@ attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
 ; CHECK-NEXT:    lwz 31, 28(1)
 ; CHECK-NEXT:    addi 1, 1, 32
 ; CHECK-NEXT:    blr
+;
+; AIX-LABEL: check_boundaries:
+; AIX:       # %bb.0:
+; AIX-NEXT:    stw 31, -4(1)
+; AIX-NEXT:    stwu 1, -48(1)
+; AIX-NEXT:    mr 31, 1
+; AIX-NEXT:    li 4, 0
+; AIX-NEXT:    li 3, 1
+; AIX-NEXT:    stw 4, 40(31)
+; AIX-NEXT:    li 4, 2
+; AIX-NEXT:    li 5, 3
+; AIX-NEXT:    li 6, 4
+; AIX-NEXT:    cmplwi 3, 0
+; AIX-NEXT:    stw 3, 36(31)
+; AIX-NEXT:    stw 4, 32(31)
+; AIX-NEXT:    stw 5, 28(31)
+; AIX-NEXT:    stw 6, 24(31)
+; AIX-NEXT:    beq 0, L..BB0_2
+; AIX-NEXT:  # %bb.1:
+; AIX-NEXT:    stw 3, 28(31)
+; AIX-NEXT:    b L..BB0_3
+; AIX-NEXT:  L..BB0_2:
+; AIX-NEXT:    stw 3, 36(31)
+; AIX-NEXT:    stw 4, 32(31)
+; AIX-NEXT:    stw 5, 28(31)
+; AIX-NEXT:    stw 6, 24(31)
+; AIX-NEXT:  L..BB0_3:
+; AIX-NEXT:    li 3, 0
+; AIX-NEXT:    addi 1, 1, 48
+; AIX-NEXT:    lwz 31, -4(1)
+; AIX-NEXT:    blr
+;
+; AIX-LABEL: main:
+; AIX:       # %bb.0:
+; AIX-NEXT:    stw 31, -4(1)
+; AIX-NEXT:    stwu 1, -48(1)
+; AIX-NEXT:    lwz 4, L..C0(2)
+; AIX-NEXT:    mr 31, 1
+; AIX-NEXT:    li 3, 0
+; AIX-NEXT:    stw 3, 40(31)
+; AIX-NEXT:    li 3, 1
+; AIX-NEXT:    li 5, 2
+; AIX-NEXT:    li 6, 3
+; AIX-NEXT:    li 7, 4
+; AIX-NEXT:    stw 3, 36(31)
+; AIX-NEXT:    stw 5, 32(31)
+; AIX-NEXT:    stw 6, 28(31)
+; AIX-NEXT:    stw 7, 24(31)
+; AIX-NEXT:    stw 3, 0(4)
+; AIX-NEXT:    #APP
+; AIX-NEXT:    #NO_APP
+; AIX-NEXT:    stw 3, 36(31)
+; AIX-NEXT:    li 3, 0
+; AIX-NEXT:    stw 5, 32(31)
+; AIX-NEXT:    stw 6, 28(31)
+; AIX-NEXT:    stw 7, 24(31)
+; AIX-NEXT:    addi 1, 1, 48
+; AIX-NEXT:    lwz 31, -4(1)
+; AIX-NEXT:    blr

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected
index 2005ff401b4b..13512d401a7f 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -enable-machine-outliner -mtriple=ppc32-unknown-linux < %s | FileCheck %s
+; RUN: llc -enable-machine-outliner -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s -check-prefix=AIX
 ;
 ; NOTE: Machine outliner doesn't run.
 @x = global i32 0, align 4
@@ -38,6 +39,37 @@ define dso_local i32 @check_boundaries() #0 {
 ; CHECK-NEXT:    lwz 31, 28(1)
 ; CHECK-NEXT:    addi 1, 1, 32
 ; CHECK-NEXT:    blr
+;
+; AIX-LABEL: check_boundaries:
+; AIX:       # %bb.0:
+; AIX-NEXT:    stw 31, -4(1)
+; AIX-NEXT:    stwu 1, -48(1)
+; AIX-NEXT:    mr 31, 1
+; AIX-NEXT:    li 4, 0
+; AIX-NEXT:    li 3, 1
+; AIX-NEXT:    stw 4, 40(31)
+; AIX-NEXT:    li 4, 2
+; AIX-NEXT:    li 5, 3
+; AIX-NEXT:    li 6, 4
+; AIX-NEXT:    cmplwi 3, 0
+; AIX-NEXT:    stw 3, 36(31)
+; AIX-NEXT:    stw 4, 32(31)
+; AIX-NEXT:    stw 5, 28(31)
+; AIX-NEXT:    stw 6, 24(31)
+; AIX-NEXT:    beq 0, L..BB0_2
+; AIX-NEXT:  # %bb.1:
+; AIX-NEXT:    stw 3, 28(31)
+; AIX-NEXT:    b L..BB0_3
+; AIX-NEXT:  L..BB0_2:
+; AIX-NEXT:    stw 3, 36(31)
+; AIX-NEXT:    stw 4, 32(31)
+; AIX-NEXT:    stw 5, 28(31)
+; AIX-NEXT:    stw 6, 24(31)
+; AIX-NEXT:  L..BB0_3:
+; AIX-NEXT:    li 3, 0
+; AIX-NEXT:    addi 1, 1, 48
+; AIX-NEXT:    lwz 31, -4(1)
+; AIX-NEXT:    blr
   %1 = alloca i32, align 4
   %2 = alloca i32, align 4
   %3 = alloca i32, align 4
@@ -105,6 +137,34 @@ define dso_local i32 @main() #0 {
 ; CHECK-NEXT:    lwz 31, 28(1)
 ; CHECK-NEXT:    addi 1, 1, 32
 ; CHECK-NEXT:    blr
+;
+; AIX-LABEL: main:
+; AIX:       # %bb.0:
+; AIX-NEXT:    stw 31, -4(1)
+; AIX-NEXT:    stwu 1, -48(1)
+; AIX-NEXT:    lwz 4, L..C0(2)
+; AIX-NEXT:    mr 31, 1
+; AIX-NEXT:    li 3, 0
+; AIX-NEXT:    stw 3, 40(31)
+; AIX-NEXT:    li 3, 1
+; AIX-NEXT:    li 5, 2
+; AIX-NEXT:    li 6, 3
+; AIX-NEXT:    li 7, 4
+; AIX-NEXT:    stw 3, 36(31)
+; AIX-NEXT:    stw 5, 32(31)
+; AIX-NEXT:    stw 6, 28(31)
+; AIX-NEXT:    stw 7, 24(31)
+; AIX-NEXT:    stw 3, 0(4)
+; AIX-NEXT:    #APP
+; AIX-NEXT:    #NO_APP
+; AIX-NEXT:    stw 3, 36(31)
+; AIX-NEXT:    li 3, 0
+; AIX-NEXT:    stw 5, 32(31)
+; AIX-NEXT:    stw 6, 28(31)
+; AIX-NEXT:    stw 7, 24(31)
+; AIX-NEXT:    addi 1, 1, 48
+; AIX-NEXT:    lwz 31, -4(1)
+; AIX-NEXT:    blr
   %1 = alloca i32, align 4
   %2 = alloca i32, align 4
   %3 = alloca i32, align 4

diff  --git a/llvm/utils/UpdateTestChecks/asm.py b/llvm/utils/UpdateTestChecks/asm.py
index a42a75ed26bf..407b26cf1523 100644
--- a/llvm/utils/UpdateTestChecks/asm.py
+++ b/llvm/utils/UpdateTestChecks/asm.py
@@ -68,15 +68,14 @@ class string:
     flags=(re.M | re.S))
 
 ASM_FUNCTION_PPC_RE = re.compile(
-    r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@"?(?P=func)"?\n'
+    r'#[ \-\t]*Begin function (?P<func>[^.:]+)\n'
     r'.*?'
-    r'\.Lfunc_begin[0-9]+:\n'
-    r'(?:[ \t]+.cfi_startproc\n)?'
-    r'(?:\.Lfunc_[gl]ep[0-9]+:\n(?:[ \t]+.*?\n)*)*'
+    r'^[_.]?(?P=func):(?:[ \t]*#+[ \t]*@"?(?P=func)"?)?\n'
+    r'(?:^[^#]*\n)*'
     r'(?P<body>.*?)\n'
     # This list is incomplete
-    r'(?:^[ \t]*(?:\.long[ \t]+[^\n]+|\.quad[ \t]+[^\n]+)\n)*'
-    r'.Lfunc_end[0-9]+:\n',
+    r'(?:^[ \t]*(?:\.(?:long|quad|v?byte)[ \t]+[^\n]+)\n)*'
+    r'(?:\.Lfunc_end|L\.\.(?P=func))[0-9]+:\n',
     flags=(re.M | re.S))
 
 ASM_FUNCTION_RISCV_RE = re.compile(


        


More information about the llvm-branch-commits mailing list