2002-10-30 06:37:54 +08:00
|
|
|
//===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
|
2005-04-22 07:38:14 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 07:38:14 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-22 07:38:14 +08:00
|
|
|
//
|
2002-10-30 06:37:54 +08:00
|
|
|
// This file defines the X86 specific subclass of TargetMachine.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "X86TargetMachine.h"
|
2002-12-24 08:04:01 +08:00
|
|
|
#include "X86.h"
|
2014-11-13 17:26:31 +08:00
|
|
|
#include "X86TargetObjectFile.h"
|
2015-01-31 19:17:59 +08:00
|
|
|
#include "X86TargetTransformInfo.h"
|
2003-01-13 08:51:23 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2014-10-06 14:45:36 +08:00
|
|
|
#include "llvm/IR/Function.h"
|
2015-02-13 18:01:29 +08:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2011-08-23 09:14:17 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2009-07-15 04:18:05 +08:00
|
|
|
#include "llvm/Support/FormattedStream.h"
|
2011-08-25 02:08:43 +08:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2003-12-20 09:22:19 +08:00
|
|
|
using namespace llvm;
|
2003-11-12 06:41:34 +08:00
|
|
|
|
2011-02-17 20:23:50 +08:00
|
|
|
extern "C" void LLVMInitializeX86Target() {
|
2009-07-25 14:49:55 +08:00
|
|
|
// Register the target.
|
2014-01-08 08:08:50 +08:00
|
|
|
RegisterTargetMachine<X86TargetMachine> X(TheX86_32Target);
|
|
|
|
RegisterTargetMachine<X86TargetMachine> Y(TheX86_64Target);
|
2006-09-08 07:39:26 +08:00
|
|
|
}
|
2006-09-08 14:48:29 +08:00
|
|
|
|
2014-11-13 17:26:31 +08:00
|
|
|
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
|
|
|
|
if (TT.isOSBinFormatMachO()) {
|
|
|
|
if (TT.getArch() == Triple::x86_64)
|
|
|
|
return make_unique<X86_64MachoTargetObjectFile>();
|
|
|
|
return make_unique<TargetLoweringObjectFileMachO>();
|
|
|
|
}
|
|
|
|
|
2015-03-12 00:16:09 +08:00
|
|
|
if (TT.isOSLinux() || TT.isOSNaCl())
|
|
|
|
return make_unique<X86LinuxNaClTargetObjectFile>();
|
2014-11-13 17:26:31 +08:00
|
|
|
if (TT.isOSBinFormatELF())
|
2015-03-04 05:01:27 +08:00
|
|
|
return make_unique<X86ELFTargetObjectFile>();
|
2014-11-13 17:26:31 +08:00
|
|
|
if (TT.isKnownWindowsMSVCEnvironment())
|
|
|
|
return make_unique<X86WindowsTargetObjectFile>();
|
|
|
|
if (TT.isOSBinFormatCOFF())
|
|
|
|
return make_unique<TargetLoweringObjectFileCOFF>();
|
|
|
|
llvm_unreachable("unknown subtarget type");
|
|
|
|
}
|
|
|
|
|
2015-01-27 03:03:15 +08:00
|
|
|
static std::string computeDataLayout(const Triple &TT) {
|
|
|
|
// X86 is little endian
|
|
|
|
std::string Ret = "e";
|
|
|
|
|
|
|
|
Ret += DataLayout::getManglingComponent(TT);
|
|
|
|
// X86 and x32 have 32 bit pointers.
|
|
|
|
if ((TT.isArch64Bit() &&
|
|
|
|
(TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) ||
|
|
|
|
!TT.isArch64Bit())
|
|
|
|
Ret += "-p:32:32";
|
|
|
|
|
|
|
|
// Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
|
|
|
|
if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl())
|
|
|
|
Ret += "-i64:64";
|
|
|
|
else
|
|
|
|
Ret += "-f64:32:64";
|
|
|
|
|
|
|
|
// Some ABIs align long double to 128 bits, others to 32.
|
|
|
|
if (TT.isOSNaCl())
|
|
|
|
; // No f80
|
|
|
|
else if (TT.isArch64Bit() || TT.isOSDarwin())
|
|
|
|
Ret += "-f80:128";
|
|
|
|
else
|
|
|
|
Ret += "-f80:32";
|
|
|
|
|
|
|
|
// The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
|
|
|
|
if (TT.isArch64Bit())
|
|
|
|
Ret += "-n8:16:32:64";
|
|
|
|
else
|
|
|
|
Ret += "-n8:16:32";
|
|
|
|
|
|
|
|
// The stack is aligned to 32 bits on some ABIs and 128 bits on others.
|
|
|
|
if (!TT.isArch64Bit() && TT.isOSWindows())
|
2015-05-01 06:11:59 +08:00
|
|
|
Ret += "-a:0:32-S32";
|
2015-01-27 03:03:15 +08:00
|
|
|
else
|
|
|
|
Ret += "-S128";
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
2009-07-09 11:32:31 +08:00
|
|
|
/// X86TargetMachine ctor - Create an X86 target.
|
2002-10-30 06:37:54 +08:00
|
|
|
///
|
2014-06-06 06:10:58 +08:00
|
|
|
X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT, StringRef CPU,
|
|
|
|
StringRef FS, const TargetOptions &Options,
|
2011-07-20 15:51:56 +08:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
2014-01-08 08:08:50 +08:00
|
|
|
CodeGenOpt::Level OL)
|
2015-03-12 08:07:24 +08:00
|
|
|
: LLVMTargetMachine(T, computeDataLayout(Triple(TT)), TT, CPU, FS, Options,
|
|
|
|
RM, CM, OL),
|
2014-11-13 17:26:31 +08:00
|
|
|
TLOF(createTLOF(Triple(getTargetTriple()))),
|
2014-06-10 01:08:19 +08:00
|
|
|
Subtarget(TT, CPU, FS, *this, Options.StackAlignmentOverride) {
|
2014-04-19 21:47:43 +08:00
|
|
|
// Windows stack unwinder gets confused when execution flow "falls through"
|
|
|
|
// after a call to 'noreturn' function.
|
|
|
|
// To prevent that, we emit a trap for 'unreachable' IR instructions.
|
|
|
|
// (which on X86, happens to be the 'ud2' instruction)
|
|
|
|
if (Subtarget.isTargetWin64())
|
|
|
|
this->Options.TrapUnreachable = true;
|
|
|
|
|
2015-06-04 09:32:35 +08:00
|
|
|
// TODO: By default, all reciprocal estimate operations are off because
|
|
|
|
// that matches the behavior before TargetRecip was added (except for btver2
|
|
|
|
// which used subtarget features to enable this type of codegen).
|
|
|
|
// We should change this to match GCC behavior where everything but
|
|
|
|
// scalar division estimates are turned on by default with -ffast-math.
|
|
|
|
this->Options.Reciprocals.setDefaults("all", false, 1);
|
|
|
|
|
2014-01-08 08:08:50 +08:00
|
|
|
initAsmInfo();
|
2006-02-04 02:59:39 +08:00
|
|
|
}
|
2002-10-30 06:37:54 +08:00
|
|
|
|
2014-11-21 07:37:18 +08:00
|
|
|
X86TargetMachine::~X86TargetMachine() {}
|
|
|
|
|
2014-10-06 14:45:36 +08:00
|
|
|
const X86Subtarget *
|
|
|
|
X86TargetMachine::getSubtargetImpl(const Function &F) const {
|
2015-02-14 09:59:52 +08:00
|
|
|
Attribute CPUAttr = F.getFnAttribute("target-cpu");
|
|
|
|
Attribute FSAttr = F.getFnAttribute("target-features");
|
2014-10-06 14:45:36 +08:00
|
|
|
|
|
|
|
std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
|
|
|
|
? CPUAttr.getValueAsString().str()
|
|
|
|
: TargetCPU;
|
|
|
|
std::string FS = !FSAttr.hasAttribute(Attribute::None)
|
|
|
|
? FSAttr.getValueAsString().str()
|
|
|
|
: TargetFS;
|
|
|
|
|
|
|
|
// FIXME: This is related to the code below to reset the target options,
|
|
|
|
// we need to know whether or not the soft float flag is set on the
|
|
|
|
// function before we can generate a subtarget. We also need to use
|
|
|
|
// it as a key for the subtarget since that can be the only difference
|
|
|
|
// between two functions.
|
2015-05-12 09:26:05 +08:00
|
|
|
bool SoftFloat =
|
|
|
|
F.hasFnAttribute("use-soft-float") &&
|
|
|
|
F.getFnAttribute("use-soft-float").getValueAsString() == "true";
|
|
|
|
// If the soft float attribute is set on the function turn on the soft float
|
|
|
|
// subtarget feature.
|
|
|
|
if (SoftFloat)
|
|
|
|
FS += FS.empty() ? "+soft-float" : ",+soft-float";
|
|
|
|
|
|
|
|
auto &I = SubtargetMap[CPU + FS];
|
2014-10-06 14:45:36 +08:00
|
|
|
if (!I) {
|
|
|
|
// This needs to be done before we create a new subtarget since any
|
|
|
|
// creation will depend on the TM and the code generation flags on the
|
|
|
|
// function that reside in TargetOptions.
|
|
|
|
resetTargetOptions(F);
|
|
|
|
I = llvm::make_unique<X86Subtarget>(TargetTriple, CPU, FS, *this,
|
|
|
|
Options.StackAlignmentOverride);
|
|
|
|
}
|
|
|
|
return I.get();
|
|
|
|
}
|
|
|
|
|
2011-08-23 09:14:17 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Command line options for x86
|
|
|
|
//===----------------------------------------------------------------------===//
|
2011-09-03 11:45:06 +08:00
|
|
|
static cl::opt<bool>
|
2013-10-19 07:38:13 +08:00
|
|
|
UseVZeroUpper("x86-use-vzeroupper", cl::Hidden,
|
2011-08-23 09:14:17 +08:00
|
|
|
cl::desc("Minimize AVX to SSE transition penalty"),
|
2011-11-17 08:21:52 +08:00
|
|
|
cl::init(true));
|
2011-08-23 09:14:17 +08:00
|
|
|
|
Switch TargetTransformInfo from an immutable analysis pass that requires
a TargetMachine to construct (and thus isn't always available), to an
analysis group that supports layered implementations much like
AliasAnalysis does. This is a pretty massive change, with a few parts
that I was unable to easily separate (sorry), so I'll walk through it.
The first step of this conversion was to make TargetTransformInfo an
analysis group, and to sink the nonce implementations in
ScalarTargetTransformInfo and VectorTargetTranformInfo into
a NoTargetTransformInfo pass. This allows other passes to add a hard
requirement on TTI, and assume they will always get at least on
implementation.
The TargetTransformInfo analysis group leverages the delegation chaining
trick that AliasAnalysis uses, where the base class for the analysis
group delegates to the previous analysis *pass*, allowing all but tho
NoFoo analysis passes to only implement the parts of the interfaces they
support. It also introduces a new trick where each pass in the group
retains a pointer to the top-most pass that has been initialized. This
allows passes to implement one API in terms of another API and benefit
when some other pass above them in the stack has more precise results
for the second API.
The second step of this conversion is to create a pass that implements
the TargetTransformInfo analysis using the target-independent
abstractions in the code generator. This replaces the
ScalarTargetTransformImpl and VectorTargetTransformImpl classes in
lib/Target with a single pass in lib/CodeGen called
BasicTargetTransformInfo. This class actually provides most of the TTI
functionality, basing it upon the TargetLowering abstraction and other
information in the target independent code generator.
The third step of the conversion adds support to all TargetMachines to
register custom analysis passes. This allows building those passes with
access to TargetLowering or other target-specific classes, and it also
allows each target to customize the set of analysis passes desired in
the pass manager. The baseline LLVMTargetMachine implements this
interface to add the BasicTTI pass to the pass manager, and all of the
tools that want to support target-aware TTI passes call this routine on
whatever target machine they end up with to add the appropriate passes.
The fourth step of the conversion created target-specific TTI analysis
passes for the X86 and ARM backends. These passes contain the custom
logic that was previously in their extensions of the
ScalarTargetTransformInfo and VectorTargetTransformInfo interfaces.
I separated them into their own file, as now all of the interface bits
are private and they just expose a function to create the pass itself.
Then I extended these target machines to set up a custom set of analysis
passes, first adding BasicTTI as a fallback, and then adding their
customized TTI implementations.
The fourth step required logic that was shared between the target
independent layer and the specific targets to move to a different
interface, as they no longer derive from each other. As a consequence,
a helper functions were added to TargetLowering representing the common
logic needed both in the target implementation and the codegen
implementation of the TTI pass. While technically this is the only
change that could have been committed separately, it would have been
a nightmare to extract.
The final step of the conversion was just to delete all the old
boilerplate. This got rid of the ScalarTargetTransformInfo and
VectorTargetTransformInfo classes, all of the support in all of the
targets for producing instances of them, and all of the support in the
tools for manually constructing a pass based around them.
Now that TTI is a relatively normal analysis group, two things become
straightforward. First, we can sink it into lib/Analysis which is a more
natural layer for it to live. Second, clients of this interface can
depend on it *always* being available which will simplify their code and
behavior. These (and other) simplifications will follow in subsequent
commits, this one is clearly big enough.
Finally, I'm very aware that much of the comments and documentation
needs to be updated. As soon as I had this working, and plausibly well
commented, I wanted to get it committed and in front of the build bots.
I'll be doing a few passes over documentation later if it sticks.
Commits to update DragonEgg and Clang will be made presently.
llvm-svn: 171681
2013-01-07 09:37:14 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2015-01-31 19:17:59 +08:00
|
|
|
// X86 TTI query.
|
Switch TargetTransformInfo from an immutable analysis pass that requires
a TargetMachine to construct (and thus isn't always available), to an
analysis group that supports layered implementations much like
AliasAnalysis does. This is a pretty massive change, with a few parts
that I was unable to easily separate (sorry), so I'll walk through it.
The first step of this conversion was to make TargetTransformInfo an
analysis group, and to sink the nonce implementations in
ScalarTargetTransformInfo and VectorTargetTranformInfo into
a NoTargetTransformInfo pass. This allows other passes to add a hard
requirement on TTI, and assume they will always get at least on
implementation.
The TargetTransformInfo analysis group leverages the delegation chaining
trick that AliasAnalysis uses, where the base class for the analysis
group delegates to the previous analysis *pass*, allowing all but tho
NoFoo analysis passes to only implement the parts of the interfaces they
support. It also introduces a new trick where each pass in the group
retains a pointer to the top-most pass that has been initialized. This
allows passes to implement one API in terms of another API and benefit
when some other pass above them in the stack has more precise results
for the second API.
The second step of this conversion is to create a pass that implements
the TargetTransformInfo analysis using the target-independent
abstractions in the code generator. This replaces the
ScalarTargetTransformImpl and VectorTargetTransformImpl classes in
lib/Target with a single pass in lib/CodeGen called
BasicTargetTransformInfo. This class actually provides most of the TTI
functionality, basing it upon the TargetLowering abstraction and other
information in the target independent code generator.
The third step of the conversion adds support to all TargetMachines to
register custom analysis passes. This allows building those passes with
access to TargetLowering or other target-specific classes, and it also
allows each target to customize the set of analysis passes desired in
the pass manager. The baseline LLVMTargetMachine implements this
interface to add the BasicTTI pass to the pass manager, and all of the
tools that want to support target-aware TTI passes call this routine on
whatever target machine they end up with to add the appropriate passes.
The fourth step of the conversion created target-specific TTI analysis
passes for the X86 and ARM backends. These passes contain the custom
logic that was previously in their extensions of the
ScalarTargetTransformInfo and VectorTargetTransformInfo interfaces.
I separated them into their own file, as now all of the interface bits
are private and they just expose a function to create the pass itself.
Then I extended these target machines to set up a custom set of analysis
passes, first adding BasicTTI as a fallback, and then adding their
customized TTI implementations.
The fourth step required logic that was shared between the target
independent layer and the specific targets to move to a different
interface, as they no longer derive from each other. As a consequence,
a helper functions were added to TargetLowering representing the common
logic needed both in the target implementation and the codegen
implementation of the TTI pass. While technically this is the only
change that could have been committed separately, it would have been
a nightmare to extract.
The final step of the conversion was just to delete all the old
boilerplate. This got rid of the ScalarTargetTransformInfo and
VectorTargetTransformInfo classes, all of the support in all of the
targets for producing instances of them, and all of the support in the
tools for manually constructing a pass based around them.
Now that TTI is a relatively normal analysis group, two things become
straightforward. First, we can sink it into lib/Analysis which is a more
natural layer for it to live. Second, clients of this interface can
depend on it *always* being available which will simplify their code and
behavior. These (and other) simplifications will follow in subsequent
commits, this one is clearly big enough.
Finally, I'm very aware that much of the comments and documentation
needs to be updated. As soon as I had this working, and plausibly well
commented, I wanted to get it committed and in front of the build bots.
I'll be doing a few passes over documentation later if it sticks.
Commits to update DragonEgg and Clang will be made presently.
llvm-svn: 171681
2013-01-07 09:37:14 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-02-01 21:20:00 +08:00
|
|
|
TargetIRAnalysis X86TargetMachine::getTargetIRAnalysis() {
|
|
|
|
return TargetIRAnalysis(
|
|
|
|
[this](Function &F) { return TargetTransformInfo(X86TTIImpl(this, F)); });
|
Switch TargetTransformInfo from an immutable analysis pass that requires
a TargetMachine to construct (and thus isn't always available), to an
analysis group that supports layered implementations much like
AliasAnalysis does. This is a pretty massive change, with a few parts
that I was unable to easily separate (sorry), so I'll walk through it.
The first step of this conversion was to make TargetTransformInfo an
analysis group, and to sink the nonce implementations in
ScalarTargetTransformInfo and VectorTargetTranformInfo into
a NoTargetTransformInfo pass. This allows other passes to add a hard
requirement on TTI, and assume they will always get at least on
implementation.
The TargetTransformInfo analysis group leverages the delegation chaining
trick that AliasAnalysis uses, where the base class for the analysis
group delegates to the previous analysis *pass*, allowing all but tho
NoFoo analysis passes to only implement the parts of the interfaces they
support. It also introduces a new trick where each pass in the group
retains a pointer to the top-most pass that has been initialized. This
allows passes to implement one API in terms of another API and benefit
when some other pass above them in the stack has more precise results
for the second API.
The second step of this conversion is to create a pass that implements
the TargetTransformInfo analysis using the target-independent
abstractions in the code generator. This replaces the
ScalarTargetTransformImpl and VectorTargetTransformImpl classes in
lib/Target with a single pass in lib/CodeGen called
BasicTargetTransformInfo. This class actually provides most of the TTI
functionality, basing it upon the TargetLowering abstraction and other
information in the target independent code generator.
The third step of the conversion adds support to all TargetMachines to
register custom analysis passes. This allows building those passes with
access to TargetLowering or other target-specific classes, and it also
allows each target to customize the set of analysis passes desired in
the pass manager. The baseline LLVMTargetMachine implements this
interface to add the BasicTTI pass to the pass manager, and all of the
tools that want to support target-aware TTI passes call this routine on
whatever target machine they end up with to add the appropriate passes.
The fourth step of the conversion created target-specific TTI analysis
passes for the X86 and ARM backends. These passes contain the custom
logic that was previously in their extensions of the
ScalarTargetTransformInfo and VectorTargetTransformInfo interfaces.
I separated them into their own file, as now all of the interface bits
are private and they just expose a function to create the pass itself.
Then I extended these target machines to set up a custom set of analysis
passes, first adding BasicTTI as a fallback, and then adding their
customized TTI implementations.
The fourth step required logic that was shared between the target
independent layer and the specific targets to move to a different
interface, as they no longer derive from each other. As a consequence,
a helper functions were added to TargetLowering representing the common
logic needed both in the target implementation and the codegen
implementation of the TTI pass. While technically this is the only
change that could have been committed separately, it would have been
a nightmare to extract.
The final step of the conversion was just to delete all the old
boilerplate. This got rid of the ScalarTargetTransformInfo and
VectorTargetTransformInfo classes, all of the support in all of the
targets for producing instances of them, and all of the support in the
tools for manually constructing a pass based around them.
Now that TTI is a relatively normal analysis group, two things become
straightforward. First, we can sink it into lib/Analysis which is a more
natural layer for it to live. Second, clients of this interface can
depend on it *always* being available which will simplify their code and
behavior. These (and other) simplifications will follow in subsequent
commits, this one is clearly big enough.
Finally, I'm very aware that much of the comments and documentation
needs to be updated. As soon as I had this working, and plausibly well
commented, I wanted to get it committed and in front of the build bots.
I'll be doing a few passes over documentation later if it sticks.
Commits to update DragonEgg and Clang will be made presently.
llvm-svn: 171681
2013-01-07 09:37:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-04 12:14:57 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pass Pipeline Configuration
|
|
|
|
//===----------------------------------------------------------------------===//
|
2003-08-06 00:34:44 +08:00
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
namespace {
|
|
|
|
/// X86 Code Generator Pass Configuration Options.
|
|
|
|
class X86PassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2012-02-04 10:56:59 +08:00
|
|
|
X86PassConfig(X86TargetMachine *TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
2012-02-03 13:12:41 +08:00
|
|
|
|
|
|
|
X86TargetMachine &getX86TargetMachine() const {
|
|
|
|
return getTM<X86TargetMachine>();
|
|
|
|
}
|
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
void addIRPasses() override;
|
2014-03-09 15:44:38 +08:00
|
|
|
bool addInstSelector() override;
|
|
|
|
bool addILPOpts() override;
|
2015-05-06 01:44:16 +08:00
|
|
|
bool addPreISel() override;
|
2015-02-02 00:56:04 +08:00
|
|
|
void addPreRegAlloc() override;
|
2014-12-12 05:26:47 +08:00
|
|
|
void addPostRegAlloc() override;
|
|
|
|
void addPreEmitPass() override;
|
2015-05-23 02:10:47 +08:00
|
|
|
void addPreSched2() override;
|
2012-02-03 13:12:41 +08:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 10:56:59 +08:00
|
|
|
TargetPassConfig *X86TargetMachine::createPassConfig(PassManagerBase &PM) {
|
2013-01-17 08:58:38 +08:00
|
|
|
return new X86PassConfig(this, PM);
|
2012-02-03 13:12:41 +08:00
|
|
|
}
|
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
void X86PassConfig::addIRPasses() {
|
2014-09-17 08:06:58 +08:00
|
|
|
addPass(createAtomicExpandPass(&getX86TargetMachine()));
|
2014-07-02 02:53:31 +08:00
|
|
|
|
|
|
|
TargetPassConfig::addIRPasses();
|
|
|
|
}
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
bool X86PassConfig::addInstSelector() {
|
2005-08-19 07:53:15 +08:00
|
|
|
// Install an instruction selector.
|
2012-07-03 03:48:31 +08:00
|
|
|
addPass(createX86ISelDag(getX86TargetMachine(), getOptLevel()));
|
2008-10-26 01:46:52 +08:00
|
|
|
|
2012-06-02 00:27:21 +08:00
|
|
|
// For ELF, cleanup any local-dynamic TLS accesses.
|
2015-02-06 03:27:04 +08:00
|
|
|
if (Triple(TM->getTargetTriple()).isOSBinFormatELF() &&
|
|
|
|
getOptLevel() != CodeGenOpt::None)
|
2012-07-03 03:48:31 +08:00
|
|
|
addPass(createCleanupLocalDynamicTLSPass());
|
2012-06-02 00:27:21 +08:00
|
|
|
|
2014-05-22 09:46:02 +08:00
|
|
|
addPass(createX86GlobalBaseRegPass());
|
2010-07-10 17:00:22 +08:00
|
|
|
|
2006-09-04 12:14:57 +08:00
|
|
|
return false;
|
2013-01-17 08:58:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool X86PassConfig::addILPOpts() {
|
2014-05-22 07:40:26 +08:00
|
|
|
addPass(&EarlyIfConverterID);
|
|
|
|
return true;
|
2003-06-19 05:43:21 +08:00
|
|
|
}
|
|
|
|
|
2015-05-06 01:44:16 +08:00
|
|
|
bool X86PassConfig::addPreISel() {
|
2015-05-30 04:43:10 +08:00
|
|
|
// Only add this pass for 32-bit x86 Windows.
|
2015-05-06 01:44:16 +08:00
|
|
|
Triple TT(TM->getTargetTriple());
|
2015-05-30 04:43:10 +08:00
|
|
|
if (TT.isOSWindows() && TT.getArch() == Triple::x86)
|
2015-05-06 01:44:16 +08:00
|
|
|
addPass(createX86WinEHStatePass());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-02 00:56:04 +08:00
|
|
|
void X86PassConfig::addPreRegAlloc() {
|
|
|
|
addPass(createX86CallFrameOptimization());
|
|
|
|
}
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
void X86PassConfig::addPostRegAlloc() {
|
2012-07-03 03:48:31 +08:00
|
|
|
addPass(createX86FloatingPointStackifierPass());
|
2006-09-04 12:14:57 +08:00
|
|
|
}
|
2003-01-13 08:51:23 +08:00
|
|
|
|
2015-05-23 02:10:47 +08:00
|
|
|
void X86PassConfig::addPreSched2() { addPass(createX86ExpandPseudoPass()); }
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
void X86PassConfig::addPreEmitPass() {
|
2015-02-06 03:27:04 +08:00
|
|
|
if (getOptLevel() != CodeGenOpt::None)
|
2014-12-12 07:18:03 +08:00
|
|
|
addPass(createExecutionDependencyFixPass(&X86::VR128RegClass));
|
2011-08-23 09:14:17 +08:00
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
if (UseVZeroUpper)
|
2014-12-12 07:18:03 +08:00
|
|
|
addPass(createX86IssueVZeroUpperPass());
|
2011-09-16 02:27:32 +08:00
|
|
|
|
2014-05-22 09:46:02 +08:00
|
|
|
if (getOptLevel() != CodeGenOpt::None) {
|
2014-12-12 07:18:03 +08:00
|
|
|
addPass(createX86PadShortFunctions());
|
2013-04-26 04:29:37 +08:00
|
|
|
addPass(createX86FixupLEAs());
|
|
|
|
}
|
2010-03-26 01:25:00 +08:00
|
|
|
}
|