blob: 96daca8067d477b51f145b08036cce2067ae70d2 [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 Korobeynikovf2e14752009-05-29 23:41:08 +000023 , ThumbMode((isThumb ? Thumb1 : ThumbNone))
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024 , UseThumbBacktraces(false)
25 , IsR9Reserved(false)
26 , stackAlignment(4)
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000027 , CPUString("generic")
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028 , TargetType(isELF) // Default to ELF unless otherwise specified.
29 , TargetABI(ARM_ABI_APCS) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030 // Determine default and user specified characteristics
Dan Gohmanf17a25c2007-07-18 16:29:46 +000031
32 // Parse features string.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000033 CPUString = ParseSubtargetFeatures(FS, CPUString);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034
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();
Evan Chengac1f7792009-03-08 04:02:49 +000038 unsigned Len = TT.length();
Evan Chenga5de2fc2009-03-09 20:25:39 +000039 unsigned Idx = 0;
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000040
Evan Chenga5de2fc2009-03-09 20:25:39 +000041 if (Len >= 5 && TT.substr(0, 4) == "armv")
42 Idx = 4;
43 else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000044 isThumb = true;
Evan Chenga5de2fc2009-03-09 20:25:39 +000045 if (Len >= 7 && TT[5] == 'v')
46 Idx = 6;
47 }
48 if (Idx) {
49 unsigned SubVer = TT[Idx];
50 if (SubVer > '4' && SubVer <= '9') {
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000051 if (SubVer >= '7') {
52 ARMArchVersion = V7A;
53 if (isThumb)
54 ThumbMode = Thumb2;
55 } else if (SubVer == '6') {
Evan Chenga5de2fc2009-03-09 20:25:39 +000056 ARMArchVersion = V6;
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000057 if (isThumb && Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2')
58 ThumbMode = Thumb2;
59 } else if (SubVer == '5') {
Evan Chenga5de2fc2009-03-09 20:25:39 +000060 ARMArchVersion = V5T;
61 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
62 ARMArchVersion = V5TE;
Evan Chengac1f7792009-03-08 04:02:49 +000063 }
64 }
65 }
66
Evan Chenga5de2fc2009-03-09 20:25:39 +000067 if (Len >= 10) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068 if (TT.find("-darwin") != std::string::npos)
Evan Chenga5de2fc2009-03-09 20:25:39 +000069 // arm-darwin
Dan Gohmanf17a25c2007-07-18 16:29:46 +000070 TargetType = isDarwin;
71 } else if (TT.empty()) {
72#if defined(__APPLE__)
73 TargetType = isDarwin;
74#endif
75 }
76
77 if (TT.find("eabi") != std::string::npos)
78 TargetABI = ARM_ABI_AAPCS;
79
80 if (isAAPCS_ABI())
81 stackAlignment = 8;
82
83 if (isTargetDarwin()) {
84 UseThumbBacktraces = true;
85 IsR9Reserved = true;
86 }
87}