This is an archive of the discontinued LLVM Phabricator instance.

[MC] Use .p2align instead of .align
ClosedPublic

Authored by sunfish on Jan 25 2016, 12:15 PM.

Details

Summary

For historic reasons, the behavior of .align differs between targets. Fortunately, there are alternatives, .p2align and .balign, which make the interpretation of the parameter explicit, and which behave consistently across targets.

This patch teaches MC to use .p2align instead of .align, so that people reading code for multiple architectures don't have to remember which way each platform does its .align directive.

Diff Detail

Repository
rL LLVM

Event Timeline

sunfish updated this revision to Diff 45898.Jan 25 2016, 12:15 PM
sunfish retitled this revision from to [MC] Use .p2align instead of .align.
sunfish updated this object.
sunfish set the repository for this revision to rL LLVM.
sunfish added subscribers: majnemer, compnerd, joerg, llvm-commits.

In general I like this a lot. But I fear there is probably some obscure assembler on some target somewhere that does not support .p2align. Maybe we need some kind of target hook to allow use of .align (either alongside getAlignmentIsInBytes() or perhaps replacing or subsuming it)? Or we could just propose/do this and let someone complain with a specific use case before doing that?

majnemer accepted this revision.Jan 25 2016, 12:49 PM
majnemer added a reviewer: majnemer.

This LGTM.

The only GAS configuration which doesn't support .p2align is Texas Instruments TMS320C54X. We do not support it so we could cross that bridge when we get there.

This revision is now accepted and ready to land.Jan 25 2016, 12:49 PM
This revision was automatically updated to reflect the committed changes.