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"
19 ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb)
23 , UseThumbBacktraces(false)
26 , CPUString("generic")
27 , TargetType(isELF) // Default to ELF unless otherwise specified.
28 , TargetABI(ARM_ABI_APCS) {
29 // Determine default and user specified characteristics
31 // Parse features string.
32 CPUString = ParseSubtargetFeatures(FS, CPUString);
34 // Set the boolean corresponding to the current target triple, or the default
35 // if one cannot be determined, to true.
36 const std::string& TT = M.getTargetTriple();
37 unsigned Len = TT.length();
39 if (Len >= 5 && TT.substr(0, 4) == "armv")
41 else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
43 if (Len >= 7 && TT[5] == 'v')
47 unsigned SubVer = TT[Idx];
48 if (SubVer > '4' && SubVer <= '9') {
51 else if (SubVer == '5') {
53 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
54 ARMArchVersion = V5TE;
60 if (TT.find("-darwin") != std::string::npos)
62 TargetType = isDarwin;
63 } else if (TT.empty()) {
64 #if defined(__APPLE__)
65 TargetType = isDarwin;
69 if (TT.find("eabi") != std::string::npos)
70 TargetABI = ARM_ABI_AAPCS;
75 if (isTargetDarwin()) {
76 UseThumbBacktraces = true;