blob: f5a18405f9ea4357dfe0ab4af4f6b3cd42474cb4 [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chenga8e29892007-01-19 07:51:42 +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"
Evan Chenga8e29892007-01-19 07:51:42 +000017using namespace llvm;
18
Evan Cheng04321f72007-02-23 03:14:31 +000019ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb)
Evan Cheng1a3771e2007-01-19 19:22:40 +000020 : ARMArchVersion(V4T)
21 , HasVFP2(false)
Evan Cheng04321f72007-02-23 03:14:31 +000022 , IsThumb(thumb)
Evan Cheng1a3771e2007-01-19 19:22:40 +000023 , UseThumbBacktraces(false)
24 , IsR9Reserved(false)
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000025 , stackAlignment(4)
26 , TargetType(isELF) // Default to ELF unless otherwise specified.
27 , TargetABI(ARM_ABI_APCS) {
Evan Chenga8e29892007-01-19 07:51:42 +000028
29 // Determine default and user specified characteristics
30 std::string CPU = "generic";
31
32 // Parse features string.
33 ParseSubtargetFeatures(FS, CPU);
34
Evan Chenga8e29892007-01-19 07:51:42 +000035 // 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 Cheng4b174742009-03-08 04:02:49 +000038 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) {
Evan Cheng1a3771e2007-01-19 19:22:40 +000055 if (TT.find("-darwin") != std::string::npos)
56 TargetType = isDarwin;
Evan Chenga8e29892007-01-19 07:51:42 +000057 } else if (TT.empty()) {
58#if defined(__APPLE__)
Evan Cheng1a3771e2007-01-19 19:22:40 +000059 TargetType = isDarwin;
Evan Chenga8e29892007-01-19 07:51:42 +000060#endif
61 }
62
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000063 if (TT.find("eabi") != std::string::npos)
64 TargetABI = ARM_ABI_AAPCS;
65
66 if (isAAPCS_ABI())
67 stackAlignment = 8;
68
Evan Cheng1a3771e2007-01-19 19:22:40 +000069 if (isTargetDarwin()) {
Evan Chenga8e29892007-01-19 07:51:42 +000070 UseThumbBacktraces = true;
71 IsR9Reserved = true;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000072 }
Evan Chenga8e29892007-01-19 07:51:42 +000073}