-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MC][AArch64][ARM][X86] Push target-dependent assembler flags into targets #139844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,10 +66,10 @@ void ARMAsmPrinter::emitFunctionEntryLabel() { | |
auto &TS = | ||
static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer()); | ||
if (AFI->isThumbFunction()) { | ||
OutStreamer->emitAssemblerFlag(MCAF_Code16); | ||
TS.emitCode16(); | ||
TS.emitThumbFunc(CurrentFnSym); | ||
} else { | ||
OutStreamer->emitAssemblerFlag(MCAF_Code32); | ||
TS.emitCode32(); | ||
} | ||
|
||
// Emit symbol for CMSE non-secure entry point | ||
|
@@ -171,7 +171,9 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) { | |
// These are created per function, rather than per TU, since it's | ||
// relatively easy to exceed the thumb branch range within a TU. | ||
if (! ThumbIndirectPads.empty()) { | ||
OutStreamer->emitAssemblerFlag(MCAF_Code16); | ||
auto &TS = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ARMAsmPrinter should probably define a convenience method that returns ARMTargetStreamer. The cast appears to occur in quite a few functions. |
||
static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer()); | ||
TS.emitCode16(); | ||
emitAlignment(Align(2)); | ||
for (std::pair<unsigned, MCSymbol *> &TIP : ThumbIndirectPads) { | ||
OutStreamer->emitLabel(TIP.second); | ||
|
@@ -489,24 +491,30 @@ void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, | |
// the start mode, then restore the start mode. | ||
const bool WasThumb = isThumb(StartInfo); | ||
if (!EndInfo || WasThumb != isThumb(*EndInfo)) { | ||
OutStreamer->emitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32); | ||
auto &TS = | ||
static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer()); | ||
if (WasThumb) | ||
TS.emitCode16(); | ||
else | ||
TS.emitCode32(); | ||
} | ||
} | ||
|
||
void ARMAsmPrinter::emitStartOfAsmFile(Module &M) { | ||
const Triple &TT = TM.getTargetTriple(); | ||
auto &TS = | ||
static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer()); | ||
// Use unified assembler syntax. | ||
OutStreamer->emitAssemblerFlag(MCAF_SyntaxUnified); | ||
TS.emitSyntaxUnified(); | ||
|
||
// Emit ARM Build Attributes | ||
if (TT.isOSBinFormatELF()) | ||
emitAttributes(); | ||
|
||
// Use the triple's architecture and subarchitecture to determine | ||
// if we're thumb for the purposes of the top level code16 assembler | ||
// flag. | ||
// if we're thumb for the purposes of the top level code16 state. | ||
if (!M.getModuleInlineAsm().empty() && TT.isThumb()) | ||
OutStreamer->emitAssemblerFlag(MCAF_Code16); | ||
TS.emitCode16(); | ||
} | ||
|
||
static void | ||
|
@@ -575,7 +583,7 @@ void ARMAsmPrinter::emitEndOfAsmFile(Module &M) { | |
// implementation of multiple entry points). If this doesn't occur, the | ||
// linker can safely perform dead code stripping. Since LLVM never | ||
// generates code that does this, it is always safe to set. | ||
OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols); | ||
OutStreamer->emitSubsectionsViaSymbols(); | ||
} | ||
|
||
// The last attribute to be emitted is ABI_optimization_goals | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I agree that it's better to handle these very target-specific flags into XXXTargetStreamer