Skip to content
X86Subtarget.cpp 1.59 KiB
Newer Older
//===-- X86Subtarget.cpp - X86 Subtarget Information ------------*- C++ -*-===//
Nate Begeman's avatar
Nate Begeman committed
//
//                     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;

Jim Laskey's avatar
 
Jim Laskey committed
X86Subtarget::X86Subtarget(const Module &M, const std::string &FS)
  : stackAlignment(8), indirectExternAndWeakGlobals(false) {
      
  // Default to ELF unless otherwise specified.
  TargetType = isELF;
      
Nate Begeman's avatar
Nate Begeman committed
  // 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) {
    if (TT.find("cygwin") != std::string::npos ||
        TT.find("mingw")  != std::string::npos)
      TargetType = isCygwin;
    else if (TT.find("darwin") != std::string::npos)
      TargetType = isDarwin;
    else if (TT.find("win32") != std::string::npos)
      TargetType = isWindows;
Nate Begeman's avatar
Nate Begeman committed
  } else if (TT.empty()) {
#if defined(__CYGWIN__) || defined(__MINGW32__)
Nate Begeman's avatar
Nate Begeman committed
#elif defined(__APPLE__)
Nate Begeman's avatar
Nate Begeman committed
#elif defined(_WIN32)
Nate Begeman's avatar
Nate Begeman committed
    stackAlignment = 16;
    indirectExternAndWeakGlobals = true;
  }
}