[PATCH] D101975: [AsmParser][ARM] Make .thumb_func imply .thumb
LemonBoy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 7 03:13:45 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf87638338464: [AsmParser][ARM] Make .thumb_func imply .thumb (authored by LemonBoy).
Changed prior to commit:
https://reviews.llvm.org/D101975?vs=343331&id=343628#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101975/new/
https://reviews.llvm.org/D101975
Files:
lld/test/ELF/arm-ldrlit-err.s
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/test/MC/ARM/thumb_func-implies-thumb.s
Index: llvm/test/MC/ARM/thumb_func-implies-thumb.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ARM/thumb_func-implies-thumb.s
@@ -0,0 +1,31 @@
+@ RUN: llvm-mc -triple=armv7-darwin- -show-encoding < %s | FileCheck %s
+.syntax unified
+
+.text
+
+.arm
+@ Ensure the plain form switches mode.
+.thumb_func
+@ CHECK: .code 16
+@ CHECK-LABEL: foo
+foo:
+ bx lr
+
+.arm
+@ Ensure the labeled form doesn't switch mode.
+.thumb_func bar
+@ CHECK-NOT: .code 16
+@ CHECK-LABEL: bar
+bar:
+ bx lr
+
+.arm
+@ Ensure the nop is assembled in thumb mode, even though the baz symbol is
+@ defined later.
+.thumb_func
+nop
+@ CHECK: .code 16
+@ CHECK-NEXT: nop
+@ CHECK-LABEL: baz
+baz:
+ bx lr
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11165,6 +11165,12 @@
"unexpected token in '.thumb_func' directive"))
return true;
+ // .thumb_func implies .thumb
+ if (!isThumb())
+ SwitchMode();
+
+ getParser().getStreamer().emitAssemblerFlag(MCAF_Code16);
+
NextSymbolIsThumb = true;
return false;
}
Index: lld/test/ELF/arm-ldrlit-err.s
===================================================================
--- lld/test/ELF/arm-ldrlit-err.s
+++ lld/test/ELF/arm-ldrlit-err.s
@@ -8,6 +8,9 @@
bx lr
nop
nop
+ nop
+ nop
+ nop
.section .text.1, "ax", %progbits
.global _start
@@ -27,3 +30,4 @@
.balign 4
high:
bx lr
+ nop
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101975.343628.patch
Type: text/x-patch
Size: 1601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210507/af799436/attachment.bin>
More information about the llvm-commits
mailing list