UpdateTestChecks: fix AMDGPU handling
Summary:
Was looking into supporting `(srl (shl x, c1), c2)` with c1 != c2 in dagcombiner,
this test changes, but makes `update_llc_test_checks.py` unhappy.
**Many** AMDGPU tests specify `-march`, not `-mtriple`, which results in `update_llc_test_checks.py`
defaulting to x86 asm function detection heuristics, which don't work here.
I propose to fix this by adding an infrastructure to map from `-march` to `-mtriple`,
in the UpdateTestChecks tooling.
Reviewers: RKSimon, MaskRay, arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62099
llvm-svn: 361101
2019-05-18 21:00:03 +08:00
|
|
|
from __future__ import print_function
|
2018-01-30 08:40:05 +08:00
|
|
|
import re
|
2018-02-10 13:01:33 +08:00
|
|
|
import sys
|
2018-01-30 08:40:05 +08:00
|
|
|
|
|
|
|
from . import common
|
|
|
|
|
2018-02-10 13:01:33 +08:00
|
|
|
if sys.version_info[0] > 2:
|
|
|
|
class string:
|
|
|
|
expandtabs = str.expandtabs
|
|
|
|
else:
|
|
|
|
import string
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
# RegEx: this is where the magic happens.
|
|
|
|
|
2018-02-10 13:01:33 +08:00
|
|
|
##### Assembly parser
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
ASM_FUNCTION_X86_RE = re.compile(
|
2019-04-30 04:25:56 +08:00
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n(?:\s*\.?Lfunc_begin[^:\n]*:\n)?[^:]*?'
|
2018-01-30 08:40:05 +08:00
|
|
|
r'(?P<body>^##?[ \t]+[^:]+:.*?)\s*'
|
|
|
|
r'^\s*(?:[^:\n]+?:\s*\n\s*\.size|\.cfi_endproc|\.globl|\.comm|\.(?:sub)?section|#+ -- End function)',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
|
|
|
ASM_FUNCTION_ARM_RE = re.compile(
|
|
|
|
r'^(?P<func>[0-9a-zA-Z_]+):\n' # f: (name of function)
|
|
|
|
r'\s+\.fnstart\n' # .fnstart
|
|
|
|
r'(?P<body>.*?)\n' # (body of the function)
|
|
|
|
r'.Lfunc_end[0-9]+:', # .Lfunc_end0: or # -- End function
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
|
|
|
ASM_FUNCTION_AARCH64_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*\/\/[ \t]*@(?P=func)\n'
|
2019-05-24 03:15:05 +08:00
|
|
|
r'(?:[ \t]+.cfi_startproc\n)?' # drop optional cfi noise
|
2018-01-30 08:40:05 +08:00
|
|
|
r'(?P<body>.*?)\n'
|
|
|
|
# This list is incomplete
|
|
|
|
r'.Lfunc_end[0-9]+:\n',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
[Utils] update_llc_test_checks.py: support AMDGPU backend: AMDGCN, r600 triples
Summary:
Lack of that support has taken me by surprise.
I need to add (or at least look at) some tests for https://reviews.llvm.org/D47980#1127615,
and i don't really fancy doing that by hand.
The asm pattern is quite similar to that of x86:
https://godbolt.org/g/hfgeds
just with `#` replaced with `;`
Reviewers: spatel, RKSimon, MaskRay, tstellar, arsenm
Reviewed By: arsenm
Subscribers: arsenm, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, rampitec, bogner, mareko, llvm-commits
Tags: #amdgpu
Differential Revision: https://reviews.llvm.org/D48001
llvm-svn: 334396
2018-06-11 17:20:21 +08:00
|
|
|
ASM_FUNCTION_AMDGPU_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*;+[ \t]*@(?P=func)\n[^:]*?'
|
|
|
|
r'(?P<body>.*?)\n' # (body of the function)
|
|
|
|
# This list is incomplete
|
2019-06-15 04:40:15 +08:00
|
|
|
r'^\s*(\.Lfunc_end[0-9]+:\n|\.section)',
|
[Utils] update_llc_test_checks.py: support AMDGPU backend: AMDGCN, r600 triples
Summary:
Lack of that support has taken me by surprise.
I need to add (or at least look at) some tests for https://reviews.llvm.org/D47980#1127615,
and i don't really fancy doing that by hand.
The asm pattern is quite similar to that of x86:
https://godbolt.org/g/hfgeds
just with `#` replaced with `;`
Reviewers: spatel, RKSimon, MaskRay, tstellar, arsenm
Reviewed By: arsenm
Subscribers: arsenm, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, rampitec, bogner, mareko, llvm-commits
Tags: #amdgpu
Differential Revision: https://reviews.llvm.org/D48001
llvm-svn: 334396
2018-06-11 17:20:21 +08:00
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2019-06-05 22:08:01 +08:00
|
|
|
ASM_FUNCTION_HEXAGON_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*//[ \t]*@(?P=func)\n[^:]*?'
|
|
|
|
r'(?P<body>.*?)\n' # (body of the function)
|
|
|
|
# This list is incomplete
|
|
|
|
r'.Lfunc_end[0-9]+:\n',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
ASM_FUNCTION_MIPS_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n[^:]*?' # f: (name of func)
|
|
|
|
r'(?:^[ \t]+\.(frame|f?mask|set).*?\n)+' # Mips+LLVM standard asm prologue
|
|
|
|
r'(?P<body>.*?)\n' # (body of the function)
|
2019-10-31 00:52:16 +08:00
|
|
|
# Mips+LLVM standard asm epilogue
|
|
|
|
r'(?:(^[ \t]+\.set[^\n]*?\n)*^[ \t]+\.end.*?\n)'
|
2018-01-30 08:40:05 +08:00
|
|
|
r'(\$|\.L)func_end[0-9]+:\n', # $func_end0: (mips32 - O32) or
|
|
|
|
# .Lfunc_end0: (mips64 - NewABI)
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2019-10-03 22:34:28 +08:00
|
|
|
ASM_FUNCTION_MSP430_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*;+[ \t]*@(?P=func)\n[^:]*?'
|
|
|
|
r'(?P<body>.*?)\n'
|
|
|
|
r'(\$|\.L)func_end[0-9]+:\n', # $func_end0:
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
ASM_FUNCTION_PPC_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n'
|
2018-10-26 11:30:28 +08:00
|
|
|
r'.*?'
|
2018-01-30 08:40:05 +08:00
|
|
|
r'\.Lfunc_begin[0-9]+:\n'
|
|
|
|
r'(?:[ \t]+.cfi_startproc\n)?'
|
|
|
|
r'(?:\.Lfunc_[gl]ep[0-9]+:\n(?:[ \t]+.*?\n)*)*'
|
|
|
|
r'(?P<body>.*?)\n'
|
|
|
|
# This list is incomplete
|
|
|
|
r'(?:^[ \t]*(?:\.long[ \t]+[^\n]+|\.quad[ \t]+[^\n]+)\n)*'
|
|
|
|
r'.Lfunc_end[0-9]+:\n',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
|
|
|
ASM_FUNCTION_RISCV_RE = re.compile(
|
2019-07-08 16:34:16 +08:00
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n(?:\s*\.?Lfunc_begin[^:\n]*:\n)?[^:]*?'
|
2018-01-30 08:40:05 +08:00
|
|
|
r'(?P<body>^##?[ \t]+[^:]+:.*?)\s*'
|
|
|
|
r'.Lfunc_end[0-9]+:\n',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2019-05-30 04:03:00 +08:00
|
|
|
ASM_FUNCTION_LANAI_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*!+[ \t]*@(?P=func)\n'
|
|
|
|
r'(?:[ \t]+.cfi_startproc\n)?' # drop optional cfi noise
|
|
|
|
r'(?P<body>.*?)\s*'
|
|
|
|
r'.Lfunc_end[0-9]+:\n',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2018-04-20 15:59:13 +08:00
|
|
|
ASM_FUNCTION_SPARC_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*!+[ \t]*@(?P=func)\n'
|
|
|
|
r'(?P<body>.*?)\s*'
|
|
|
|
r'.Lfunc_end[0-9]+:\n',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
ASM_FUNCTION_SYSTEMZ_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n'
|
|
|
|
r'[ \t]+.cfi_startproc\n'
|
|
|
|
r'(?P<body>.*?)\n'
|
|
|
|
r'.Lfunc_end[0-9]+:\n',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
[NFC] Improve triple match of scripts that update tests
Summary:
The prior behavior of the triple matcher would stop
in the first matched triple. It was not possible to
create specific matches for sub-sets of a triple
(e.g aarch64-apple-darwin would never be used after
aarch64 was matched).
This patch:
1) Allows that specialized triples take priority,
considering that the string lenght of the triple
indentifies how specialized a triple is. If two
triples of same lenght match, the one matched first
prevails, preserving the old behavior.
2) Remove 20 duplicated triples of arm, thumb,
aarch64 options with same arguments, matching
the common prefix (aarch64, arm, thumb) of them.
3) Creates three new function matching regexes and
five triple options for arm64-apple-ios,
(arm|thumb)-apple-ios and thumb(v5)?-macho
Reviewers: lebedev.ri, RKSimon, MaskRay, gbedwell
Reviewed By: MaskRay
Subscribers: javed.absar, kristof.beyls, llvm-commits, carwil
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63145
llvm-svn: 363656
2019-06-18 18:04:36 +08:00
|
|
|
ASM_FUNCTION_AARCH64_DARWIN_RE = re.compile(
|
|
|
|
r'^_(?P<func>[^:]+):[ \t]*;[ \t]@(?P=func)\n'
|
|
|
|
r'([ \t]*.cfi_startproc\n[\s]*)?'
|
|
|
|
r'(?P<body>.*?)'
|
|
|
|
r'([ \t]*.cfi_endproc\n[\s]*)?'
|
|
|
|
r'^[ \t]*;[ \t]--[ \t]End[ \t]function',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2019-06-29 02:07:19 +08:00
|
|
|
ASM_FUNCTION_ARM_DARWIN_RE = re.compile(
|
|
|
|
r'^[ \t]*\.globl[ \t]*_(?P<func>[^ \t])[ \t]*@[ \t]--[ \t]Begin[ \t]function[ \t](?P=func)'
|
|
|
|
r'(?P<directives>.*?)'
|
|
|
|
r'^_(?P=func):\n[ \t]*'
|
|
|
|
r'(?P<body>.*?)'
|
|
|
|
r'^[ \t]*@[ \t]--[ \t]End[ \t]function',
|
|
|
|
flags=(re.M | re.S ))
|
|
|
|
|
[NFC] Improve triple match of scripts that update tests
Summary:
The prior behavior of the triple matcher would stop
in the first matched triple. It was not possible to
create specific matches for sub-sets of a triple
(e.g aarch64-apple-darwin would never be used after
aarch64 was matched).
This patch:
1) Allows that specialized triples take priority,
considering that the string lenght of the triple
indentifies how specialized a triple is. If two
triples of same lenght match, the one matched first
prevails, preserving the old behavior.
2) Remove 20 duplicated triples of arm, thumb,
aarch64 options with same arguments, matching
the common prefix (aarch64, arm, thumb) of them.
3) Creates three new function matching regexes and
five triple options for arm64-apple-ios,
(arm|thumb)-apple-ios and thumb(v5)?-macho
Reviewers: lebedev.ri, RKSimon, MaskRay, gbedwell
Reviewed By: MaskRay
Subscribers: javed.absar, kristof.beyls, llvm-commits, carwil
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63145
llvm-svn: 363656
2019-06-18 18:04:36 +08:00
|
|
|
ASM_FUNCTION_ARM_MACHO_RE = re.compile(
|
|
|
|
r'^_(?P<func>[^:]+):[ \t]*\n'
|
|
|
|
r'([ \t]*.cfi_startproc\n[ \t]*)?'
|
|
|
|
r'(?P<body>.*?)\n'
|
|
|
|
r'[ \t]*\.cfi_endproc\n',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
|
|
|
ASM_FUNCTION_ARM_IOS_RE = re.compile(
|
|
|
|
r'^_(?P<func>[^:]+):[ \t]*\n'
|
|
|
|
r'^Lfunc_begin(?P<id>[0-9][1-9]*):\n'
|
|
|
|
r'(?P<body>.*?)'
|
|
|
|
r'^Lfunc_end(?P=id):\n'
|
|
|
|
r'^[ \t]*@[ \t]--[ \t]End[ \t]function',
|
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2019-05-22 07:06:34 +08:00
|
|
|
ASM_FUNCTION_WASM32_RE = re.compile(
|
|
|
|
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n'
|
|
|
|
r'(?P<body>.*?)\n'
|
2019-08-05 00:28:37 +08:00
|
|
|
r'^\s*(\.Lfunc_end[0-9]+:\n|end_function)',
|
2019-05-22 07:06:34 +08:00
|
|
|
flags=(re.M | re.S))
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
SCRUB_X86_SHUFFLES_RE = (
|
|
|
|
re.compile(
|
|
|
|
r'^(\s*\w+) [^#\n]+#+ ((?:[xyz]mm\d+|mem)( \{%k\d+\}( \{z\})?)? = .*)$',
|
|
|
|
flags=re.M))
|
2020-02-20 22:22:56 +08:00
|
|
|
|
|
|
|
SCRUB_X86_SHUFFLES_NO_MEM_RE = (
|
|
|
|
re.compile(
|
|
|
|
r'^(\s*\w+) [^#\n]+#+ ((?:[xyz]mm\d+|mem)( \{%k\d+\}( \{z\})?)? = (?!.*(?:mem)).*)$',
|
|
|
|
flags=re.M))
|
|
|
|
|
2018-04-03 17:57:05 +08:00
|
|
|
SCRUB_X86_SPILL_RELOAD_RE = (
|
|
|
|
re.compile(
|
|
|
|
r'-?\d+\(%([er])[sb]p\)(.*(?:Spill|Reload))$',
|
|
|
|
flags=re.M))
|
2018-01-30 08:40:05 +08:00
|
|
|
SCRUB_X86_SP_RE = re.compile(r'\d+\(%(esp|rsp)\)')
|
|
|
|
SCRUB_X86_RIP_RE = re.compile(r'[.\w]+\(%rip\)')
|
|
|
|
SCRUB_X86_LCP_RE = re.compile(r'\.LCPI[0-9]+_[0-9]+')
|
|
|
|
SCRUB_X86_RET_RE = re.compile(r'ret[l|q]')
|
|
|
|
|
|
|
|
def scrub_asm_x86(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
2020-02-20 22:22:56 +08:00
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
# Detect shuffle asm comments and hide the operands in favor of the comments.
|
2020-02-20 22:22:56 +08:00
|
|
|
if getattr(args, 'no_x86_scrub_mem_shuffle', True):
|
|
|
|
asm = SCRUB_X86_SHUFFLES_NO_MEM_RE.sub(r'\1 {{.*#+}} \2', asm)
|
|
|
|
else:
|
|
|
|
asm = SCRUB_X86_SHUFFLES_RE.sub(r'\1 {{.*#+}} \2', asm)
|
|
|
|
|
2018-04-03 17:57:05 +08:00
|
|
|
# Detect stack spills and reloads and hide their exact offset and whether
|
|
|
|
# they used the stack pointer or frame pointer.
|
2018-04-03 18:28:56 +08:00
|
|
|
asm = SCRUB_X86_SPILL_RELOAD_RE.sub(r'{{[-0-9]+}}(%\1{{[sb]}}p)\2', asm)
|
2018-01-30 08:40:05 +08:00
|
|
|
# Generically match the stack offset of a memory operand.
|
|
|
|
asm = SCRUB_X86_SP_RE.sub(r'{{[0-9]+}}(%\1)', asm)
|
2018-07-24 05:14:35 +08:00
|
|
|
if getattr(args, 'x86_scrub_rip', False):
|
|
|
|
# Generically match a RIP-relative memory operand.
|
|
|
|
asm = SCRUB_X86_RIP_RE.sub(r'{{.*}}(%rip)', asm)
|
2018-01-30 08:40:05 +08:00
|
|
|
# Generically match a LCP symbol.
|
|
|
|
asm = SCRUB_X86_LCP_RE.sub(r'{{\.LCPI.*}}', asm)
|
2018-06-01 21:37:01 +08:00
|
|
|
if getattr(args, 'extra_scrub', False):
|
2018-01-30 08:40:05 +08:00
|
|
|
# Avoid generating different checks for 32- and 64-bit because of 'retl' vs 'retq'.
|
|
|
|
asm = SCRUB_X86_RET_RE.sub(r'ret{{[l|q]}}', asm)
|
|
|
|
# Strip kill operands inserted into the asm.
|
|
|
|
asm = common.SCRUB_KILL_COMMENT_RE.sub('', asm)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
[Utils] update_llc_test_checks.py: support AMDGPU backend: AMDGCN, r600 triples
Summary:
Lack of that support has taken me by surprise.
I need to add (or at least look at) some tests for https://reviews.llvm.org/D47980#1127615,
and i don't really fancy doing that by hand.
The asm pattern is quite similar to that of x86:
https://godbolt.org/g/hfgeds
just with `#` replaced with `;`
Reviewers: spatel, RKSimon, MaskRay, tstellar, arsenm
Reviewed By: arsenm
Subscribers: arsenm, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, rampitec, bogner, mareko, llvm-commits
Tags: #amdgpu
Differential Revision: https://reviews.llvm.org/D48001
llvm-svn: 334396
2018-06-11 17:20:21 +08:00
|
|
|
def scrub_asm_amdgpu(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
def scrub_asm_arm_eabi(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip kill operands inserted into the asm.
|
|
|
|
asm = common.SCRUB_KILL_COMMENT_RE.sub('', asm)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2019-06-05 22:08:01 +08:00
|
|
|
def scrub_asm_hexagon(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2019-05-24 03:54:41 +08:00
|
|
|
def scrub_asm_powerpc(asm, args):
|
2018-01-30 08:40:05 +08:00
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
2020-04-10 23:03:16 +08:00
|
|
|
# Strip unimportant comments, but leave the token '#' in place.
|
2020-04-02 17:46:45 +08:00
|
|
|
asm = common.SCRUB_LOOP_COMMENT_RE.sub(r'#', asm)
|
2018-01-30 08:40:05 +08:00
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
2020-04-10 23:03:16 +08:00
|
|
|
# Strip the tailing token '#', except the line only has token '#'.
|
2020-04-10 14:09:01 +08:00
|
|
|
asm = common.SCRUB_TAILING_COMMENT_TOKEN_RE.sub(r'', asm)
|
2018-01-30 08:40:05 +08:00
|
|
|
return asm
|
|
|
|
|
|
|
|
def scrub_asm_mips(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2019-10-03 22:34:28 +08:00
|
|
|
def scrub_asm_msp430(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
def scrub_asm_riscv(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2019-05-30 04:03:00 +08:00
|
|
|
def scrub_asm_lanai(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2018-04-20 15:59:13 +08:00
|
|
|
def scrub_asm_sparc(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2018-01-30 08:40:05 +08:00
|
|
|
def scrub_asm_systemz(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
2019-05-22 07:06:34 +08:00
|
|
|
def scrub_asm_wasm32(asm, args):
|
|
|
|
# Scrub runs of whitespace out of the assembly, but leave the leading
|
|
|
|
# whitespace in place.
|
|
|
|
asm = common.SCRUB_WHITESPACE_RE.sub(r' ', asm)
|
|
|
|
# Expand the tabs used for indentation.
|
|
|
|
asm = string.expandtabs(asm, 2)
|
|
|
|
# Strip trailing whitespace.
|
|
|
|
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
|
|
|
|
return asm
|
|
|
|
|
UpdateTestChecks: fix AMDGPU handling
Summary:
Was looking into supporting `(srl (shl x, c1), c2)` with c1 != c2 in dagcombiner,
this test changes, but makes `update_llc_test_checks.py` unhappy.
**Many** AMDGPU tests specify `-march`, not `-mtriple`, which results in `update_llc_test_checks.py`
defaulting to x86 asm function detection heuristics, which don't work here.
I propose to fix this by adding an infrastructure to map from `-march` to `-mtriple`,
in the UpdateTestChecks tooling.
Reviewers: RKSimon, MaskRay, arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62099
llvm-svn: 361101
2019-05-18 21:00:03 +08:00
|
|
|
def get_triple_from_march(march):
|
|
|
|
triples = {
|
|
|
|
'amdgcn': 'amdgcn',
|
2019-05-31 23:05:06 +08:00
|
|
|
'r600': 'r600',
|
2019-05-24 02:08:00 +08:00
|
|
|
'mips': 'mips',
|
2019-05-22 21:04:34 +08:00
|
|
|
'sparc': 'sparc',
|
2019-06-05 22:08:01 +08:00
|
|
|
'hexagon': 'hexagon',
|
UpdateTestChecks: fix AMDGPU handling
Summary:
Was looking into supporting `(srl (shl x, c1), c2)` with c1 != c2 in dagcombiner,
this test changes, but makes `update_llc_test_checks.py` unhappy.
**Many** AMDGPU tests specify `-march`, not `-mtriple`, which results in `update_llc_test_checks.py`
defaulting to x86 asm function detection heuristics, which don't work here.
I propose to fix this by adding an infrastructure to map from `-march` to `-mtriple`,
in the UpdateTestChecks tooling.
Reviewers: RKSimon, MaskRay, arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62099
llvm-svn: 361101
2019-05-18 21:00:03 +08:00
|
|
|
}
|
|
|
|
for prefix, triple in triples.items():
|
|
|
|
if march.startswith(prefix):
|
|
|
|
return triple
|
|
|
|
print("Cannot find a triple. Assume 'x86'", file=sys.stderr)
|
|
|
|
return 'x86'
|
2018-01-30 08:40:05 +08:00
|
|
|
|
|
|
|
def build_function_body_dictionary_for_triple(args, raw_tool_output, triple, prefixes, func_dict):
|
|
|
|
target_handlers = {
|
|
|
|
'i686': (scrub_asm_x86, ASM_FUNCTION_X86_RE),
|
|
|
|
'x86': (scrub_asm_x86, ASM_FUNCTION_X86_RE),
|
|
|
|
'i386': (scrub_asm_x86, ASM_FUNCTION_X86_RE),
|
|
|
|
'aarch64': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_RE),
|
[NFC] Improve triple match of scripts that update tests
Summary:
The prior behavior of the triple matcher would stop
in the first matched triple. It was not possible to
create specific matches for sub-sets of a triple
(e.g aarch64-apple-darwin would never be used after
aarch64 was matched).
This patch:
1) Allows that specialized triples take priority,
considering that the string lenght of the triple
indentifies how specialized a triple is. If two
triples of same lenght match, the one matched first
prevails, preserving the old behavior.
2) Remove 20 duplicated triples of arm, thumb,
aarch64 options with same arguments, matching
the common prefix (aarch64, arm, thumb) of them.
3) Creates three new function matching regexes and
five triple options for arm64-apple-ios,
(arm|thumb)-apple-ios and thumb(v5)?-macho
Reviewers: lebedev.ri, RKSimon, MaskRay, gbedwell
Reviewed By: MaskRay
Subscribers: javed.absar, kristof.beyls, llvm-commits, carwil
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63145
llvm-svn: 363656
2019-06-18 18:04:36 +08:00
|
|
|
'aarch64-apple-darwin': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_DARWIN_RE),
|
2019-06-05 22:08:01 +08:00
|
|
|
'hexagon': (scrub_asm_hexagon, ASM_FUNCTION_HEXAGON_RE),
|
[Utils] update_llc_test_checks.py: support AMDGPU backend: AMDGCN, r600 triples
Summary:
Lack of that support has taken me by surprise.
I need to add (or at least look at) some tests for https://reviews.llvm.org/D47980#1127615,
and i don't really fancy doing that by hand.
The asm pattern is quite similar to that of x86:
https://godbolt.org/g/hfgeds
just with `#` replaced with `;`
Reviewers: spatel, RKSimon, MaskRay, tstellar, arsenm
Reviewed By: arsenm
Subscribers: arsenm, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, rampitec, bogner, mareko, llvm-commits
Tags: #amdgpu
Differential Revision: https://reviews.llvm.org/D48001
llvm-svn: 334396
2018-06-11 17:20:21 +08:00
|
|
|
'r600': (scrub_asm_amdgpu, ASM_FUNCTION_AMDGPU_RE),
|
|
|
|
'amdgcn': (scrub_asm_amdgpu, ASM_FUNCTION_AMDGPU_RE),
|
[NFC] Improve triple match of scripts that update tests
Summary:
The prior behavior of the triple matcher would stop
in the first matched triple. It was not possible to
create specific matches for sub-sets of a triple
(e.g aarch64-apple-darwin would never be used after
aarch64 was matched).
This patch:
1) Allows that specialized triples take priority,
considering that the string lenght of the triple
indentifies how specialized a triple is. If two
triples of same lenght match, the one matched first
prevails, preserving the old behavior.
2) Remove 20 duplicated triples of arm, thumb,
aarch64 options with same arguments, matching
the common prefix (aarch64, arm, thumb) of them.
3) Creates three new function matching regexes and
five triple options for arm64-apple-ios,
(arm|thumb)-apple-ios and thumb(v5)?-macho
Reviewers: lebedev.ri, RKSimon, MaskRay, gbedwell
Reviewed By: MaskRay
Subscribers: javed.absar, kristof.beyls, llvm-commits, carwil
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63145
llvm-svn: 363656
2019-06-18 18:04:36 +08:00
|
|
|
'arm': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_RE),
|
|
|
|
'arm64': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_RE),
|
|
|
|
'arm64-apple-ios': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_DARWIN_RE),
|
|
|
|
'armv7-apple-ios' : (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_IOS_RE),
|
2019-06-29 02:07:19 +08:00
|
|
|
'armv7-apple-darwin': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_DARWIN_RE),
|
[NFC] Improve triple match of scripts that update tests
Summary:
The prior behavior of the triple matcher would stop
in the first matched triple. It was not possible to
create specific matches for sub-sets of a triple
(e.g aarch64-apple-darwin would never be used after
aarch64 was matched).
This patch:
1) Allows that specialized triples take priority,
considering that the string lenght of the triple
indentifies how specialized a triple is. If two
triples of same lenght match, the one matched first
prevails, preserving the old behavior.
2) Remove 20 duplicated triples of arm, thumb,
aarch64 options with same arguments, matching
the common prefix (aarch64, arm, thumb) of them.
3) Creates three new function matching regexes and
five triple options for arm64-apple-ios,
(arm|thumb)-apple-ios and thumb(v5)?-macho
Reviewers: lebedev.ri, RKSimon, MaskRay, gbedwell
Reviewed By: MaskRay
Subscribers: javed.absar, kristof.beyls, llvm-commits, carwil
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63145
llvm-svn: 363656
2019-06-18 18:04:36 +08:00
|
|
|
'thumb': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_RE),
|
|
|
|
'thumb-macho': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_MACHO_RE),
|
|
|
|
'thumbv5-macho': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_MACHO_RE),
|
|
|
|
'thumbv7-apple-ios' : (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_IOS_RE),
|
2018-01-30 08:40:05 +08:00
|
|
|
'mips': (scrub_asm_mips, ASM_FUNCTION_MIPS_RE),
|
2019-10-03 22:34:28 +08:00
|
|
|
'msp430': (scrub_asm_msp430, ASM_FUNCTION_MSP430_RE),
|
2019-05-24 03:54:41 +08:00
|
|
|
'ppc32': (scrub_asm_powerpc, ASM_FUNCTION_PPC_RE),
|
2019-06-25 02:00:34 +08:00
|
|
|
'powerpc': (scrub_asm_powerpc, ASM_FUNCTION_PPC_RE),
|
2018-01-30 08:40:05 +08:00
|
|
|
'riscv32': (scrub_asm_riscv, ASM_FUNCTION_RISCV_RE),
|
|
|
|
'riscv64': (scrub_asm_riscv, ASM_FUNCTION_RISCV_RE),
|
2019-05-30 04:03:00 +08:00
|
|
|
'lanai': (scrub_asm_lanai, ASM_FUNCTION_LANAI_RE),
|
2018-04-20 15:59:13 +08:00
|
|
|
'sparc': (scrub_asm_sparc, ASM_FUNCTION_SPARC_RE),
|
2018-01-30 08:40:05 +08:00
|
|
|
's390x': (scrub_asm_systemz, ASM_FUNCTION_SYSTEMZ_RE),
|
2019-05-22 07:06:34 +08:00
|
|
|
'wasm32': (scrub_asm_wasm32, ASM_FUNCTION_WASM32_RE),
|
2018-01-30 08:40:05 +08:00
|
|
|
}
|
[NFC] Improve triple match of scripts that update tests
Summary:
The prior behavior of the triple matcher would stop
in the first matched triple. It was not possible to
create specific matches for sub-sets of a triple
(e.g aarch64-apple-darwin would never be used after
aarch64 was matched).
This patch:
1) Allows that specialized triples take priority,
considering that the string lenght of the triple
indentifies how specialized a triple is. If two
triples of same lenght match, the one matched first
prevails, preserving the old behavior.
2) Remove 20 duplicated triples of arm, thumb,
aarch64 options with same arguments, matching
the common prefix (aarch64, arm, thumb) of them.
3) Creates three new function matching regexes and
five triple options for arm64-apple-ios,
(arm|thumb)-apple-ios and thumb(v5)?-macho
Reviewers: lebedev.ri, RKSimon, MaskRay, gbedwell
Reviewed By: MaskRay
Subscribers: javed.absar, kristof.beyls, llvm-commits, carwil
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63145
llvm-svn: 363656
2019-06-18 18:04:36 +08:00
|
|
|
handler = None
|
|
|
|
best_prefix = ''
|
2018-01-30 08:40:05 +08:00
|
|
|
for prefix, s in target_handlers.items():
|
[NFC] Improve triple match of scripts that update tests
Summary:
The prior behavior of the triple matcher would stop
in the first matched triple. It was not possible to
create specific matches for sub-sets of a triple
(e.g aarch64-apple-darwin would never be used after
aarch64 was matched).
This patch:
1) Allows that specialized triples take priority,
considering that the string lenght of the triple
indentifies how specialized a triple is. If two
triples of same lenght match, the one matched first
prevails, preserving the old behavior.
2) Remove 20 duplicated triples of arm, thumb,
aarch64 options with same arguments, matching
the common prefix (aarch64, arm, thumb) of them.
3) Creates three new function matching regexes and
five triple options for arm64-apple-ios,
(arm|thumb)-apple-ios and thumb(v5)?-macho
Reviewers: lebedev.ri, RKSimon, MaskRay, gbedwell
Reviewed By: MaskRay
Subscribers: javed.absar, kristof.beyls, llvm-commits, carwil
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63145
llvm-svn: 363656
2019-06-18 18:04:36 +08:00
|
|
|
if triple.startswith(prefix) and len(prefix) > len(best_prefix):
|
|
|
|
handler = s
|
|
|
|
best_prefix = prefix
|
|
|
|
|
|
|
|
if handler is None:
|
2018-01-30 08:40:05 +08:00
|
|
|
raise KeyError('Triple %r is not supported' % (triple))
|
|
|
|
|
[NFC] Improve triple match of scripts that update tests
Summary:
The prior behavior of the triple matcher would stop
in the first matched triple. It was not possible to
create specific matches for sub-sets of a triple
(e.g aarch64-apple-darwin would never be used after
aarch64 was matched).
This patch:
1) Allows that specialized triples take priority,
considering that the string lenght of the triple
indentifies how specialized a triple is. If two
triples of same lenght match, the one matched first
prevails, preserving the old behavior.
2) Remove 20 duplicated triples of arm, thumb,
aarch64 options with same arguments, matching
the common prefix (aarch64, arm, thumb) of them.
3) Creates three new function matching regexes and
five triple options for arm64-apple-ios,
(arm|thumb)-apple-ios and thumb(v5)?-macho
Reviewers: lebedev.ri, RKSimon, MaskRay, gbedwell
Reviewed By: MaskRay
Subscribers: javed.absar, kristof.beyls, llvm-commits, carwil
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63145
llvm-svn: 363656
2019-06-18 18:04:36 +08:00
|
|
|
scrubber, function_re = handler
|
2018-01-30 08:40:05 +08:00
|
|
|
common.build_function_body_dictionary(
|
|
|
|
function_re, scrubber, [args], raw_tool_output, prefixes,
|
2019-11-01 02:37:34 +08:00
|
|
|
func_dict, args.verbose, False)
|
2018-02-10 13:01:33 +08:00
|
|
|
|
|
|
|
##### Generator of assembly CHECK lines
|
|
|
|
|
2018-04-05 17:50:58 +08:00
|
|
|
def add_asm_checks(output_lines, comment_marker, prefix_list, func_dict, func_name):
|
|
|
|
# Label format is based on ASM string.
|
2019-11-01 02:37:34 +08:00
|
|
|
check_label_format = '{} %s-LABEL: %s%s:'.format(comment_marker)
|
2018-04-06 20:36:27 +08:00
|
|
|
common.add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, True, False)
|