Skip to content

[AsmPrinter] Don't check for inlineasm dialect on non-X86 platforms #98097

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 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions clang/test/CodeGen/aarch64-inlineasm-ios.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// REQUIRES: aarch64-registered-target
// RUN: %clang_cc1 -triple arm64-apple-ios -S -o - %s | FileCheck %s

// CHECK: _restartable_function:
// CHECK-NEXT: ldr x11, [x0]
// CHECK-NEXT: add x11, x11, #1
// CHECK-NEXT: str x11, [x0]
// CHECK-NEXT: Ltmp0:
// CHECK-NEXT: b Ltmp0
// CHECK-NEXT: LExit_restartable_function:
// CHECK-NEXT: ret
asm(".align 4\n"
" .text\n"
" .private_extern _restartable_function\n"
"_restartable_function:\n"
" ldr x11, [x0]\n"
" add x11, x11, #1\n"
" str x11, [x0]\n"
"1:\n"
" b 1b\n"
"LExit_restartable_function:\n"
" ret\n"
);
14 changes: 9 additions & 5 deletions llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ void AsmPrinter::emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
if (!TAP)
report_fatal_error("Inline asm not supported by this streamer because"
" we don't have an asm parser for this target\n");
Parser->setAssemblerDialect(Dialect);

// Respect inlineasm dialect on X86 targets only
if (TM.getTargetTriple().isX86()) {
Parser->setAssemblerDialect(Dialect);
// Enable lexing Masm binary and hex integer literals in intel inline
// assembly.
if (Dialect == InlineAsm::AD_Intel)
Parser->getLexer().setLexMasmIntegers(true);
}
Parser->setTargetParser(*TAP);
// Enable lexing Masm binary and hex integer literals in intel inline
// assembly.
if (Dialect == InlineAsm::AD_Intel)
Parser->getLexer().setLexMasmIntegers(true);

emitInlineAsmStart();
// Don't implicitly switch to the text section before the asm.
Expand Down
Loading