Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1 | //===-- 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" |
| 18 | using namespace llvm; |
| 19 | |
| 20 | // FIXME: this is temporary. |
| 21 | static cl::opt<bool> Thumb("enable-thumb", |
| 22 | cl::desc("Switch to thumb mode in ARM backend")); |
| 23 | |
| 24 | ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS) |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 25 | : ARMArchVersion(V4T) |
| 26 | , HasVFP2(false) |
| 27 | , UseThumbBacktraces(false) |
| 28 | , IsR9Reserved(false) |
| 29 | , stackAlignment(8) |
| 30 | , TargetType(isELF) { // Default to ELF unless otherwise specified. |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 31 | |
| 32 | // Determine default and user specified characteristics |
| 33 | std::string CPU = "generic"; |
| 34 | |
| 35 | // Parse features string. |
| 36 | ParseSubtargetFeatures(FS, CPU); |
| 37 | |
| 38 | IsThumb = Thumb; |
| 39 | |
| 40 | // Set the boolean corresponding to the current target triple, or the default |
| 41 | // if one cannot be determined, to true. |
| 42 | const std::string& TT = M.getTargetTriple(); |
| 43 | if (TT.length() > 5) { |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 44 | if (TT.find("-darwin") != std::string::npos) |
| 45 | TargetType = isDarwin; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 46 | } else if (TT.empty()) { |
| 47 | #if defined(__APPLE__) |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 48 | TargetType = isDarwin; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 49 | #endif |
| 50 | } |
| 51 | |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 52 | if (isTargetDarwin()) { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 53 | UseThumbBacktraces = true; |
| 54 | IsR9Reserved = true; |
| 55 | stackAlignment = 4; |
| 56 | } |
| 57 | } |