This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Fix bug in printing namespace for register altname indices in AsmWriterEmitter
ClosedPublic

Authored by asb on Nov 27 2015, 7:00 AM.

Details

Summary

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.

i.e. if a target has something like def AnAltNameIndex : RegAltNameIndex and defines RegAltNameIndices for some registers then without this patch, AsmWriterEmitter will generate references to ::AnAltNameIndex and ::NoRegAltName.

Adding Jakob Oleson (TableGen code owner) and Jim Grosbach (original author of the RegAltName code) as reviewers. This patch is relevant to D14994, but the two patches are independent.

Patch by Alex Bradbury

Diff Detail

Event Timeline

asb updated this revision to Diff 41304.Nov 27 2015, 7:00 AM
asb retitled this revision from to [TableGen] Fix bug in printing namespace for register altname indices in AsmWriterEmitter.
asb updated this object.
asb added reviewers: stoklund, grosbach.
asb updated this object.
asb added a subscriber: llvm-commits.
asb updated this revision to Diff 41305.Nov 27 2015, 7:04 AM

Apologies, the previous patch missed an uncommitted fix.

hfinkel accepted this revision.Dec 10 2015, 1:39 PM
hfinkel added a reviewer: hfinkel.
hfinkel added a subscriber: hfinkel.

Seems to make sense, reading the namespace name from the first register def should be a reliable way to get it. LGTM.

This revision is now accepted and ready to land.Dec 10 2015, 1:39 PM
asb added a comment.Dec 11 2015, 2:21 AM

Seems to make sense, reading the namespace name from the first register def should be a reliable way to get it. LGTM.

Thanks for reviewing Hal, could you commit please? I've just checked the patch applies cleanly to rL255331, with all tests of course still passing.

hfinkel closed this revision.Dec 11 2015, 9:34 AM

r255344.