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"
21 ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS,
27 , UseThumbBacktraces(false)
30 , CPUString("generic")
31 , TargetType(isELF) // Default to ELF unless otherwise specified.
32 , TargetABI(ARM_ABI_APCS) {
33 // default to soft float ABI
34 if (FloatABIType == FloatABI::Default)
35 FloatABIType = FloatABI::Soft;
37 // Determine default and user specified characteristics
39 // Parse features string.
40 CPUString = ParseSubtargetFeatures(FS, CPUString);
42 // Set the boolean corresponding to the current target triple, or the default
43 // if one cannot be determined, to true.
44 const std::string& TT = M.getTargetTriple();
45 unsigned Len = TT.length();
48 if (Len >= 5 && TT.substr(0, 4) == "armv")
50 else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
52 if (Len >= 7 && TT[5] == 'v')
56 unsigned SubVer = TT[Idx];
57 if (SubVer > '4' && SubVer <= '9') {
60 else if (SubVer == '6')
62 else if (SubVer == '5') {
64 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
65 ARMArchVersion = V5TE;
71 if (TT.find("-darwin") != std::string::npos)
73 TargetType = isDarwin;
74 } else if (TT.empty()) {
75 #if defined(__APPLE__)
76 TargetType = isDarwin;
80 if (TT.find("eabi") != std::string::npos)
81 TargetABI = ARM_ABI_AAPCS;
86 if (isTargetDarwin()) {
87 UseThumbBacktraces = true;