blob: b05e674ff0a8c716a09b66fe93e94ee10a3a38cc [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)
Jeff Cohen00b168892005-07-27 06:12:32 +000019 : TargetSubtarget(), stackAlignment(8),
Nate Begemanfb5792f2005-07-12 01:41:54 +000020 indirectExternAndWeakGlobals(false), asmDarwinLinkerStubs(false),
21 asmLeadingUnderscore(false), asmAlignmentIsInBytes(false),
22 asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false),
23 asmPrintConstantAlignment(false) {
Chris Lattnere5600e52005-11-21 22:31:58 +000024
25 // Default to ELF unless otherwise specified.
26 TargetType = isELF;
27
Nate Begemanfb5792f2005-07-12 01:41:54 +000028 // Set the boolean corresponding to the current target triple, or the default
29 // if one cannot be determined, to true.
30 const std::string& TT = M.getTargetTriple();
31 if (TT.length() > 5) {
Chris Lattnere5600e52005-11-21 22:31:58 +000032 if (TT.find("cygwin") != std::string::npos ||
33 TT.find("mingw") != std::string::npos)
34 TargetType = isCygwin;
35 else if (TT.find("darwin") != std::string::npos)
36 TargetType = isDarwin;
37 else if (TT.find("win32") != std::string::npos)
38 TargetType = isWindows;
Nate Begemanfb5792f2005-07-12 01:41:54 +000039 } else if (TT.empty()) {
40#if defined(__CYGWIN__) || defined(__MINGW32__)
Chris Lattnere5600e52005-11-21 22:31:58 +000041 TargetType = isCygwin;
Nate Begemanfb5792f2005-07-12 01:41:54 +000042#elif defined(__APPLE__)
Chris Lattnere5600e52005-11-21 22:31:58 +000043 TargetType = isDarwin;
Nate Begemanfb5792f2005-07-12 01:41:54 +000044#elif defined(_WIN32)
Chris Lattnere5600e52005-11-21 22:31:58 +000045 TargetType = isWindows;
Nate Begemanfb5792f2005-07-12 01:41:54 +000046#endif
47 }
48
Chris Lattnere5600e52005-11-21 22:31:58 +000049 switch (TargetType) {
50 case isCygwin:
Nate Begemanfb5792f2005-07-12 01:41:54 +000051 asmLeadingUnderscore = true;
Chris Lattnere5600e52005-11-21 22:31:58 +000052 break;
53 case isDarwin:
Nate Begemanfb5792f2005-07-12 01:41:54 +000054 stackAlignment = 16;
55 indirectExternAndWeakGlobals = true;
56 asmDarwinLinkerStubs = true;
57 asmLeadingUnderscore = true;
58 asmPrintDotLCommConstants = true;
Chris Lattnere5600e52005-11-21 22:31:58 +000059 break;
60 default: break;
Nate Begemanfb5792f2005-07-12 01:41:54 +000061 }
62}