[llvm] r370805 - [MC] Pass through .code16/32/64 and .syntax unified for COFF
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 11:16:53 PDT 2019
Author: rnk
Date: Tue Sep 3 11:16:52 2019
New Revision: 370805
URL: http://llvm.org/viewvc/llvm-project?rev=370805&view=rev
Log:
[MC] Pass through .code16/32/64 and .syntax unified for COFF
These flags should simply be passed through to the target, which will do
the right thing. Add an MC/X86 test that uses these directives with the
three primary object file formats and shows that they disassemble the
same everywhere.
There is a missing test for .code32 on Windows ARM, since I'm not sure
exactly how to construct one.
Fixes PR43203
Added:
llvm/trunk/test/MC/X86/code16-32-64.s
Modified:
llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMWinCOFFStreamer.cpp
Modified: llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp?rev=370805&r1=370804&r2=370805&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp Tue Sep 3 11:16:52 2019
@@ -88,7 +88,19 @@ void MCWinCOFFStreamer::EmitLabel(MCSymb
}
void MCWinCOFFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
- llvm_unreachable("not implemented");
+ // Let the target do whatever target specific stuff it needs to do.
+ getAssembler().getBackend().handleAssemblerFlag(Flag);
+
+ switch (Flag) {
+ // None of these require COFF specific handling.
+ case MCAF_SyntaxUnified:
+ case MCAF_Code16:
+ case MCAF_Code32:
+ case MCAF_Code64:
+ break;
+ case MCAF_SubsectionsViaSymbols:
+ llvm_unreachable("COFF doesn't support .subsections_via_symbols");
+ }
}
void MCWinCOFFStreamer::EmitThumbFunc(MCSymbol *Func) {
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMWinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMWinCOFFStreamer.cpp?rev=370805&r1=370804&r2=370805&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMWinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMWinCOFFStreamer.cpp Tue Sep 3 11:16:52 2019
@@ -22,20 +22,10 @@ public:
std::unique_ptr<MCObjectWriter> OW)
: MCWinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW)) {}
- void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
void EmitThumbFunc(MCSymbol *Symbol) override;
void FinishImpl() override;
};
-void ARMWinCOFFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
- switch (Flag) {
- default: llvm_unreachable("not implemented");
- case MCAF_SyntaxUnified:
- case MCAF_Code16:
- break;
- }
-}
-
void ARMWinCOFFStreamer::EmitThumbFunc(MCSymbol *Symbol) {
getAssembler().setIsThumbFunc(Symbol);
}
Added: llvm/trunk/test/MC/X86/code16-32-64.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/code16-32-64.s?rev=370805&view=auto
==============================================================================
--- llvm/trunk/test/MC/X86/code16-32-64.s (added)
+++ llvm/trunk/test/MC/X86/code16-32-64.s Tue Sep 3 11:16:52 2019
@@ -0,0 +1,21 @@
+# RUN: llvm-mc %s -triple x86_64-linux-gnu -filetype=obj -o - | llvm-objdump -d - | FileCheck %s
+# RUN: llvm-mc %s -triple x86_64-windows-msvc -filetype=obj -o - | llvm-objdump -d - | FileCheck %s
+# RUN: llvm-mc %s -triple x86_64-apple-macos -filetype=obj -o - | llvm-objdump -d - | FileCheck %s
+
+.text
+.global foo
+foo:
+ .code64
+ movl (%eax), %eax
+ .code32
+ movl (%eax), %eax
+ .code16
+ movl (%eax), %eax
+ .code64
+ retq
+
+# CHECK: foo:
+# CHECK-NEXT: 67 8b 00 movl (%eax), %eax
+# CHECK-NEXT: 8b 00 movl (%rax), %eax
+# CHECK-NEXT: 67 66 8b 00 movw (%eax), %ax
+# CHECK-NEXT: c3 retq
More information about the llvm-commits
mailing list