2003-09-30 18:37:50 +00:00
|
|
|
//===-- llvm/Target/TargetMachine.h - Target Information --------*- C++ -*-===//
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-09-18 12:38:31 +00:00
|
|
|
//
|
2006-09-04 04:14:57 +00:00
|
|
|
// This file defines the TargetMachine and LLVMTargetMachine classes.
|
2001-09-18 12:38:31 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_TARGETMACHINE_H
|
|
|
|
#define LLVM_TARGET_TARGETMACHINE_H
|
|
|
|
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2012-07-02 19:48:45 +00:00
|
|
|
#include "llvm/Pass.h"
|
2012-03-25 18:09:44 +00:00
|
|
|
#include "llvm/Support/CodeGen.h"
|
2011-12-02 22:16:29 +00:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2003-10-20 15:14:33 +00:00
|
|
|
#include <cassert>
|
2009-08-11 20:42:37 +00:00
|
|
|
#include <string>
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2011-06-29 01:14:12 +00:00
|
|
|
class InstrItineraryData;
|
2012-04-08 17:20:55 +00:00
|
|
|
class GlobalValue;
|
2014-02-19 20:30:41 +00:00
|
|
|
class Mangler;
|
2009-08-22 20:48:53 +00:00
|
|
|
class MCAsmInfo;
|
2011-07-19 06:37:02 +00:00
|
|
|
class MCCodeGenInfo;
|
2011-06-29 01:14:12 +00:00
|
|
|
class MCContext;
|
2014-02-19 20:30:41 +00:00
|
|
|
class MCSymbol;
|
2011-06-29 01:14:12 +00:00
|
|
|
class Target;
|
2012-10-08 16:38:25 +00:00
|
|
|
class DataLayout;
|
2013-04-22 22:47:22 +00:00
|
|
|
class TargetLibraryInfo;
|
2011-06-29 01:14:12 +00:00
|
|
|
class TargetFrameLowering;
|
2009-02-05 01:49:45 +00:00
|
|
|
class TargetIntrinsicInfo;
|
2006-03-13 23:17:42 +00:00
|
|
|
class TargetLowering;
|
2012-02-03 05:12:41 +00:00
|
|
|
class TargetPassConfig;
|
2008-02-10 18:45:23 +00:00
|
|
|
class TargetRegisterInfo;
|
2011-06-29 01:14:12 +00:00
|
|
|
class TargetSelectionDAGInfo;
|
2011-07-01 21:01:15 +00:00
|
|
|
class TargetSubtargetInfo;
|
2012-12-11 05:53:43 +00:00
|
|
|
class ScalarTargetTransformInfo;
|
|
|
|
class VectorTargetTransformInfo;
|
2009-07-14 20:18:05 +00:00
|
|
|
class formatted_raw_ostream;
|
2011-03-18 22:48:41 +00:00
|
|
|
class raw_ostream;
|
2014-11-13 09:26:31 +00:00
|
|
|
class TargetLoweringObjectFile;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2013-11-09 12:26:54 +00:00
|
|
|
// The old pass manager infrastructure is hidden in a legacy namespace now.
|
|
|
|
namespace legacy {
|
|
|
|
class PassManagerBase;
|
|
|
|
}
|
|
|
|
using legacy::PassManagerBase;
|
|
|
|
|
2002-12-28 20:13:29 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// TargetMachine - Primary interface to the complete machine description for
|
|
|
|
/// the target machine. All target-specific information should be accessible
|
|
|
|
/// through this interface.
|
2005-04-21 20:59:05 +00:00
|
|
|
///
|
2003-06-03 15:28:40 +00:00
|
|
|
class TargetMachine {
|
2012-09-17 06:59:23 +00:00
|
|
|
TargetMachine(const TargetMachine &) LLVM_DELETED_FUNCTION;
|
|
|
|
void operator=(const TargetMachine &) LLVM_DELETED_FUNCTION;
|
2006-09-03 18:44:26 +00:00
|
|
|
protected: // Can only create subclasses.
|
2011-07-08 01:53:10 +00:00
|
|
|
TargetMachine(const Target &T, StringRef TargetTriple,
|
2011-12-02 22:16:29 +00:00
|
|
|
StringRef CPU, StringRef FS, const TargetOptions &Options);
|
2005-07-12 03:04:49 +00:00
|
|
|
|
2009-07-15 20:24:03 +00:00
|
|
|
/// TheTarget - The Target that this machine was created for.
|
|
|
|
const Target &TheTarget;
|
2010-10-16 08:25:21 +00:00
|
|
|
|
2011-07-08 01:53:10 +00:00
|
|
|
/// TargetTriple, TargetCPU, TargetFS - Triple string, CPU name, and target
|
|
|
|
/// feature strings the TargetMachine instance is created with.
|
|
|
|
std::string TargetTriple;
|
|
|
|
std::string TargetCPU;
|
|
|
|
std::string TargetFS;
|
|
|
|
|
2011-07-19 06:37:02 +00:00
|
|
|
/// CodeGenInfo - Low level target information such as relocation model.
|
2013-11-22 19:11:24 +00:00
|
|
|
/// Non-const to allow resetting optimization level per-function.
|
|
|
|
MCCodeGenInfo *CodeGenInfo;
|
2011-07-19 06:37:02 +00:00
|
|
|
|
2006-09-07 22:06:40 +00:00
|
|
|
/// AsmInfo - Contains target specific asm information.
|
|
|
|
///
|
2009-08-22 20:48:53 +00:00
|
|
|
const MCAsmInfo *AsmInfo;
|
2010-05-26 21:48:55 +00:00
|
|
|
|
2013-12-07 01:49:19 +00:00
|
|
|
unsigned RequireStructuredCFG : 1;
|
2010-05-26 21:48:55 +00:00
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
public:
|
2014-08-04 21:25:44 +00:00
|
|
|
mutable TargetOptions Options;
|
|
|
|
|
2003-12-28 21:23:38 +00:00
|
|
|
virtual ~TargetMachine();
|
2002-10-29 21:12:46 +00:00
|
|
|
|
2009-07-15 20:24:03 +00:00
|
|
|
const Target &getTarget() const { return TheTarget; }
|
2009-07-15 12:11:05 +00:00
|
|
|
|
2014-08-30 16:48:02 +00:00
|
|
|
StringRef getTargetTriple() const { return TargetTriple; }
|
|
|
|
StringRef getTargetCPU() const { return TargetCPU; }
|
|
|
|
StringRef getTargetFeatureString() const { return TargetFS; }
|
2011-07-08 01:53:10 +00:00
|
|
|
|
2013-01-09 16:21:47 +00:00
|
|
|
/// getSubtargetImpl - virtual method implemented by subclasses that returns
|
|
|
|
/// a reference to that target's TargetSubtargetInfo-derived member variable.
|
2014-04-14 00:51:57 +00:00
|
|
|
virtual const TargetSubtargetInfo *getSubtargetImpl() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-09-26 02:57:05 +00:00
|
|
|
virtual const TargetSubtargetInfo *getSubtargetImpl(const Function &) const {
|
2014-09-18 00:34:14 +00:00
|
|
|
return getSubtargetImpl();
|
|
|
|
}
|
2014-11-13 09:26:31 +00:00
|
|
|
virtual TargetLoweringObjectFile *getObjFileLowering() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-01-09 16:21:47 +00:00
|
|
|
|
2014-08-04 21:25:44 +00:00
|
|
|
/// getSubtarget - This method returns a pointer to the specified type of
|
|
|
|
/// TargetSubtargetInfo. In debug builds, it verifies that the object being
|
|
|
|
/// returned is of the correct type.
|
|
|
|
template<typename STC> const STC &getSubtarget() const {
|
|
|
|
return *static_cast<const STC*>(getSubtargetImpl());
|
|
|
|
}
|
2014-09-18 00:34:14 +00:00
|
|
|
template <typename STC> const STC &getSubtarget(const Function *) const {
|
|
|
|
return *static_cast<const STC*>(getSubtargetImpl());
|
|
|
|
}
|
2013-03-13 22:26:59 +00:00
|
|
|
|
|
|
|
/// \brief Reset the target options based on the function's attributes.
|
2014-09-26 01:44:05 +00:00
|
|
|
// FIXME: Remove TargetOptions that affect per-function code generation
|
|
|
|
// from TargetMachine.
|
2014-09-26 01:28:10 +00:00
|
|
|
void resetTargetOptions(const Function &F) const;
|
2011-12-02 22:16:29 +00:00
|
|
|
|
2009-08-22 20:48:53 +00:00
|
|
|
/// getMCAsmInfo - Return target specific asm information.
|
2006-09-07 22:06:40 +00:00
|
|
|
///
|
2009-08-22 20:48:53 +00:00
|
|
|
const MCAsmInfo *getMCAsmInfo() const { return AsmInfo; }
|
2010-10-16 08:25:21 +00:00
|
|
|
|
2009-02-05 01:49:45 +00:00
|
|
|
/// getIntrinsicInfo - If intrinsic information is available, return it. If
|
|
|
|
/// not, return null.
|
|
|
|
///
|
2014-08-04 21:25:23 +00:00
|
|
|
virtual const TargetIntrinsicInfo *getIntrinsicInfo() const {
|
2014-04-14 00:51:57 +00:00
|
|
|
return nullptr;
|
2005-11-01 20:06:59 +00:00
|
|
|
}
|
2003-12-20 01:22:19 +00:00
|
|
|
|
2013-12-07 01:49:19 +00:00
|
|
|
bool requiresStructuredCFG() const { return RequireStructuredCFG; }
|
|
|
|
void setRequiresStructuredCFG(bool Value) { RequireStructuredCFG = Value; }
|
|
|
|
|
2006-02-22 20:19:42 +00:00
|
|
|
/// getRelocationModel - Returns the code generation relocation model. The
|
|
|
|
/// choices are static, PIC, and dynamic-no-pic, and target default.
|
2011-07-19 06:37:02 +00:00
|
|
|
Reloc::Model getRelocationModel() const;
|
2006-02-22 20:19:42 +00:00
|
|
|
|
2006-07-06 01:53:36 +00:00
|
|
|
/// getCodeModel - Returns the code model. The choices are small, kernel,
|
|
|
|
/// medium, large, and target default.
|
2011-07-20 07:51:56 +00:00
|
|
|
CodeModel::Model getCodeModel() const;
|
2006-07-06 01:53:36 +00:00
|
|
|
|
2012-04-08 17:20:55 +00:00
|
|
|
/// getTLSModel - Returns the TLS model which should be used for the given
|
|
|
|
/// global variable.
|
|
|
|
TLSModel::Model getTLSModel(const GlobalValue *GV) const;
|
|
|
|
|
2011-11-16 08:38:26 +00:00
|
|
|
/// getOptLevel - Returns the optimization level: None, Less,
|
|
|
|
/// Default, or Aggressive.
|
|
|
|
CodeGenOpt::Level getOptLevel() const;
|
|
|
|
|
2013-11-22 19:11:24 +00:00
|
|
|
/// \brief Overrides the optimization level.
|
|
|
|
void setOptLevel(CodeGenOpt::Level Level) const;
|
|
|
|
|
2012-02-03 05:12:41 +00:00
|
|
|
void setFastISel(bool Enable) { Options.EnableFastISel = Enable; }
|
|
|
|
|
|
|
|
bool shouldPrintMachineCode() const { return Options.PrintMachineCode; }
|
|
|
|
|
2009-03-25 01:47:28 +00:00
|
|
|
/// getAsmVerbosityDefault - Returns the default value of asm verbosity.
|
|
|
|
///
|
2014-05-20 23:59:50 +00:00
|
|
|
bool getAsmVerbosityDefault() const ;
|
2009-03-25 01:47:28 +00:00
|
|
|
|
|
|
|
/// setAsmVerbosityDefault - Set the default value of asm verbosity. Default
|
|
|
|
/// is false.
|
2014-05-20 23:59:50 +00:00
|
|
|
void setAsmVerbosityDefault(bool);
|
2009-03-25 01:47:28 +00:00
|
|
|
|
2010-04-13 00:36:43 +00:00
|
|
|
/// getDataSections - Return true if data objects should be emitted into their
|
|
|
|
/// own section, corresponds to -fdata-sections.
|
2014-05-20 21:25:34 +00:00
|
|
|
bool getDataSections() const;
|
2010-04-13 00:36:43 +00:00
|
|
|
|
|
|
|
/// getFunctionSections - Return true if functions should be emitted into
|
|
|
|
/// their own section, corresponding to -ffunction-sections.
|
2014-05-20 21:25:34 +00:00
|
|
|
bool getFunctionSections() const;
|
2010-04-13 00:36:43 +00:00
|
|
|
|
|
|
|
/// setDataSections - Set if the data are emit into separate sections.
|
2014-05-20 21:25:34 +00:00
|
|
|
void setDataSections(bool);
|
2010-04-13 00:36:43 +00:00
|
|
|
|
|
|
|
/// setFunctionSections - Set if the functions are emit into separate
|
|
|
|
/// sections.
|
2014-05-20 21:25:34 +00:00
|
|
|
void setFunctionSections(bool);
|
2010-04-13 00:36:43 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171681 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 01:37:14 +00:00
|
|
|
/// \brief Register analysis passes for this target with a pass manager.
|
|
|
|
virtual void addAnalysisPasses(PassManagerBase &) {}
|
|
|
|
|
2005-06-25 02:47:50 +00:00
|
|
|
/// CodeGenFileType - These enums are meant to be passed into
|
2010-02-02 21:06:45 +00:00
|
|
|
/// addPassesToEmitFile to indicate what type of file to emit, and returned by
|
|
|
|
/// it to indicate what type of file could actually be made.
|
2005-06-25 02:47:50 +00:00
|
|
|
enum CodeGenFileType {
|
2010-02-02 21:06:45 +00:00
|
|
|
CGFT_AssemblyFile,
|
|
|
|
CGFT_ObjectFile,
|
2010-02-03 05:55:08 +00:00
|
|
|
CGFT_Null // Do not emit any output.
|
2005-06-25 02:47:50 +00:00
|
|
|
};
|
|
|
|
|
2007-02-08 01:34:45 +00:00
|
|
|
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
|
|
|
/// specified file emitted. Typically this will involve several steps of code
|
2010-02-03 05:55:08 +00:00
|
|
|
/// generation. This method should return true if emission of this file type
|
|
|
|
/// is not supported, or false on success.
|
|
|
|
virtual bool addPassesToEmitFile(PassManagerBase &,
|
|
|
|
formatted_raw_ostream &,
|
2010-02-17 23:55:26 +00:00
|
|
|
CodeGenFileType,
|
2012-07-02 19:48:45 +00:00
|
|
|
bool /*DisableVerify*/ = true,
|
2014-04-14 00:51:57 +00:00
|
|
|
AnalysisID /*StartAfter*/ = nullptr,
|
|
|
|
AnalysisID /*StopAfter*/ = nullptr) {
|
2010-02-03 05:55:08 +00:00
|
|
|
return true;
|
2007-02-08 01:34:45 +00:00
|
|
|
}
|
|
|
|
|
2010-07-22 05:58:53 +00:00
|
|
|
/// addPassesToEmitMC - Add passes to the specified pass manager to get
|
|
|
|
/// machine code emitted with the MCJIT. This method returns true if machine
|
|
|
|
/// code is not supported. It fills the MCContext Ctx pointer which can be
|
|
|
|
/// used to build custom MCStreamer.
|
|
|
|
///
|
2010-07-22 21:51:30 +00:00
|
|
|
virtual bool addPassesToEmitMC(PassManagerBase &,
|
|
|
|
MCContext *&,
|
2011-03-21 18:06:32 +00:00
|
|
|
raw_ostream &,
|
2011-12-02 20:53:57 +00:00
|
|
|
bool /*DisableVerify*/ = true) {
|
2010-07-22 05:58:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-02-19 20:30:41 +00:00
|
|
|
|
|
|
|
void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV,
|
|
|
|
Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
|
|
|
|
MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const;
|
2006-09-04 04:14:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// LLVMTargetMachine - This class describes a target machine that is
|
|
|
|
/// implemented with the LLVM target-independent code generator.
|
|
|
|
///
|
|
|
|
class LLVMTargetMachine : public TargetMachine {
|
|
|
|
protected: // Can only create subclasses.
|
2011-07-08 01:53:10 +00:00
|
|
|
LLVMTargetMachine(const Target &T, StringRef TargetTriple,
|
2011-12-02 22:16:29 +00:00
|
|
|
StringRef CPU, StringRef FS, TargetOptions Options,
|
2011-11-16 08:38:26 +00:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL);
|
2010-10-16 08:25:21 +00:00
|
|
|
|
2013-05-13 01:16:13 +00:00
|
|
|
void initAsmInfo();
|
2006-09-04 04:14:57 +00:00
|
|
|
public:
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171681 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 01:37:14 +00:00
|
|
|
/// \brief Register analysis passes for this target with a pass manager.
|
|
|
|
///
|
|
|
|
/// This registers target independent analysis passes.
|
2014-03-05 09:10:37 +00:00
|
|
|
void addAnalysisPasses(PassManagerBase &PM) override;
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171681 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 01:37:14 +00:00
|
|
|
|
2012-02-03 05:12:41 +00:00
|
|
|
/// createPassConfig - Create a pass configuration object to be used by
|
|
|
|
/// addPassToEmitX methods for generating a pipeline of CodeGen passes.
|
2012-02-04 02:56:59 +00:00
|
|
|
virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
|
2012-02-03 05:12:41 +00:00
|
|
|
|
2007-02-08 01:34:45 +00:00
|
|
|
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
|
|
|
/// specified file emitted. Typically this will involve several steps of code
|
2011-11-16 08:38:26 +00:00
|
|
|
/// generation.
|
2014-03-05 09:10:37 +00:00
|
|
|
bool addPassesToEmitFile(PassManagerBase &PM, formatted_raw_ostream &Out,
|
|
|
|
CodeGenFileType FileType, bool DisableVerify = true,
|
2014-04-14 00:51:57 +00:00
|
|
|
AnalysisID StartAfter = nullptr,
|
|
|
|
AnalysisID StopAfter = nullptr) override;
|
2010-10-16 08:25:21 +00:00
|
|
|
|
2010-07-22 05:58:53 +00:00
|
|
|
/// addPassesToEmitMC - Add passes to the specified pass manager to get
|
|
|
|
/// machine code emitted with the MCJIT. This method returns true if machine
|
|
|
|
/// code is not supported. It fills the MCContext Ctx pointer which can be
|
|
|
|
/// used to build custom MCStreamer.
|
|
|
|
///
|
2014-03-05 09:10:37 +00:00
|
|
|
bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
|
|
|
|
raw_ostream &OS, bool DisableVerify = true) override;
|
2001-09-18 12:38:31 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
#endif
|