blob: 2415a85051aa47cb416b7e17bf786a03b9861463 [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)
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();
Evan Chengac1f7792009-03-08 04:02:49 +000038 unsigned Len = TT.length();
Evan Chenga5de2fc2009-03-09 20:25:39 +000039 unsigned Idx = 0;
40 if (Len >= 5 && TT.substr(0, 4) == "armv")
41 Idx = 4;
42 else if (Len >= 6 && TT.substr(0, 6) == "thumb") {
43 IsThumb = true;
44 if (Len >= 7 && TT[5] == 'v')
45 Idx = 6;
46 }
47 if (Idx) {
48 unsigned SubVer = TT[Idx];
49 if (SubVer > '4' && SubVer <= '9') {
50 if (SubVer >= '6')
51 ARMArchVersion = V6;
52 else if (SubVer == '5') {
53 ARMArchVersion = V5T;
54 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
55 ARMArchVersion = V5TE;
Evan Chengac1f7792009-03-08 04:02:49 +000056 }
57 }
58 }
59
Evan Chenga5de2fc2009-03-09 20:25:39 +000060 if (Len >= 10) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 if (TT.find("-darwin") != std::string::npos)
Evan Chenga5de2fc2009-03-09 20:25:39 +000062 // arm-darwin
Dan Gohmanf17a25c2007-07-18 16:29:46 +000063 TargetType = isDarwin;
64 } else if (TT.empty()) {
65#if defined(__APPLE__)
66 TargetType = isDarwin;
67#endif
68 }
69
70 if (TT.find("eabi") != std::string::npos)
71 TargetABI = ARM_ABI_AAPCS;
72
73 if (isAAPCS_ABI())
74 stackAlignment = 8;
75
76 if (isTargetDarwin()) {
77 UseThumbBacktraces = true;
78 IsR9Reserved = true;
79 }
80}