aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2017-08-12 17:40:18 +0000
committerFlorian Hahn <florian.hahn@arm.com>2017-08-12 17:40:18 +0000
commitace970e5d2e806f380756353f29693c5bbeeef85 (patch)
treef1c6d64568d0b200f52ac2efd96a84b667e2bc2a
parentc05af7aa8cbfafb74219fb9829c5e7937b1d1cd5 (diff)
[Triple] Add isThumb and isARM functions.
Summary: 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. Reviewers: javed.absar, rengolin, kristof.beyls, t.p.northover Reviewed By: rengolin Subscribers: llvm-commits, aemerson Differential Revision: https://reviews.llvm.org/D34682 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310781 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/Triple.h10
-rw-r--r--lib/MC/MCSectionELF.cpp3
-rw-r--r--lib/Object/ELFObjectFile.cpp3
-rw-r--r--lib/Target/ARM/ARMAsmPrinter.cpp6
-rw-r--r--lib/Target/ARM/ARMAsmPrinter.h3
-rw-r--r--lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp5
6 files changed, 15 insertions, 15 deletions
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index 124ff864793..c6e87deead3 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -630,6 +630,16 @@ public:
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(); }
diff --git a/lib/MC/MCSectionELF.cpp b/lib/MC/MCSectionELF.cpp
index 2f4f61aa4d5..bf1fcb03273 100644
--- a/lib/MC/MCSectionELF.cpp
+++ b/lib/MC/MCSectionELF.cpp
@@ -113,8 +113,7 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
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';
}
diff --git a/lib/Object/ELFObjectFile.cpp b/lib/Object/ELFObjectFile.cpp
index fa136d782b5..986eccc36e3 100644
--- a/lib/Object/ELFObjectFile.cpp
+++ b/lib/Object/ELFObjectFile.cpp
@@ -260,8 +260,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const {
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";
diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp
index 582153daebd..94bb9cbbb8a 100644
--- a/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -476,11 +476,7 @@ void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
// 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 ||
- TT.getSubArch() == Triple::ARMSubArch_v7m ||
- TT.getSubArch() == Triple::ARMSubArch_v6m;
- if (!M.getModuleInlineAsm().empty() && isThumb)
+ if (!M.getModuleInlineAsm().empty() && TT.isThumb())
OutStreamer->EmitAssemblerFlag(MCAF_Code16);
}
diff --git a/lib/Target/ARM/ARMAsmPrinter.h b/lib/Target/ARM/ARMAsmPrinter.h
index 93fed10eb2d..7b811b18f74 100644
--- a/lib/Target/ARM/ARMAsmPrinter.h
+++ b/lib/Target/ARM/ARMAsmPrinter.h
@@ -135,8 +135,7 @@ public:
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;
diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
index 9fb6ffcd6d2..969452e6fe9 100644
--- a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
+++ b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
@@ -131,16 +131,13 @@ static bool getARMLoadDeprecationInfo(MCInst &MI, const MCSubtargetInfo &STI,
#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;
ARM::ArchKind ArchID = ARM::parseArch(TT.getArchName());
if (ArchID != ARM::ArchKind::INVALID && (CPU.empty() || CPU == "generic"))
ARMArchFeature = (ARMArchFeature + "+" + ARM::getArchName(ArchID)).str();
- if (isThumb) {
+ if (TT.isThumb()) {
if (ARMArchFeature.empty())
ARMArchFeature = "+thumb-mode";
else