Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame] | 1 | //===-- X86Subtarget.cpp - X86 Subtarget Information ------------*- C++ -*-===// |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Nate Begeman 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 X86 specific subclass of TargetSubtarget. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "X86Subtarget.h" |
| 15 | #include "llvm/Module.h" |
| 16 | using namespace llvm; |
| 17 | |
Jim Laskey | b1e1180 | 2005-09-01 21:38:21 +0000 | [diff] [blame] | 18 | X86Subtarget::X86Subtarget(const Module &M, const std::string &FS) |
Chris Lattner | d460f57 | 2005-11-21 22:43:58 +0000 | [diff] [blame] | 19 | : stackAlignment(8), indirectExternAndWeakGlobals(false) { |
Chris Lattner | e5600e5 | 2005-11-21 22:31:58 +0000 | [diff] [blame] | 20 | |
| 21 | // Default to ELF unless otherwise specified. |
| 22 | TargetType = isELF; |
| 23 | |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 24 | // Set the boolean corresponding to the current target triple, or the default |
| 25 | // if one cannot be determined, to true. |
| 26 | const std::string& TT = M.getTargetTriple(); |
| 27 | if (TT.length() > 5) { |
Chris Lattner | e5600e5 | 2005-11-21 22:31:58 +0000 | [diff] [blame] | 28 | if (TT.find("cygwin") != std::string::npos || |
| 29 | TT.find("mingw") != std::string::npos) |
| 30 | TargetType = isCygwin; |
| 31 | else if (TT.find("darwin") != std::string::npos) |
| 32 | TargetType = isDarwin; |
| 33 | else if (TT.find("win32") != std::string::npos) |
| 34 | TargetType = isWindows; |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 35 | } else if (TT.empty()) { |
| 36 | #if defined(__CYGWIN__) || defined(__MINGW32__) |
Chris Lattner | e5600e5 | 2005-11-21 22:31:58 +0000 | [diff] [blame] | 37 | TargetType = isCygwin; |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 38 | #elif defined(__APPLE__) |
Chris Lattner | e5600e5 | 2005-11-21 22:31:58 +0000 | [diff] [blame] | 39 | TargetType = isDarwin; |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 40 | #elif defined(_WIN32) |
Chris Lattner | e5600e5 | 2005-11-21 22:31:58 +0000 | [diff] [blame] | 41 | TargetType = isWindows; |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 42 | #endif |
| 43 | } |
| 44 | |
Chris Lattner | d460f57 | 2005-11-21 22:43:58 +0000 | [diff] [blame] | 45 | if (TargetType == isDarwin) { |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 46 | stackAlignment = 16; |
| 47 | indirectExternAndWeakGlobals = true; |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 48 | } |
| 49 | } |