blob: 35bb9accc3507ee46afa767960b60182360101d1 [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===-- ARMSubtarget.cpp - ARM Subtarget Information ------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Evan Cheng and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
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"
17#include "llvm/Support/CommandLine.h"
18using namespace llvm;
19
20// FIXME: this is temporary.
21static cl::opt<bool> Thumb("enable-thumb",
22 cl::desc("Switch to thumb mode in ARM backend"));
23
24ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS)
25 : ARMArchVersion(V4T), HasVFP2(false), IsDarwin(false),
26 UseThumbBacktraces(false), IsR9Reserved(false), stackAlignment(8) {
27
28 // Determine default and user specified characteristics
29 std::string CPU = "generic";
30
31 // Parse features string.
32 ParseSubtargetFeatures(FS, CPU);
33
34 IsThumb = Thumb;
35
36 // Set the boolean corresponding to the current target triple, or the default
37 // if one cannot be determined, to true.
38 const std::string& TT = M.getTargetTriple();
39 if (TT.length() > 5) {
40 IsDarwin = TT.find("-darwin") != std::string::npos;
41 } else if (TT.empty()) {
42#if defined(__APPLE__)
43 IsDarwin = true;
44#endif
45 }
46
47 if (IsDarwin) {
48 UseThumbBacktraces = true;
49 IsR9Reserved = true;
50 stackAlignment = 4;
51 }
52}