mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
Add a largish auto-generated test for the aligned bundling feature, along with
the script generating it. The test should never be modified manually. If anyone needs to change it, please change the script and re-run it. The script is placed into utils/testgen - I couldn't think of a better place, and after some discussion on IRC this looked like a logical location. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170720 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
16996c4940
commit
b17201f1b8
2674
test/MC/X86/AlignedBundling/autogen-inst-offset-padding.s
Normal file
2674
test/MC/X86/AlignedBundling/autogen-inst-offset-padding.s
Normal file
File diff suppressed because it is too large
Load Diff
70
utils/testgen/mc-bundling-x86-gen.py
Normal file
70
utils/testgen/mc-bundling-x86-gen.py
Normal file
@ -0,0 +1,70 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Auto-generates an exhaustive and repetitive test for correct bundle-locked
|
||||
# alignment on x86.
|
||||
# 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
|
||||
# is added to verify that NOP padding occurred (or did not occur) as expected.
|
||||
|
||||
# This script runs with Python 2.6+ (including 3.x)
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
BUNDLE_SIZE_POW2 = 4
|
||||
BUNDLE_SIZE = 2 ** BUNDLE_SIZE_POW2
|
||||
|
||||
PREAMBLE = '''
|
||||
# RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -o - \\
|
||||
# RUN: | llvm-objdump -triple i386 -disassemble -no-show-raw-insn - | FileCheck %s
|
||||
|
||||
# !!! This test is auto-generated from utils/testgen/mc-bundling-x86-gen.py !!!
|
||||
# It tests that bundle-aligned grouping works correctly in MC. Read the
|
||||
# source of the script for more details.
|
||||
|
||||
.text
|
||||
.bundle_align_mode {0}
|
||||
'''.format(BUNDLE_SIZE_POW2).lstrip()
|
||||
|
||||
ALIGNTO = ' .align {0}, 0x90'
|
||||
NOPFILL = ' .fill {0}, 1, 0x90'
|
||||
|
||||
def print_bundle_locked_sequence(len):
|
||||
print(' .bundle_lock')
|
||||
print(' .rept {0}'.format(len))
|
||||
print(' inc %eax')
|
||||
print(' .endr')
|
||||
print(' .bundle_unlock')
|
||||
|
||||
def generate():
|
||||
print(PREAMBLE)
|
||||
|
||||
ntest = 0
|
||||
for instlen in range(1, BUNDLE_SIZE + 1):
|
||||
for offset in range(0, BUNDLE_SIZE):
|
||||
# Spread out all the instructions to not worry about cross-bundle
|
||||
# interference.
|
||||
print(ALIGNTO.format(2 * BUNDLE_SIZE))
|
||||
print('INSTRLEN_{0}_OFFSET_{1}:'.format(instlen, offset))
|
||||
if offset > 0:
|
||||
print(NOPFILL.format(offset))
|
||||
print_bundle_locked_sequence(instlen)
|
||||
|
||||
# Now generate an appropriate CHECK line
|
||||
base_offset = ntest * 2 * BUNDLE_SIZE
|
||||
inst_orig_offset = base_offset + offset # had it not been padded...
|
||||
|
||||
if offset + instlen > BUNDLE_SIZE:
|
||||
# Padding needed
|
||||
print('# CHECK: {0:x}: nop'.format(inst_orig_offset))
|
||||
aligned_offset = (inst_orig_offset + instlen) & ~(BUNDLE_SIZE - 1)
|
||||
print('# CHECK: {0:x}: incl'.format(aligned_offset))
|
||||
else:
|
||||
# No padding needed
|
||||
print('# CHECK: {0:x}: incl'.format(inst_orig_offset))
|
||||
|
||||
print()
|
||||
ntest += 1
|
||||
|
||||
if __name__ == '__main__':
|
||||
generate()
|
||||
|
Loading…
Reference in New Issue
Block a user