Skip to content
Open
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
2 changes: 2 additions & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ Changes to the X86 Backend

* `-mcpu=wildcatlake` is now supported.
* `-mcpu=novalake` is now supported.
* `.att_syntax` is now emitted at the beginning of the file when emitting AT&T
syntax assembly.

Changes to the OCaml bindings
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/MC/MCStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ class LLVM_ABI MCStreamer {
/// Get the .xdata section used for the given section.
MCSection *getAssociatedXDataSection(const MCSection *TextSec);

virtual void emitSyntaxDirective();
virtual void emitSyntaxDirective(StringRef Syntax, StringRef Options);

/// Record a relocation described by the .reloc directive.
virtual void emitRelocDirective(const MCExpr &Offset, StringRef Name,
Expand Down
14 changes: 6 additions & 8 deletions llvm/lib/MC/MCAsmStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MCAsmStreamer final : public MCStreamer {
EmitCommentsAndEOL();
}

void emitSyntaxDirective() override;
void emitSyntaxDirective(StringRef Syntax, StringRef Options) override;

void EmitCommentsAndEOL();

Expand Down Expand Up @@ -796,14 +796,12 @@ void MCAsmStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
EmitEOL();
}

void MCAsmStreamer::emitSyntaxDirective() {
if (MAI->getAssemblerDialect() == 1) {
OS << "\t.intel_syntax noprefix";
EmitEOL();
void MCAsmStreamer::emitSyntaxDirective(StringRef Syntax, StringRef Options) {
OS << "\t." << Syntax << "_syntax";
if (!Options.empty()) {
OS << " " << Options;
}
// FIXME: Currently emit unprefix'ed registers.
// The intel_syntax directive has one optional argument
// with may have a value of prefix or noprefix.
EmitEOL();
}

void MCAsmStreamer::beginCOFFSymbolDef(const MCSymbol *Symbol) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/MC/MCStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ MCSection *MCStreamer::getAssociatedXDataSection(const MCSection *TextSec) {
TextSec);
}

void MCStreamer::emitSyntaxDirective() {}
void MCStreamer::emitSyntaxDirective(StringRef Syntax, StringRef Options) {}

static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg) {
return Ctx.getRegisterInfo()->getSEHRegNum(Reg);
Expand Down
6 changes: 5 additions & 1 deletion llvm/lib/Target/M68k/M68kAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ void M68kAsmPrinter::emitFunctionBodyStart() {}
void M68kAsmPrinter::emitFunctionBodyEnd() {}

void M68kAsmPrinter::emitStartOfAsmFile(Module &M) {
OutStreamer->emitSyntaxDirective();
// m68k assemblers generally don't support .att_syntax so we only emit the
// directive for Intel syntax.
if (MAI->getAssemblerDialect() == InlineAsm::AD_Intel) {
OutStreamer->emitSyntaxDirective("intel", "noprefix");
}
}

void M68kAsmPrinter::emitEndOfAsmFile(Module &M) {}
Expand Down
8 changes: 7 additions & 1 deletion llvm/lib/Target/X86/X86AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,13 @@ void X86AsmPrinter::emitStartOfAsmFile(Module &M) {
if (M.getModuleFlag("import-call-optimization"))
EnableImportCallOptimization = true;
}
OutStreamer->emitSyntaxDirective();

// FIXME: Currently emit unprefix'ed registers.
// The intel_syntax directive has one optional argument
// with may have a value of prefix or noprefix.
const bool IntelSyntax = MAI->getAssemblerDialect() == InlineAsm::AD_Intel;
OutStreamer->emitSyntaxDirective(IntelSyntax ? "intel" : "att",
IntelSyntax ? "noprefix" : "");

// If this is not inline asm and we're in 16-bit
// mode prefix assembly with .code16.
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/CodeGen/X86/asm-syntax-directive.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
;; Make sure that we always emit an assembly syntax directive for X86.
; RUN: llc < %s -mtriple=x86_64 | FileCheck %s --check-prefix=ATT
; RUN: llc < %s -mtriple=x86_64 -x86-asm-syntax=att | FileCheck %s --check-prefix=ATT
; RUN: llc < %s -mtriple=x86_64 -x86-asm-syntax=intel | FileCheck %s --check-prefix=INTEL

; INTEL: .intel_syntax noprefix
; ATT: .att_syntax
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/coal-sections.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; Check that *coal* sections are not emitted.

; CHECK: .section __TEXT,__text,regular,pure_instructions{{$}}
; CHECK-NEXT: .globl _foo
; CHECK: .globl _foo

; CHECK: .section __TEXT,__const{{$}}
; CHECK-NEXT: .globl _a
Expand Down
Loading