blob: ef78cd52d85a23236f8ad50c81ce2c0bc18ebb84 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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"
17using namespace llvm;
18
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000019ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS,
20 bool isThumb)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021 : ARMArchVersion(V4T)
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000022 , ARMFPUType(None)
Anton Korobeynikove7540d62009-06-01 20:00:48 +000023 , IsThumb(isThumb)
24 , ThumbMode(Thumb1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025 , UseThumbBacktraces(false)
26 , IsR9Reserved(false)
27 , stackAlignment(4)
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000028 , CPUString("generic")
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029 , TargetType(isELF) // Default to ELF unless otherwise specified.
30 , TargetABI(ARM_ABI_APCS) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000031 // Determine default and user specified characteristics
Dan Gohmanf17a25c2007-07-18 16:29:46 +000032
33 // Parse features string.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000034 CPUString = ParseSubtargetFeatures(FS, CPUString);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035
36 // Set the boolean corresponding to the current target triple, or the default
37 // if one cannot be determined, to true.
38 const std::string& TT = M.getTargetTriple();
Evan Chengac1f7792009-03-08 04:02:49 +000039 unsigned Len = TT.length();
Evan Chenga5de2fc2009-03-09 20:25:39 +000040 unsigned Idx = 0;
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000041
Evan Chenga5de2fc2009-03-09 20:25:39 +000042 if (Len >= 5 && TT.substr(0, 4) == "armv")
43 Idx = 4;
44 else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
Anton Korobeynikove7540d62009-06-01 20:00:48 +000045 IsThumb = true;
Evan Chenga5de2fc2009-03-09 20:25:39 +000046 if (Len >= 7 && TT[5] == 'v')
47 Idx = 6;
48 }
49 if (Idx) {
50 unsigned SubVer = TT[Idx];
51 if (SubVer > '4' && SubVer <= '9') {
Anton Korobeynikove7540d62009-06-01 20:00:48 +000052 if (SubVer >= '7')
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000053 ARMArchVersion = V7A;
Anton Korobeynikove7540d62009-06-01 20:00:48 +000054 else if (SubVer == '6')
Evan Chenga5de2fc2009-03-09 20:25:39 +000055 ARMArchVersion = V6;
Anton Korobeynikove7540d62009-06-01 20:00:48 +000056 else if (SubVer == '5') {
Evan Chenga5de2fc2009-03-09 20:25:39 +000057 ARMArchVersion = V5T;
58 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
59 ARMArchVersion = V5TE;
Evan Chengac1f7792009-03-08 04:02:49 +000060 }
61 }
62 }
63
Evan Chenga5de2fc2009-03-09 20:25:39 +000064 if (Len >= 10) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000065 if (TT.find("-darwin") != std::string::npos)
Evan Chenga5de2fc2009-03-09 20:25:39 +000066 // arm-darwin
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067 TargetType = isDarwin;
68 } else if (TT.empty()) {
69#if defined(__APPLE__)
70 TargetType = isDarwin;
71#endif
72 }
73
74 if (TT.find("eabi") != std::string::npos)
75 TargetABI = ARM_ABI_AAPCS;
76
77 if (isAAPCS_ABI())
78 stackAlignment = 8;
79
80 if (isTargetDarwin()) {
81 UseThumbBacktraces = true;
82 IsR9Reserved = true;
83 }
84}