blob: 1c161562c37522fe17a45c613e4e8921ea376853 [file] [log] [blame]
Nate Begemanfb5792f2005-07-12 01:41:54 +00001//===- 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"
16using namespace llvm;
17
18X86Subtarget::X86Subtarget(const Module &M)
19 : TargetSubtarget(M), stackAlignment(8),
20 indirectExternAndWeakGlobals(false), asmDarwinLinkerStubs(false),
21 asmLeadingUnderscore(false), asmAlignmentIsInBytes(false),
22 asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false),
23 asmPrintConstantAlignment(false) {
Chris Lattnerb151aca2005-07-12 02:36:10 +000024 // Declare a boolean for each major platform.
Nate Begemanfb5792f2005-07-12 01:41:54 +000025 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)
Chris Lattnerb151aca2005-07-12 02:36:10 +000043 forWindows = true;
Nate Begemanfb5792f2005-07-12 01:41:54 +000044#endif
45 }
46
47 if (forCygwin) {
48 asmLeadingUnderscore = true;
Chris Lattnerb151aca2005-07-12 02:36:10 +000049 } else if (forDarwin) {
Nate Begemanfb5792f2005-07-12 01:41:54 +000050 stackAlignment = 16;
51 indirectExternAndWeakGlobals = true;
52 asmDarwinLinkerStubs = true;
53 asmLeadingUnderscore = true;
54 asmPrintDotLCommConstants = true;
Chris Lattnerb151aca2005-07-12 02:36:10 +000055 } else if (forWindows) {
Nate Begemanfb5792f2005-07-12 01:41:54 +000056 }
57}