summaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86Subtarget.cpp
blob: ed8b8712a7ef6f5ebb418fad3d7f53b5e74996e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//===-- X86Subtarget.cpp - X86 Subtarget Information ------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by Nate Begeman and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the X86 specific subclass of TargetSubtarget.
//
//===----------------------------------------------------------------------===//

#include "X86Subtarget.h"
#include "llvm/Module.h"
using namespace llvm;

X86Subtarget::X86Subtarget(const Module &M)
  : TargetSubtarget(), stackAlignment(8),
    indirectExternAndWeakGlobals(false), asmDarwinLinkerStubs(false),
    asmLeadingUnderscore(false), asmAlignmentIsInBytes(false),
    asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false),
    asmPrintConstantAlignment(false) {
  // Declare a boolean for each major platform.
  bool forCygwin = false;
  bool forDarwin = false;
  bool forWindows = false;

  // Set the boolean corresponding to the current target triple, or the default
  // if one cannot be determined, to true.
  const std::string& TT = M.getTargetTriple();
  if (TT.length() > 5) {
    forCygwin = TT.find("cygwin") != std::string::npos ||
                TT.find("mingw")  != std::string::npos;
    forDarwin = TT.find("darwin") != std::string::npos;
    forWindows = TT.find("win32") != std::string::npos;
  } else if (TT.empty()) {
#if defined(__CYGWIN__) || defined(__MINGW32__)
    forCygwin = true;
#elif defined(__APPLE__)
    forDarwin = true;
#elif defined(_WIN32)
    forWindows = true;
#endif
  }

  if (forCygwin) {
    asmLeadingUnderscore = true;
  } else if (forDarwin) {
    stackAlignment = 16;
    indirectExternAndWeakGlobals = true;
    asmDarwinLinkerStubs = true;
    asmLeadingUnderscore = true;
    asmPrintDotLCommConstants = true;
  } else if (forWindows) {
  }
}