[TableGen] Correct Namespace lookup with AltNames in AsmWriterEmitter
authorHal Finkel <hfinkel@anl.gov>
Fri, 11 Dec 2015 17:31:27 +0000 (17:31 +0000)
committerHal Finkel <hfinkel@anl.gov>
Fri, 11 Dec 2015 17:31:27 +0000 (17:31 +0000)
commitf7649afaba06bfd08fdd087067fc7aae43aadb9a
tree52a1effecf2e0b8acd803a31542fdf8504de3f34
parent89fa0a8cb60fa485309f9f9fda6409f834d9f0f6
[TableGen] Correct Namespace lookup with AltNames in AsmWriterEmitter

AsmWriterEmitter will generate a getRegisterName function with an alternate
register name index as its second argument if the target makes use of them. The
enum of these values is generated in RegisterInfoEmitter. The getRegisterName
generator would assume the namespace could always be found by reading index 1
of the list of AltNameIndices, but this will fail if this list is sorted such
that the NoRegAltName is at index 1. Because this list is sorted by record name
(in CodeGenTarget::ReadRegAltNameIndices), you only run in to problems if your
MyTargetRegisterInfo.td defines a single RegAltNameIndex that sorts lexically
before NoRegAltName.

For example, if a target has something like

  def AnAltNameIndex : RegAltNameIndex

and defines RegAltNameIndices for some registers then, prior to this change,
AsmWriterEmitter would generate references to

  ::AnAltNameIndex and ::NoRegAltName

Patch by Alex Bradbury!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255344 91177308-0d34-0410-b5e6-96231b3b80d8
utils/TableGen/AsmWriterEmitter.cpp