blob: bbc2202c3ba2047f660a7a247c8c1fd5814a93da [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();
38 if (TT.length() > 5) {
Evan Cheng1a3771e2007-01-19 19:22:40 +000039 if (TT.find("-darwin") != std::string::npos)
40 TargetType = isDarwin;
Evan Chenga8e29892007-01-19 07:51:42 +000041 } else if (TT.empty()) {
42#if defined(__APPLE__)
Evan Cheng1a3771e2007-01-19 19:22:40 +000043 TargetType = isDarwin;
Evan Chenga8e29892007-01-19 07:51:42 +000044#endif
45 }
46
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000047 if (TT.find("eabi") != std::string::npos)
48 TargetABI = ARM_ABI_AAPCS;
49
50 if (isAAPCS_ABI())
51 stackAlignment = 8;
52
Evan Cheng1a3771e2007-01-19 19:22:40 +000053 if (isTargetDarwin()) {
Evan Chenga8e29892007-01-19 07:51:42 +000054 UseThumbBacktraces = true;
55 IsR9Reserved = true;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000056 }
Evan Chenga8e29892007-01-19 07:51:42 +000057}