[PATCH] Warn on deprecated IT blocks in v8 AArch32 assembly

Artyom Skrobov Artyom.Skrobov at arm.com
Fri Sep 27 01:52:33 PDT 2013


Hello,

To continue from
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130819/184864.
html and building upon Joey's new support for deprecated instructions in MC
layer
(http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130902/186768
.html), we want to add deprecation warnings for the IT blocks in ARMv8 Thumb
mode, using the same set of criteria as in the aforementioned CodeGen patch.

Unfortunately, since CodeGen and MC don't share any target-specific C code,
there's no good place to put isV8EligibleForIT() to make it accessible from
both sides.  Our approach is to add a new header
lib/Target/ARM/ARMFeatures.h for the shared CodeGen/MC definitions.  It
would be even neater to have this all in TableGen, with similar "custom
deprecation predicates" to what Joey did.  However, that approach would
require setting up new infrastructure for whitelisting the instructions, as
opposed to Joey's blacklisting;  that's considerably more work (requiring
changes to InstrInfoEmitter.cpp and throughout LLVM) while there won't
likely be any future applications for such infrastructure, besides our case
with IT blocks.

The other thing we're cautious about is the testing.  The patch includes a
98K lines test case, which is why I'm attaching the patch zipped.  That's an
exhaustive test of all valid 16-bit Thumb encodings, taking ~1 min on my
development machine.  The test can be split into a few chunks to run in
parallel, but even that would add considerably to the testing time.  Clang
testing setup supports long_tests feature to enable/disable long-running
tests
(http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130617/082137.
html);  do we need the same support added into LLVM testing setup?  Do the
existing build bots actually enable long_tests?

The long test case was generated using this simple Python script, using the
bit-masks derived from the "ARMv8 Instruction Set" reference
(http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.genc010197a/ind
ex.html)

#!/usr/bin/env python

import subprocess

print "@ RUN: llvm-mc -triple thumbv8 -show-encoding < %s 2>&1 | FileCheck
%s"

for encoding in range(0, 1<<16 - 1):
  deprecated = ((encoding & 0xc000 == 0xc000) or
                (encoding & 0xb000 == 0xb000) or
                (encoding & 0xb800 == 0xa000) or
                (encoding & 0xf800 == 0x4800) or
                (encoding & 0xf478 == 0x4478) or
                (encoding & 0xfc87 == 0x4487))

  mc = subprocess.Popen(["llvm-mc","-triple","thumbv8","-disassemble"],
                        stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
  (out,err) = mc.communicate("0x%02x 0x%02x 0x00 0x00" % (encoding & 255,
encoding >> 8))
  if (mc.returncode == 0) and ('invalid instruction encoding' not in err): #
disassembled correctly
    if deprecated:
      print "@ CHECK: [[@LINE+2]]:1: warning: deprecated instruction in IT
block"
    else:
      print "@ CHECK-NOT: [[@LINE+2]]:1: warning"

    instr = out.splitlines()[1].lstrip().replace("s\t","ge
",1).replace("\t","ge ",1)
    print "it ge\n" + instr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v8_IT_asm.zip
Type: application/x-zip-compressed
Size: 86962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130927/22f57c9a/attachment.bin>


More information about the llvm-commits mailing list