Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 1 | //===- X86Subtarget.cpp - X86 Instruction Information -----------*- C++ -*-===// |
| 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 | |
Jeff Cohen | 00b16889 | 2005-07-27 06:12:32 +0000 | [diff] [blame] | 18 | X86Subtarget::X86Subtarget(const Module &M) |
| 19 | : TargetSubtarget(), stackAlignment(8), |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 20 | indirectExternAndWeakGlobals(false), asmDarwinLinkerStubs(false), |
| 21 | asmLeadingUnderscore(false), asmAlignmentIsInBytes(false), |
| 22 | asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false), |
| 23 | asmPrintConstantAlignment(false) { |
Chris Lattner | b151aca | 2005-07-12 02:36:10 +0000 | [diff] [blame] | 24 | // Declare a boolean for each major platform. |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 25 | bool forCygwin = false; |
| 26 | bool forDarwin = false; |
| 27 | bool forWindows = false; |
Jeff Cohen | 00b16889 | 2005-07-27 06:12:32 +0000 | [diff] [blame] | 28 | |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 29 | // Set the boolean corresponding to the current target triple, or the default |
| 30 | // if one cannot be determined, to true. |
| 31 | const std::string& TT = M.getTargetTriple(); |
| 32 | if (TT.length() > 5) { |
| 33 | forCygwin = TT.find("cygwin") != std::string::npos || |
| 34 | TT.find("mingw") != std::string::npos; |
| 35 | forDarwin = TT.find("darwin") != std::string::npos; |
| 36 | forWindows = TT.find("win32") != std::string::npos; |
| 37 | } else if (TT.empty()) { |
| 38 | #if defined(__CYGWIN__) || defined(__MINGW32__) |
| 39 | forCygwin = true; |
| 40 | #elif defined(__APPLE__) |
| 41 | forDarwin = true; |
| 42 | #elif defined(_WIN32) |
Chris Lattner | b151aca | 2005-07-12 02:36:10 +0000 | [diff] [blame] | 43 | forWindows = true; |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 44 | #endif |
| 45 | } |
| 46 | |
| 47 | if (forCygwin) { |
| 48 | asmLeadingUnderscore = true; |
Chris Lattner | b151aca | 2005-07-12 02:36:10 +0000 | [diff] [blame] | 49 | } else if (forDarwin) { |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 50 | stackAlignment = 16; |
| 51 | indirectExternAndWeakGlobals = true; |
| 52 | asmDarwinLinkerStubs = true; |
| 53 | asmLeadingUnderscore = true; |
| 54 | asmPrintDotLCommConstants = true; |
Chris Lattner | b151aca | 2005-07-12 02:36:10 +0000 | [diff] [blame] | 55 | } else if (forWindows) { |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 56 | } |
| 57 | } |