llvm-6502/lib/Target/X86/X86Subtarget.cpp
Nate Begeman fb5792f416 Implement Subtarget support
Implement the X86 Subtarget.

This consolidates the checks for target triple, and setting options based
on target triple into one place.  This allows us to convert the asm printer
and isel over from being littered with "forDarwin", "forCygwin", etc. into
just having the appropriate flags for each subtarget feature controlling
the code for that feature.

This patch also implements indirect external and weak references in the
X86 pattern isel, for darwin.  Next up is to convert over the asm printers
to use this new interface.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22389 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-12 01:41:54 +00:00

60 lines
1.9 KiB
C++

//===- X86Subtarget.cpp - X86 Instruction 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(M), stackAlignment(8),
indirectExternAndWeakGlobals(false), asmDarwinLinkerStubs(false),
asmLeadingUnderscore(false), asmAlignmentIsInBytes(false),
asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false),
asmPrintConstantAlignment(false) {
// Declare a boolean for each 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)
forWindws = true;
#endif
}
if (forCygwin) {
asmLeadingUnderscore = true;
}
if (forDarwin) {
stackAlignment = 16;
indirectExternAndWeakGlobals = true;
asmDarwinLinkerStubs = true;
asmLeadingUnderscore = true;
asmPrintDotLCommConstants = true;
}
if (forWindows) {
}
}