1 //===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the ARM specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #include "ARMSubtarget.h"
15 #include "ARMGenSubtarget.inc"
16 #include "llvm/Target/TargetOptions.h"
17 #include "llvm/Support/CommandLine.h"
21 ReserveR9("arm-reserve-r9", cl::Hidden,
22 cl::desc("Reserve R9, making it unavailable as GPR"));
24 ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS,
28 , UseNEONForSinglePrecisionFP(false)
31 , IsR9Reserved(ReserveR9)
33 , CPUString("generic")
34 , TargetType(isELF) // Default to ELF unless otherwise specified.
35 , TargetABI(ARM_ABI_APCS) {
36 // default to soft float ABI
37 if (FloatABIType == FloatABI::Default)
38 FloatABIType = FloatABI::Soft;
40 // Determine default and user specified characteristics
42 // Parse features string.
43 CPUString = ParseSubtargetFeatures(FS, CPUString);
45 // Set the boolean corresponding to the current target triple, or the default
46 // if one cannot be determined, to true.
47 unsigned Len = TT.length();
50 if (Len >= 5 && TT.substr(0, 4) == "armv")
52 else if (Len >= 6 && TT.substr(0, 5) == "thumb") {
54 if (Len >= 7 && TT[5] == 'v')
58 unsigned SubVer = TT[Idx];
59 if (SubVer > '4' && SubVer <= '9') {
62 } else if (SubVer == '6') {
64 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2')
65 ARMArchVersion = V6T2;
66 } else if (SubVer == '5') {
68 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
69 ARMArchVersion = V5TE;
71 if (ARMArchVersion >= V6T2)
76 // Thumb2 implies at least V6T2.
77 if (ARMArchVersion < V6T2 && ThumbMode >= Thumb2)
78 ARMArchVersion = V6T2;
81 if (TT.find("-darwin") != std::string::npos)
83 TargetType = isDarwin;
86 if (TT.find("eabi") != std::string::npos)
87 TargetABI = ARM_ABI_AAPCS;
93 IsR9Reserved = ReserveR9 | (ARMArchVersion < V6);