#!/usr/bin/env 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.
# 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.7 and 3.2+
= 4
= 2 **
=
=
=
= 0
# Spread out all the instructions to not worry about cross-bundle
# interference.
# Now generate an appropriate CHECK line
= * 2 *
= + # had it not been padded...
# No padding needed
+ < :
# Pad to end at nearest bundle boundary
= +
# offset + instlen > BUNDLE_SIZE
# Pad to end at next bundle boundary, splitting the nop sequence
# at the nearest bundle boundary
= +
= +
= None
# Padding needed
= & ~
# No padding needed
+= 1
=
=