mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 00:32:23 +00:00
44b486ed78
Before this change, the SystemZ backend would use BRCL for all branches and only consider shortening them to BRC when generating an object file. E.g. a branch on equal would use the JGE alias of BRCL in assembly output, but might be shortened to the JE alias of BRC in ELF output. This was a useful first step, but it had two problems: (1) The z assembler isn't traditionally supposed to perform branch shortening or branch relaxation. We followed this rule by not relaxing branches in assembler input, but that meant that generating assembly code and then assembling it would not produce the same result as going directly to object code; the former would give long branches everywhere, whereas the latter would use short branches where possible. (2) Other useful branches, like COMPARE AND BRANCH, do not have long forms. We would need to do something else before supporting them. (Although COMPARE AND BRANCH does not change the condition codes, the plan is to model COMPARE AND BRANCH as a CC-clobbering instruction during codegen, so that we can safely lower it to a separate compare and long branch where necessary. This is not a valid transformation for the assembler proper to make.) This patch therefore moves branch relaxation to a pre-emit pass. For now, calls are still shortened from BRASL to BRAS by the assembler, although this too is not really the traditional behaviour. The first test takes about 1.5s to run, and there are likely to be more tests in this vein once further branch types are added. The feeling on IRC was that 1.5s is a bit much for a single test, so I've restricted it to SystemZ hosts for now. The patch exposes (and fixes) some typos in the main CodeGen/SystemZ tests. A later patch will remove the {{g}}s from that directory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182274 91177308-0d34-0410-b5e6-96231b3b80d8
83 lines
2.1 KiB
Python
83 lines
2.1 KiB
Python
# Test normal conditional branches in cases where block alignments cause
|
|
# some branches to be out of range.
|
|
# RUN: python %s | llc -mtriple=s390x-linux-gnu -align-all-blocks=8 | FileCheck %s
|
|
|
|
# Construct:
|
|
#
|
|
# b0:
|
|
# conditional branch to end
|
|
# ...
|
|
# b<N>:
|
|
# conditional branch to end
|
|
# b<N+1>:
|
|
# conditional branch to b0
|
|
# ...
|
|
# b<2*N>:
|
|
# conditional branch to b0
|
|
# end:
|
|
#
|
|
# with N == 256 + 4. The -align-all-blocks=8 option ensures that all blocks
|
|
# are 256 bytes in size. The first 4 blocks and the last 4 blocks are then
|
|
# out of range.
|
|
#
|
|
# CHECK: c %r4, 0(%r3)
|
|
# CHECK: jge [[LABEL:\.L[^ ]*]]
|
|
# CHECK: c %r4, 4(%r3)
|
|
# CHECK: jge [[LABEL]]
|
|
# CHECK: c %r4, 8(%r3)
|
|
# CHECK: jge [[LABEL]]
|
|
# CHECK: c %r4, 12(%r3)
|
|
# CHECK: jge [[LABEL]]
|
|
# CHECK: c %r4, 16(%r3)
|
|
# CHECK: je [[LABEL]]
|
|
# CHECK: c %r4, 20(%r3)
|
|
# CHECK: je [[LABEL]]
|
|
# CHECK: c %r4, 24(%r3)
|
|
# CHECK: je [[LABEL]]
|
|
# CHECK: c %r4, 28(%r3)
|
|
# CHECK: je [[LABEL]]
|
|
# ...lots of other blocks...
|
|
# CHECK: c %r4, 1004(%r3)
|
|
# CHECK: je [[LABEL:\.L[^ ]*]]
|
|
# CHECK: c %r4, 1008(%r3)
|
|
# CHECK: je [[LABEL]]
|
|
# CHECK: c %r4, 1012(%r3)
|
|
# CHECK: je [[LABEL]]
|
|
# CHECK: c %r4, 1016(%r3)
|
|
# CHECK: je [[LABEL]]
|
|
# CHECK: c %r4, 1020(%r3)
|
|
# CHECK: je [[LABEL]]
|
|
# CHECK: c %r4, 1024(%r3)
|
|
# CHECK: jge [[LABEL]]
|
|
# CHECK: c %r4, 1028(%r3)
|
|
# CHECK: jge [[LABEL]]
|
|
# CHECK: c %r4, 1032(%r3)
|
|
# CHECK: jge [[LABEL]]
|
|
# CHECK: c %r4, 1036(%r3)
|
|
# CHECK: jge [[LABEL]]
|
|
|
|
blocks = 256 + 4
|
|
|
|
print 'define void @f1(i8 *%base, i32 *%stop, i32 %limit) {'
|
|
print 'entry:'
|
|
print ' br label %b0'
|
|
print ''
|
|
|
|
a, b = 1, 1
|
|
for i in xrange(blocks):
|
|
a, b = b, a + b
|
|
value = a % 256
|
|
next = 'b%d' % (i + 1) if i + 1 < blocks else 'end'
|
|
other = 'end' if 2 * i < blocks else 'b0'
|
|
print 'b%d:' % i
|
|
print ' store volatile i8 %d, i8 *%%base' % value
|
|
print ' %%astop%d = getelementptr i32 *%%stop, i64 %d' % (i, i)
|
|
print ' %%acur%d = load volatile i32 *%%astop%d' % (i, i)
|
|
print ' %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i)
|
|
print ' br i1 %%atest%d, label %%%s, label %%%s' % (i, other, next)
|
|
|
|
print ''
|
|
print '%s:' % next
|
|
print ' ret void'
|
|
print '}'
|