A few more SH{L|R}D peepholes.
[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   : stackAlignment(8), indirectExternAndWeakGlobals(false) {
20       
21   // Default to ELF unless otherwise specified.
22   TargetType = isELF;
23       
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) {
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;
35   } else if (TT.empty()) {
36 #if defined(__CYGWIN__) || defined(__MINGW32__)
37     TargetType = isCygwin;
38 #elif defined(__APPLE__)
39     TargetType = isDarwin;
40 #elif defined(_WIN32)
41     TargetType = isWindows;
42 #endif
43   }
44
45   if (TargetType == isDarwin) {
46     stackAlignment = 16;
47     indirectExternAndWeakGlobals = true;
48   }
49 }