1. Use SubtargetFeatures in llc/lli.
[oota-llvm.git] / lib / Target / X86 / X86Subtarget.cpp
1 //===-- X86Subtarget.cpp - X86 Subtarget 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
18 X86Subtarget::X86Subtarget(const Module &M, const std::string &FS)
19   : TargetSubtarget(), stackAlignment(8),
20     indirectExternAndWeakGlobals(false), asmDarwinLinkerStubs(false),
21     asmLeadingUnderscore(false), asmAlignmentIsInBytes(false),
22     asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false),
23     asmPrintConstantAlignment(false) {
24   // Declare a boolean for each major platform.
25   bool forCygwin = false;
26   bool forDarwin = false;
27   bool forWindows = false;
28
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)
43     forWindows = true;
44 #endif
45   }
46
47   if (forCygwin) {
48     asmLeadingUnderscore = true;
49   } else if (forDarwin) {
50     stackAlignment = 16;
51     indirectExternAndWeakGlobals = true;
52     asmDarwinLinkerStubs = true;
53     asmLeadingUnderscore = true;
54     asmPrintDotLCommConstants = true;
55   } else if (forWindows) {
56   }
57 }