[PATCH] D101975: [AsmParser][ARM] Make .thumb_func imply .thumb
LemonBoy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 5 23:55:10 PDT 2021
LemonBoy created this revision.
LemonBoy added reviewers: MaskRay, t.p.northover, lenary, nickdesaulniers.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
LemonBoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
GNU as documentation states that a `.thumb_func` directive implies `.thumb`, teach the asm parser to switch mode whenever it's encountered. On the other hand the labeled form, exclusive to Apple's toolchain, doesn't switch mode at all.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101975
Files:
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,20 @@
+@ 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
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11167,6 +11167,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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101975.343298.patch
Type: text/x-patch
Size: 1067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210506/7c82f08f/attachment.bin>
More information about the llvm-commits
mailing list