blob: 7379f1c39d8970a856f5af735ea36d00cea493d7 [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
19ARMSubtarget::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)
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000026 , CPUString("generic")
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027 , TargetType(isELF) // Default to ELF unless otherwise specified.
28 , TargetABI(ARM_ABI_APCS) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029 // Determine default and user specified characteristics
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030
31 // Parse features string.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000032 CPUString = ParseSubtargetFeatures(FS, CPUString);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033
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();
Evan Chengac1f7792009-03-08 04:02:49 +000037 unsigned Len = TT.length();
Evan Chenga5de2fc2009-03-09 20:25:39 +000038 unsigned Idx = 0;
39 if (Len >= 5 && TT.substr(0, 4) == "armv")
40 Idx = 4;
41 else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
42 IsThumb = true;
43 if (Len >= 7 && TT[5] == 'v')
44 Idx = 6;
45 }
46 if (Idx) {
47 unsigned SubVer = TT[Idx];
48 if (SubVer > '4' && SubVer <= '9') {
49 if (SubVer >= '6')
50 ARMArchVersion = V6;
51 else if (SubVer == '5') {
52 ARMArchVersion = V5T;
53 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
54 ARMArchVersion = V5TE;
Evan Chengac1f7792009-03-08 04:02:49 +000055 }
56 }
57 }
58
Evan Chenga5de2fc2009-03-09 20:25:39 +000059 if (Len >= 10) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000060 if (TT.find("-darwin") != std::string::npos)
Evan Chenga5de2fc2009-03-09 20:25:39 +000061 // arm-darwin
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062 TargetType = isDarwin;
63 } else if (TT.empty()) {
64#if defined(__APPLE__)
65 TargetType = isDarwin;
66#endif
67 }
68
69 if (TT.find("eabi") != std::string::npos)
70 TargetABI = ARM_ABI_AAPCS;
71
72 if (isAAPCS_ABI())
73 stackAlignment = 8;
74
75 if (isTargetDarwin()) {
76 UseThumbBacktraces = true;
77 IsR9Reserved = true;
78 }
79}