blob: 80f12b008ccc22141f64ca1cb1e00e1744290b62 [file] [log] [blame]
Nate Begeman8c00f8c2005-08-04 07:12:09 +00001//===-- X86Subtarget.cpp - X86 Subtarget Information ------------*- C++ -*-===//
Nate Begemanfb5792f2005-07-12 01:41:54 +00002//
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
Jim Laskeyb1e11802005-09-01 21:38:21 +000018X86Subtarget::X86Subtarget(const Module &M, const std::string &FS)
Chris Lattnerd460f572005-11-21 22:43:58 +000019 : stackAlignment(8), indirectExternAndWeakGlobals(false) {
Chris Lattnere5600e52005-11-21 22:31:58 +000020
21 // Default to ELF unless otherwise specified.
22 TargetType = isELF;
23
Nate Begemanfb5792f2005-07-12 01:41:54 +000024 // 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) {
Chris Lattnere5600e52005-11-21 22:31:58 +000028 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;
Nate Begemanfb5792f2005-07-12 01:41:54 +000035 } else if (TT.empty()) {
36#if defined(__CYGWIN__) || defined(__MINGW32__)
Chris Lattnere5600e52005-11-21 22:31:58 +000037 TargetType = isCygwin;
Nate Begemanfb5792f2005-07-12 01:41:54 +000038#elif defined(__APPLE__)
Chris Lattnere5600e52005-11-21 22:31:58 +000039 TargetType = isDarwin;
Nate Begemanfb5792f2005-07-12 01:41:54 +000040#elif defined(_WIN32)
Chris Lattnere5600e52005-11-21 22:31:58 +000041 TargetType = isWindows;
Nate Begemanfb5792f2005-07-12 01:41:54 +000042#endif
43 }
44
Chris Lattnerd460f572005-11-21 22:43:58 +000045 if (TargetType == isDarwin) {
Nate Begemanfb5792f2005-07-12 01:41:54 +000046 stackAlignment = 16;
47 indirectExternAndWeakGlobals = true;
Nate Begemanfb5792f2005-07-12 01:41:54 +000048 }
49}