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/Module.h"
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetOptions.h"
19 #include "llvm/Support/CommandLine.h"
23 ReserveR9("arm-reserve-r9", cl::Hidden,
24 cl::desc("Reserve R9, making it unavailable as GPR"));
26 ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS,
32 , IsR9Reserved(ReserveR9)
34 , CPUString("generic")
35 , TargetType(isELF) // Default to ELF unless otherwise specified.
36 , TargetABI(ARM_ABI_APCS) {
37 // default to soft float ABI
38 if (FloatABIType == FloatABI::Default)
39 FloatABIType = FloatABI::Soft;
41 // Determine default and user specified characteristics
43 // Parse features string.
44 CPUString = ParseSubtargetFeatures(FS, CPUString);
46 // Set the boolean corresponding to the current target triple, or the default
47 // if one cannot be determined, to true.
48 const std::string& TT = M.getTargetTriple();
49 unsigned Len = TT.length();
52 if (Len >= 5 && TT.substr(0, 4) == "armv")
54 else if (Len >= 6 && TT.substr(0, 5) == "thumb") {
56 if (Len >= 7 && TT[5] == 'v')
60 unsigned SubVer = TT[Idx];
61 if (SubVer > '4' && SubVer <= '9') {
64 } else if (SubVer == '6') {
66 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2')
67 ARMArchVersion = V6T2;
68 } else if (SubVer == '5') {
70 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
71 ARMArchVersion = V5TE;
73 if (ARMArchVersion >= V6T2)
79 if (TT.find("-darwin") != std::string::npos)
81 TargetType = isDarwin;
82 } else if (TT.empty()) {
83 #if defined(__APPLE__)
84 TargetType = isDarwin;
88 if (TT.find("eabi") != std::string::npos)
89 TargetABI = ARM_ABI_AAPCS;
95 IsR9Reserved = ReserveR9 | (ARMArchVersion < V6);