2002-10-29 23:37:54 +01:00
|
|
|
//===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
|
2005-04-22 01:38:14 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 01:38:14 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-22 01:38:14 +02:00
|
|
|
//
|
2002-10-29 23:37:54 +01:00
|
|
|
// This file defines the X86 specific subclass of TargetMachine.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "X86TargetMachine.h"
|
2002-12-24 01:04:01 +01:00
|
|
|
#include "X86.h"
|
2002-10-30 01:47:49 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2003-01-13 01:51:23 +01:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2012-12-03 17:50:05 +01:00
|
|
|
#include "llvm/PassManager.h"
|
2011-08-23 03:14:17 +02:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2009-07-14 22:18:05 +02:00
|
|
|
#include "llvm/Support/FormattedStream.h"
|
2011-08-24 20:08:43 +02:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2012-12-03 17:50:05 +01:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2003-12-20 02:22:19 +01:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2011-02-17 13:23:50 +01:00
|
|
|
extern "C" void LLVMInitializeX86Target() {
|
2009-07-25 08:49:55 +02:00
|
|
|
// Register the target.
|
|
|
|
RegisterTargetMachine<X86_32TargetMachine> X(TheX86_32Target);
|
|
|
|
RegisterTargetMachine<X86_64TargetMachine> Y(TheX86_64Target);
|
2006-09-08 01:39:26 +02:00
|
|
|
}
|
2006-09-08 08:48:29 +02:00
|
|
|
|
2011-12-20 03:50:00 +01:00
|
|
|
void X86_32TargetMachine::anchor() { }
|
2009-08-12 09:22:17 +02:00
|
|
|
|
2011-07-19 08:37:02 +02:00
|
|
|
X86_32TargetMachine::X86_32TargetMachine(const Target &T, StringRef TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
2011-12-02 23:16:29 +01:00
|
|
|
const TargetOptions &Options,
|
2011-11-16 09:38:26 +01:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL)
|
2011-12-02 23:16:29 +01:00
|
|
|
: X86TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false),
|
2012-10-08 18:38:25 +02:00
|
|
|
DL(getSubtargetImpl()->isTargetDarwin() ?
|
2011-10-14 22:36:23 +02:00
|
|
|
"e-p:32:32-f64:32:64-i64:32:64-f80:128:128-f128:128:128-"
|
|
|
|
"n8:16:32-S128" :
|
2010-10-03 20:59:45 +02:00
|
|
|
(getSubtargetImpl()->isTargetCygMing() ||
|
|
|
|
getSubtargetImpl()->isTargetWindows()) ?
|
2011-10-14 22:36:23 +02:00
|
|
|
"e-p:32:32-f64:64:64-i64:64:64-f80:32:32-f128:128:128-"
|
|
|
|
"n8:16:32-S32" :
|
|
|
|
"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-f128:128:128-"
|
|
|
|
"n8:16:32-S128"),
|
2010-10-03 20:59:45 +02:00
|
|
|
InstrInfo(*this),
|
|
|
|
TLInfo(*this),
|
2012-12-20 05:04:17 +01:00
|
|
|
TSInfo(*this),
|
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 02:37:14 +01:00
|
|
|
JITInfo(*this) {
|
2013-05-13 03:16:13 +02:00
|
|
|
initAsmInfo();
|
2006-09-08 08:48:29 +02:00
|
|
|
}
|
|
|
|
|
2011-12-20 03:50:00 +01:00
|
|
|
void X86_64TargetMachine::anchor() { }
|
2006-09-08 08:48:29 +02:00
|
|
|
|
2011-07-19 08:37:02 +02:00
|
|
|
X86_64TargetMachine::X86_64TargetMachine(const Target &T, StringRef TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
2011-12-02 23:16:29 +01:00
|
|
|
const TargetOptions &Options,
|
2011-11-16 09:38:26 +01:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL)
|
2011-12-02 23:16:29 +01:00
|
|
|
: X86TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true),
|
2013-01-25 23:07:43 +01:00
|
|
|
// The x32 ABI dictates the ILP32 programming model for x64.
|
|
|
|
DL(getSubtargetImpl()->isTarget64BitILP32() ?
|
|
|
|
"e-p:32:32-s:64-f64:64:64-i64:64:64-f80:128:128-f128:128:128-"
|
|
|
|
"n8:16:32:64-S128" :
|
|
|
|
"e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128-f128:128:128-"
|
|
|
|
"n8:16:32:64-S128"),
|
2010-10-03 20:59:45 +02:00
|
|
|
InstrInfo(*this),
|
|
|
|
TLInfo(*this),
|
2012-12-20 05:04:17 +01:00
|
|
|
TSInfo(*this),
|
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 02:37:14 +01:00
|
|
|
JITInfo(*this) {
|
2013-05-13 03:16:13 +02:00
|
|
|
initAsmInfo();
|
2006-09-08 08:48:29 +02:00
|
|
|
}
|
|
|
|
|
2009-07-09 05:32:31 +02:00
|
|
|
/// X86TargetMachine ctor - Create an X86 target.
|
2002-10-29 23:37:54 +01:00
|
|
|
///
|
2011-07-19 08:37:02 +02:00
|
|
|
X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
2011-12-02 23:16:29 +01:00
|
|
|
const TargetOptions &Options,
|
2011-07-20 09:51:56 +02:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
2011-11-16 09:38:26 +01:00
|
|
|
CodeGenOpt::Level OL,
|
2011-07-20 09:51:56 +02:00
|
|
|
bool is64Bit)
|
2011-12-02 23:16:29 +01:00
|
|
|
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
|
|
|
Subtarget(TT, CPU, FS, Options.StackAlignmentOverride, is64Bit),
|
2011-01-10 13:39:04 +01:00
|
|
|
FrameLowering(*this, Subtarget),
|
2012-02-02 00:20:51 +01:00
|
|
|
InstrItins(Subtarget.getInstrItineraryData()){
|
2009-07-09 05:32:31 +02:00
|
|
|
// Determine the PICStyle based on the target selected.
|
|
|
|
if (getRelocationModel() == Reloc::Static) {
|
|
|
|
// Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.
|
|
|
|
Subtarget.setPICStyle(PICStyles::None);
|
2010-08-21 19:21:11 +02:00
|
|
|
} else if (Subtarget.is64Bit()) {
|
|
|
|
// PIC in 64 bit mode is always rip-rel.
|
|
|
|
Subtarget.setPICStyle(PICStyles::RIPRel);
|
2013-08-21 04:37:25 +02:00
|
|
|
} else if (Subtarget.isTargetCOFF()) {
|
2009-07-09 05:15:51 +02:00
|
|
|
Subtarget.setPICStyle(PICStyles::None);
|
|
|
|
} else if (Subtarget.isTargetDarwin()) {
|
2010-08-21 19:21:11 +02:00
|
|
|
if (getRelocationModel() == Reloc::PIC_)
|
2009-07-10 22:58:47 +02:00
|
|
|
Subtarget.setPICStyle(PICStyles::StubPIC);
|
|
|
|
else {
|
|
|
|
assert(getRelocationModel() == Reloc::DynamicNoPIC);
|
|
|
|
Subtarget.setPICStyle(PICStyles::StubDynamicNoPIC);
|
|
|
|
}
|
2008-02-20 12:22:39 +01:00
|
|
|
} else if (Subtarget.isTargetELF()) {
|
2010-08-21 19:21:11 +02:00
|
|
|
Subtarget.setPICStyle(PICStyles::GOT);
|
2008-02-20 12:22:39 +01:00
|
|
|
}
|
2010-08-21 19:21:11 +02:00
|
|
|
|
2011-06-23 19:54:54 +02:00
|
|
|
// default to hard float ABI
|
2011-12-02 23:16:29 +01:00
|
|
|
if (Options.FloatABIType == FloatABI::Default)
|
2012-02-03 06:12:30 +01:00
|
|
|
this->Options.FloatABIType = FloatABI::Hard;
|
2006-02-03 19:59:39 +01:00
|
|
|
}
|
2002-10-29 23:37:54 +01:00
|
|
|
|
2011-08-23 03:14:17 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Command line options for x86
|
|
|
|
//===----------------------------------------------------------------------===//
|
2011-09-03 05:45:06 +02:00
|
|
|
static cl::opt<bool>
|
|
|
|
UseVZeroUpper("x86-use-vzeroupper",
|
2011-08-23 03:14:17 +02:00
|
|
|
cl::desc("Minimize AVX to SSE transition penalty"),
|
2011-11-17 01:21:52 +01:00
|
|
|
cl::init(true));
|
2011-08-23 03:14:17 +02:00
|
|
|
|
2012-10-03 02:51:32 +02:00
|
|
|
// Temporary option to control early if-conversion for x86 while adding machine
|
|
|
|
// models.
|
|
|
|
static cl::opt<bool>
|
|
|
|
X86EarlyIfConv("x86-early-ifcvt",
|
|
|
|
cl::desc("Enable early if-conversion on X86"));
|
|
|
|
|
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 02:37:14 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// X86 Analysis Pass Setup
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void X86TargetMachine::addAnalysisPasses(PassManagerBase &PM) {
|
|
|
|
// Add first the target-independent BasicTTI pass, then our X86 pass. This
|
|
|
|
// allows the X86 pass to delegate to the target independent layer when
|
|
|
|
// appropriate.
|
2013-06-19 22:51:24 +02:00
|
|
|
PM.add(createBasicTargetTransformInfoPass(this));
|
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 02:37:14 +01:00
|
|
|
PM.add(createX86TargetTransformInfoPass(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-04 06:14:57 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pass Pipeline Configuration
|
|
|
|
//===----------------------------------------------------------------------===//
|
2003-08-05 18:34:44 +02:00
|
|
|
|
2012-02-03 06:12:41 +01:00
|
|
|
namespace {
|
|
|
|
/// X86 Code Generator Pass Configuration Options.
|
|
|
|
class X86PassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2012-02-04 03:56:59 +01:00
|
|
|
X86PassConfig(X86TargetMachine *TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
2012-02-03 06:12:41 +01:00
|
|
|
|
|
|
|
X86TargetMachine &getX86TargetMachine() const {
|
|
|
|
return getTM<X86TargetMachine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
const X86Subtarget &getX86Subtarget() const {
|
|
|
|
return *getX86TargetMachine().getSubtargetImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool addInstSelector();
|
2013-01-17 01:58:38 +01:00
|
|
|
virtual bool addILPOpts();
|
2012-02-03 06:12:41 +01:00
|
|
|
virtual bool addPreRegAlloc();
|
|
|
|
virtual bool addPostRegAlloc();
|
|
|
|
virtual bool addPreEmitPass();
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 03:56:59 +01:00
|
|
|
TargetPassConfig *X86TargetMachine::createPassConfig(PassManagerBase &PM) {
|
2013-01-17 01:58:38 +01:00
|
|
|
return new X86PassConfig(this, PM);
|
2012-02-03 06:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool X86PassConfig::addInstSelector() {
|
2005-08-19 01:53:15 +02:00
|
|
|
// Install an instruction selector.
|
2012-07-02 21:48:31 +02:00
|
|
|
addPass(createX86ISelDag(getX86TargetMachine(), getOptLevel()));
|
2008-10-25 19:46:52 +02:00
|
|
|
|
2012-06-01 18:27:21 +02:00
|
|
|
// For ELF, cleanup any local-dynamic TLS accesses.
|
|
|
|
if (getX86Subtarget().isTargetELF() && getOptLevel() != CodeGenOpt::None)
|
2012-07-02 21:48:31 +02:00
|
|
|
addPass(createCleanupLocalDynamicTLSPass());
|
2012-06-01 18:27:21 +02:00
|
|
|
|
2010-07-10 11:00:22 +02:00
|
|
|
// For 32-bit, prepend instructions to set the "global base reg" for PIC.
|
2012-02-03 06:12:41 +01:00
|
|
|
if (!getX86Subtarget().is64Bit())
|
2012-07-02 21:48:31 +02:00
|
|
|
addPass(createGlobalBaseRegPass());
|
2010-07-10 11:00:22 +02:00
|
|
|
|
2006-09-04 06:14:57 +02:00
|
|
|
return false;
|
2013-01-17 01:58:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool X86PassConfig::addILPOpts() {
|
|
|
|
if (X86EarlyIfConv && getX86Subtarget().hasCMov()) {
|
|
|
|
addPass(&EarlyIfConverterID);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2003-06-18 23:43:21 +02:00
|
|
|
}
|
|
|
|
|
2012-02-03 06:12:41 +01:00
|
|
|
bool X86PassConfig::addPreRegAlloc() {
|
2008-04-23 20:23:05 +02:00
|
|
|
return false; // -print-machineinstr shouldn't print after this.
|
|
|
|
}
|
|
|
|
|
2012-02-03 06:12:41 +01:00
|
|
|
bool X86PassConfig::addPostRegAlloc() {
|
2012-07-02 21:48:31 +02:00
|
|
|
addPass(createX86FloatingPointStackifierPass());
|
2006-09-04 06:14:57 +02:00
|
|
|
return true; // -print-machineinstr should print after this.
|
|
|
|
}
|
2003-01-13 01:51:23 +01:00
|
|
|
|
2012-02-03 06:12:41 +01:00
|
|
|
bool X86PassConfig::addPreEmitPass() {
|
2011-09-15 20:27:32 +02:00
|
|
|
bool ShouldPrint = false;
|
2012-02-03 06:12:41 +01:00
|
|
|
if (getOptLevel() != CodeGenOpt::None && getX86Subtarget().hasSSE2()) {
|
2012-07-02 21:48:31 +02:00
|
|
|
addPass(createExecutionDependencyFixPass(&X86::VR128RegClass));
|
2011-11-16 06:02:04 +01:00
|
|
|
ShouldPrint = true;
|
2010-03-25 18:25:00 +01:00
|
|
|
}
|
2011-08-23 03:14:17 +02:00
|
|
|
|
2012-02-03 06:12:41 +01:00
|
|
|
if (getX86Subtarget().hasAVX() && UseVZeroUpper) {
|
2012-07-02 21:48:31 +02:00
|
|
|
addPass(createX86IssueVZeroUpperPass());
|
2011-09-15 20:27:32 +02:00
|
|
|
ShouldPrint = true;
|
2011-08-23 03:14:17 +02:00
|
|
|
}
|
2011-09-15 20:27:32 +02:00
|
|
|
|
2013-01-08 19:27:24 +01:00
|
|
|
if (getOptLevel() != CodeGenOpt::None &&
|
|
|
|
getX86Subtarget().padShortFunctions()) {
|
|
|
|
addPass(createX86PadShortFunctions());
|
|
|
|
ShouldPrint = true;
|
|
|
|
}
|
2013-04-25 22:29:37 +02:00
|
|
|
if (getOptLevel() != CodeGenOpt::None &&
|
|
|
|
getX86Subtarget().LEAusesAG()){
|
|
|
|
addPass(createX86FixupLEAs());
|
|
|
|
ShouldPrint = true;
|
|
|
|
}
|
2013-01-08 19:27:24 +01:00
|
|
|
|
2011-09-15 20:27:32 +02:00
|
|
|
return ShouldPrint;
|
2010-03-25 18:25:00 +01:00
|
|
|
}
|
|
|
|
|
2009-05-30 22:51:52 +02:00
|
|
|
bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
|
2009-06-01 21:57:37 +02:00
|
|
|
JITCodeEmitter &JCE) {
|
2009-05-30 22:51:52 +02:00
|
|
|
PM.add(createX86JITCodeEmitterPass(*this, JCE));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|