Add a --scrub-reg option to convert target-specific register names to regular
expressions or FileCheck variables. --scrub-reg=names will replace register
names with FileCheck variables and track register dependencies via the
variables. --scrub-reg=deps will replace register names with a regular
expression that doesn't capture into a FileCheck variable. Dependency scrubbing
makes a test more robust in the face of incidental register name changes at the
cost of losing the ability to catch changes in the register dependency graph.
This patch only implements the regular expressions to match register names for
X86 and Lanai. Other targets will not query the option, though adding support
for it is simply a matter of checking the option and passing a regular
expression that matches register names on the target.
X86 was chosen to demonstrate how to scrub in the face of a particularly complex
set of register super-/sub-register relationships along with non-uniform naming
even within a register class. It uses a fully custom match and replace
algorithm. The Lanai implementation demonstrates the other end of the spectrum,
where super-/sub-registers all have the same names anyway so effectively they do
not matter for matching purposes. The Lanai implmentation exercises generic
routine that other targets may also use to implement scrubbing.
The x86 regular expression intentionally does not substitute for [re]?sp and
[re]?ip because it's likely that tests will want to match based on addressing
mode. Lanai does not match anything other than r[0-9]+ for similar reasons.
Typo: when -> that?