Recognize triplets starting with armv5-, armv6- etc. And set the ARM arch version...
[oota-llvm.git] / lib / Target / ARM / ARMSubtarget.cpp
1 //===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the ARM specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "ARMSubtarget.h"
15 #include "ARMGenSubtarget.inc"
16 #include "llvm/Module.h"
17 using namespace llvm;
18
19 ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb)
20   : ARMArchVersion(V4T)
21   , HasVFP2(false)
22   , IsThumb(thumb)
23   , UseThumbBacktraces(false)
24   , IsR9Reserved(false)
25   , stackAlignment(4)
26   , TargetType(isELF) // Default to ELF unless otherwise specified.
27   , TargetABI(ARM_ABI_APCS) {
28
29   // Determine default and user specified characteristics
30   std::string CPU = "generic";
31
32   // Parse features string.
33   ParseSubtargetFeatures(FS, CPU);
34
35   // Set the boolean corresponding to the current target triple, or the default
36   // if one cannot be determined, to true.
37   const std::string& TT = M.getTargetTriple();
38   unsigned Len = TT.length();
39   if (Len >= 5) {
40     if (TT.substr(0, 4) == "armv") {
41       unsigned SubVer = TT[4];
42       if (SubVer > '4' && SubVer <= '9') {
43         if (SubVer >= '6')
44           ARMArchVersion = V6;
45         else if (SubVer == '5') {
46           ARMArchVersion = V5T;
47           if (Len >= 7 && TT[5] == 't' && TT[6] == 'e')
48             ARMArchVersion = V5TE;
49         }
50       }
51     }
52   }
53
54   if (Len > 5) {
55     if (TT.find("-darwin") != std::string::npos)
56       TargetType = isDarwin;
57   } else if (TT.empty()) {
58 #if defined(__APPLE__)
59     TargetType = isDarwin;
60 #endif
61   }
62
63   if (TT.find("eabi") != std::string::npos)
64     TargetABI = ARM_ABI_AAPCS;
65
66   if (isAAPCS_ABI())
67     stackAlignment = 8;
68
69   if (isTargetDarwin()) {
70     UseThumbBacktraces = true;
71     IsR9Reserved = true;
72   }
73 }