[PATCH] D34682: [Triple] Add isThumb and isARM functions NFCI.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 27 04:57:31 PDT 2017
fhahn created this revision.
Herald added a subscriber: aemerson.
isThumb returns true for Thumb triples (little and big endian), isARM
returns true for ARM triples (little and big endian).
There are a few more checks using arm/thumb that are not covered by
those functions, e.g. that the architecture is either ARM or Thumb
(little endian) or ARM/Thumb little endian only.
https://reviews.llvm.org/D34682
Files:
include/llvm/ADT/Triple.h
lib/MC/MCSectionELF.cpp
lib/Object/ELFObjectFile.cpp
lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/ARM/ARMAsmPrinter.h
lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
Index: lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
===================================================================
--- lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
+++ lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
@@ -131,16 +131,13 @@
#include "ARMGenSubtargetInfo.inc"
std::string ARM_MC::ParseARMTriple(const Triple &TT, StringRef CPU) {
- bool isThumb =
- TT.getArch() == Triple::thumb || TT.getArch() == Triple::thumbeb;
-
std::string ARMArchFeature;
unsigned ArchID = ARM::parseArch(TT.getArchName());
if (ArchID != ARM::AK_INVALID && (CPU.empty() || CPU == "generic"))
ARMArchFeature = (ARMArchFeature + "+" + ARM::getArchName(ArchID)).str();
- if (isThumb) {
+ if (TT.isThumb()) {
if (ARMArchFeature.empty())
ARMArchFeature = "+thumb-mode";
else
Index: lib/Target/ARM/ARMAsmPrinter.h
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.h
+++ lib/Target/ARM/ARMAsmPrinter.h
@@ -135,8 +135,7 @@
const Triple &TT = TM.getTargetTriple();
if (!TT.isOSBinFormatMachO())
return 0;
- bool isThumb = TT.getArch() == Triple::thumb ||
- TT.getArch() == Triple::thumbeb ||
+ bool isThumb = TT.isThumb() ||
TT.getSubArch() == Triple::ARMSubArch_v7m ||
TT.getSubArch() == Triple::ARMSubArch_v6m;
return isThumb ? ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
Index: lib/Target/ARM/ARMAsmPrinter.cpp
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.cpp
+++ lib/Target/ARM/ARMAsmPrinter.cpp
@@ -476,8 +476,7 @@
// Use the triple's architecture and subarchitecture to determine
// if we're thumb for the purposes of the top level code16 assembler
// flag.
- bool isThumb = TT.getArch() == Triple::thumb ||
- TT.getArch() == Triple::thumbeb ||
+ bool isThumb = TT.isThumb() ||
TT.getSubArch() == Triple::ARMSubArch_v7m ||
TT.getSubArch() == Triple::ARMSubArch_v6m;
if (!M.getModuleInlineAsm().empty() && isThumb)
Index: lib/Object/ELFObjectFile.cpp
===================================================================
--- lib/Object/ELFObjectFile.cpp
+++ lib/Object/ELFObjectFile.cpp
@@ -260,8 +260,7 @@
std::string Triple;
// Default to ARM, but use the triple if it's been set.
- if (TheTriple.getArch() == Triple::thumb ||
- TheTriple.getArch() == Triple::thumbeb)
+ if (TheTriple.isThumb())
Triple = "thumb";
else
Triple = "arm";
Index: lib/MC/MCSectionELF.cpp
===================================================================
--- lib/MC/MCSectionELF.cpp
+++ lib/MC/MCSectionELF.cpp
@@ -113,8 +113,7 @@
OS << 'c';
if (Flags & ELF::XCORE_SHF_DP_SECTION)
OS << 'd';
- } else if (Arch == Triple::arm || Arch == Triple::armeb ||
- Arch == Triple::thumb || Arch == Triple::thumbeb) {
+ } else if (T.isARM() || T.isThumb()) {
if (Flags & ELF::SHF_ARM_PURECODE)
OS << 'y';
}
Index: include/llvm/ADT/Triple.h
===================================================================
--- include/llvm/ADT/Triple.h
+++ include/llvm/ADT/Triple.h
@@ -634,6 +634,16 @@
return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
}
+ /// Tests whether the target is Thumb (little and big endian).
+ bool isThumb() const {
+ return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
+ }
+
+ /// Tests whether the target is ARM (little and big endian).
+ bool isARM() const {
+ return getArch() == Triple::arm || getArch() == Triple::armeb;
+ }
+
/// Tests wether the target supports comdat
bool supportsCOMDAT() const { return !isOSBinFormatMachO(); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34682.104141.patch
Type: text/x-patch
Size: 3761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170627/f2999cc1/attachment.bin>
More information about the llvm-commits
mailing list