forked from OSchip/llvm-project
Add some additional tests for the .bundle_lock align_to_end feature that didn't
make into the last commit. Also, update the test-generation script to generate an exhaustive test for align_to_end as well, and include the generated test. llvm-svn: 171811
This commit is contained in:
parent
070db184fb
commit
3e76eb2dbc
|
@ -0,0 +1,41 @@
|
||||||
|
# RUN: llvm-mc -filetype=obj -triple armv7-linux-gnueabi %s -o - \
|
||||||
|
# RUN: | llvm-objdump -no-show-raw-insn -triple armv7 -disassemble - | FileCheck %s
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.text
|
||||||
|
.bundle_align_mode 4
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
and r1, r1, r2
|
||||||
|
and r1, r1, r2
|
||||||
|
.bundle_lock align_to_end
|
||||||
|
bx r9
|
||||||
|
.bundle_unlock
|
||||||
|
# No padding required here because bx just happens to be in the
|
||||||
|
# right offset.
|
||||||
|
# CHECK: 8: and
|
||||||
|
# CHECK-NEXT: c: bx
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
and r1, r1, r2
|
||||||
|
.bundle_lock align_to_end
|
||||||
|
bx r9
|
||||||
|
.bundle_unlock
|
||||||
|
# A 4-byte padding is needed here
|
||||||
|
# CHECK: 18: nop
|
||||||
|
# CHECK-NEXT: 1c: bx
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
and r1, r1, r2
|
||||||
|
.bundle_lock align_to_end
|
||||||
|
bx r9
|
||||||
|
bx r9
|
||||||
|
bx r9
|
||||||
|
.bundle_unlock
|
||||||
|
# A 12-byte padding is needed here to push the group to the end of the next
|
||||||
|
# bundle
|
||||||
|
# CHECK: 28: nop
|
||||||
|
# CHECK-NEXT: 2c: nop
|
||||||
|
# CHECK-NEXT: 30: nop
|
||||||
|
# CHECK-NEXT: 34: bx
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,11 @@
|
||||||
|
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
# Missing .bundle_align_mode argument
|
||||||
|
# CHECK: error: invalid option
|
||||||
|
|
||||||
|
.bundle_align_mode 4
|
||||||
|
.bundle_lock 5
|
||||||
|
imull $17, %ebx, %ebp
|
||||||
|
.bundle_unlock
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
|
||||||
|
# RUN: | llvm-objdump -disassemble -no-show-raw-insn - | FileCheck %s
|
||||||
|
|
||||||
|
# Test some variations of padding to the end of a bundle.
|
||||||
|
|
||||||
|
.text
|
||||||
|
foo:
|
||||||
|
.bundle_align_mode 4
|
||||||
|
|
||||||
|
# Each of these callq instructions is 5 bytes long
|
||||||
|
callq bar
|
||||||
|
callq bar
|
||||||
|
.bundle_lock align_to_end
|
||||||
|
callq bar
|
||||||
|
.bundle_unlock
|
||||||
|
# To align this group to a bundle end, we need a 1-byte NOP.
|
||||||
|
# CHECK: a: nop
|
||||||
|
# CHECK-NEXT: b: callq
|
||||||
|
|
||||||
|
callq bar
|
||||||
|
callq bar
|
||||||
|
.bundle_lock align_to_end
|
||||||
|
callq bar
|
||||||
|
callq bar
|
||||||
|
.bundle_unlock
|
||||||
|
# Here we have to pad until the end of the *next* boundary because
|
||||||
|
# otherwise the group crosses a boundary.
|
||||||
|
# CHECK: 1a: nop
|
||||||
|
# CHECK-NEXT: 26: callq
|
||||||
|
# CHECK-NEXT: 2b: callq
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,13 @@
|
||||||
# For every possible offset in an aligned bundle, a bundle-locked group of every
|
# For every possible offset in an aligned bundle, a bundle-locked group of every
|
||||||
# size in the inclusive range [1, bundle_size] is inserted. An appropriate CHECK
|
# size in the inclusive range [1, bundle_size] is inserted. An appropriate CHECK
|
||||||
# is added to verify that NOP padding occurred (or did not occur) as expected.
|
# is added to verify that NOP padding occurred (or did not occur) as expected.
|
||||||
|
# Run with --align-to-end to generate a similar test with align_to_end for each
|
||||||
|
# .bundle_lock directive.
|
||||||
|
|
||||||
# This script runs with Python 2.6+ (including 3.x)
|
# This script runs with Python 2.7 and 3.2+
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
import argparse
|
||||||
|
|
||||||
BUNDLE_SIZE_POW2 = 4
|
BUNDLE_SIZE_POW2 = 4
|
||||||
BUNDLE_SIZE = 2 ** BUNDLE_SIZE_POW2
|
BUNDLE_SIZE = 2 ** BUNDLE_SIZE_POW2
|
||||||
|
@ -28,14 +31,14 @@ PREAMBLE = '''
|
||||||
ALIGNTO = ' .align {0}, 0x90'
|
ALIGNTO = ' .align {0}, 0x90'
|
||||||
NOPFILL = ' .fill {0}, 1, 0x90'
|
NOPFILL = ' .fill {0}, 1, 0x90'
|
||||||
|
|
||||||
def print_bundle_locked_sequence(len):
|
def print_bundle_locked_sequence(len, align_to_end=False):
|
||||||
print(' .bundle_lock')
|
print(' .bundle_lock{0}'.format(' align_to_end' if align_to_end else ''))
|
||||||
print(' .rept {0}'.format(len))
|
print(' .rept {0}'.format(len))
|
||||||
print(' inc %eax')
|
print(' inc %eax')
|
||||||
print(' .endr')
|
print(' .endr')
|
||||||
print(' .bundle_unlock')
|
print(' .bundle_unlock')
|
||||||
|
|
||||||
def generate():
|
def generate(align_to_end=False):
|
||||||
print(PREAMBLE)
|
print(PREAMBLE)
|
||||||
|
|
||||||
ntest = 0
|
ntest = 0
|
||||||
|
@ -47,24 +50,49 @@ def generate():
|
||||||
print('INSTRLEN_{0}_OFFSET_{1}:'.format(instlen, offset))
|
print('INSTRLEN_{0}_OFFSET_{1}:'.format(instlen, offset))
|
||||||
if offset > 0:
|
if offset > 0:
|
||||||
print(NOPFILL.format(offset))
|
print(NOPFILL.format(offset))
|
||||||
print_bundle_locked_sequence(instlen)
|
print_bundle_locked_sequence(instlen, align_to_end)
|
||||||
|
|
||||||
# Now generate an appropriate CHECK line
|
# Now generate an appropriate CHECK line
|
||||||
base_offset = ntest * 2 * BUNDLE_SIZE
|
base_offset = ntest * 2 * BUNDLE_SIZE
|
||||||
inst_orig_offset = base_offset + offset # had it not been padded...
|
inst_orig_offset = base_offset + offset # had it not been padded...
|
||||||
|
|
||||||
|
def print_check(adjusted_offset=None):
|
||||||
|
if adjusted_offset is not None:
|
||||||
|
print('# CHECK: {0:x}: nop'.format(inst_orig_offset))
|
||||||
|
print('# CHECK: {0:x}: incl'.format(adjusted_offset))
|
||||||
|
else:
|
||||||
|
print('# CHECK: {0:x}: incl'.format(inst_orig_offset))
|
||||||
|
|
||||||
if offset + instlen > BUNDLE_SIZE:
|
if align_to_end:
|
||||||
# Padding needed
|
if offset + instlen == BUNDLE_SIZE:
|
||||||
print('# CHECK: {0:x}: nop'.format(inst_orig_offset))
|
# No padding needed
|
||||||
aligned_offset = (inst_orig_offset + instlen) & ~(BUNDLE_SIZE - 1)
|
print_check()
|
||||||
print('# CHECK: {0:x}: incl'.format(aligned_offset))
|
elif offset + instlen < BUNDLE_SIZE:
|
||||||
|
# Pad to end at nearest bundle boundary
|
||||||
|
offset_to_end = base_offset + (BUNDLE_SIZE - instlen)
|
||||||
|
print_check(offset_to_end)
|
||||||
|
else: # offset + instlen > BUNDLE_SIZE
|
||||||
|
# Pad to end at next bundle boundary
|
||||||
|
offset_to_end = base_offset + (BUNDLE_SIZE * 2 - instlen)
|
||||||
|
print_check(offset_to_end)
|
||||||
else:
|
else:
|
||||||
# No padding needed
|
if offset + instlen > BUNDLE_SIZE:
|
||||||
print('# CHECK: {0:x}: incl'.format(inst_orig_offset))
|
# Padding needed
|
||||||
|
aligned_offset = (inst_orig_offset + instlen) & ~(BUNDLE_SIZE - 1)
|
||||||
|
print_check(aligned_offset)
|
||||||
|
else:
|
||||||
|
# No padding needed
|
||||||
|
print_check()
|
||||||
|
|
||||||
print()
|
print()
|
||||||
ntest += 1
|
ntest += 1
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
generate()
|
argparser = argparse.ArgumentParser()
|
||||||
|
argparser.add_argument('--align-to-end',
|
||||||
|
action='store_true',
|
||||||
|
help='generate .bundle_lock with align_to_end option')
|
||||||
|
args = argparser.parse_args()
|
||||||
|
generate(align_to_end=args.align_to_end)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue