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,
30 , IsR9Reserved(ReserveR9)
32 , CPUString("generic")
33 , TargetType(isELF) // Default to ELF unless otherwise specified.
34 , TargetABI(ARM_ABI_APCS) {
35 // default to soft float ABI
36 if (FloatABIType == FloatABI::Default)
37 FloatABIType = FloatABI::Soft;
39 // Determine default and user specified characteristics
41 // Parse features string.
42 CPUString = ParseSubtargetFeatures(FS, CPUString);
44 // Set the boolean corresponding to the current target triple, or the default
45 // if one cannot be determined, to true.
46 unsigned Len = TT.length();
49 if (Len >= 5 && TT.substr(0, 4) == "armv")
51 else if (Len >= 6 && TT.substr(0, 5) == "thumb") {
53 if (Len >= 7 && TT[5] == 'v')
57 unsigned SubVer = TT[Idx];
58 if (SubVer > '4' && SubVer <= '9') {
61 } else if (SubVer == '6') {
63 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2')
64 ARMArchVersion = V6T2;
65 } else if (SubVer == '5') {
67 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
68 ARMArchVersion = V5TE;
70 if (ARMArchVersion >= V6T2)
75 // Thumb2 implies at least V6T2.
76 if (ARMArchVersion < V6T2 && ThumbMode >= Thumb2)
77 ARMArchVersion = V6T2;
80 if (TT.find("-darwin") != std::string::npos)
82 TargetType = isDarwin;
83 } else if (TT.empty()) {
84 #if defined(__APPLE__)
85 TargetType = isDarwin;
89 if (TT.find("eabi") != std::string::npos)
90 TargetABI = ARM_ABI_AAPCS;
96 IsR9Reserved = ReserveR9 | (ARMArchVersion < V6);