LLVM API Documentation

TargetSubtargetInfo.h
Go to the documentation of this file.
00001 //==-- llvm/Target/TargetSubtargetInfo.h - Target Information ----*- C++ -*-==//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file describes the subtarget options of a Target machine.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_TARGET_TARGETSUBTARGETINFO_H
00015 #define LLVM_TARGET_TARGETSUBTARGETINFO_H
00016 
00017 #include "llvm/MC/MCSubtargetInfo.h"
00018 #include "llvm/Support/CodeGen.h"
00019 
00020 namespace llvm {
00021 
00022 class DataLayout;
00023 class MachineFunction;
00024 class MachineInstr;
00025 class SDep;
00026 class SUnit;
00027 class TargetFrameLowering;
00028 class TargetInstrInfo;
00029 class TargetLowering;
00030 class TargetRegisterClass;
00031 class TargetRegisterInfo;
00032 class TargetSchedModel;
00033 class TargetSelectionDAGInfo;
00034 struct MachineSchedPolicy;
00035 template <typename T> class SmallVectorImpl;
00036 
00037 //===----------------------------------------------------------------------===//
00038 ///
00039 /// TargetSubtargetInfo - Generic base class for all target subtargets.  All
00040 /// Target-specific options that control code generation and printing should
00041 /// be exposed through a TargetSubtargetInfo-derived class.
00042 ///
00043 class TargetSubtargetInfo : public MCSubtargetInfo {
00044   TargetSubtargetInfo(const TargetSubtargetInfo&) LLVM_DELETED_FUNCTION;
00045   void operator=(const TargetSubtargetInfo&) LLVM_DELETED_FUNCTION;
00046 protected: // Can only create subclasses...
00047   TargetSubtargetInfo();
00048 public:
00049   // AntiDepBreakMode - Type of anti-dependence breaking that should
00050   // be performed before post-RA scheduling.
00051   typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode;
00052   typedef SmallVectorImpl<const TargetRegisterClass*> RegClassVector;
00053 
00054   virtual ~TargetSubtargetInfo();
00055 
00056   // Interfaces to the major aspects of target machine information:
00057   //
00058   // -- Instruction opcode and operand information
00059   // -- Pipelines and scheduling information
00060   // -- Stack frame information
00061   // -- Selection DAG lowering information
00062   //
00063   // N.B. These objects may change during compilation. It's not safe to cache
00064   // them between functions.
00065   virtual const TargetInstrInfo *getInstrInfo() const { return nullptr; }
00066   virtual const TargetFrameLowering *getFrameLowering() const {
00067     return nullptr;
00068   }
00069   virtual const TargetLowering *getTargetLowering() const { return nullptr; }
00070   virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
00071     return nullptr;
00072   }
00073   virtual const DataLayout *getDataLayout() const { return nullptr; }
00074 
00075   /// getRegisterInfo - If register information is available, return it.  If
00076   /// not, return null.  This is kept separate from RegInfo until RegInfo has
00077   /// details of graph coloring register allocation removed from it.
00078   ///
00079   virtual const TargetRegisterInfo *getRegisterInfo() const { return nullptr; }
00080 
00081   /// getInstrItineraryData - Returns instruction itinerary data for the target
00082   /// or specific subtarget.
00083   ///
00084   virtual const InstrItineraryData *getInstrItineraryData() const {
00085     return nullptr;
00086   }
00087 
00088   /// Resolve a SchedClass at runtime, where SchedClass identifies an
00089   /// MCSchedClassDesc with the isVariant property. This may return the ID of
00090   /// another variant SchedClass, but repeated invocation must quickly terminate
00091   /// in a nonvariant SchedClass.
00092   virtual unsigned resolveSchedClass(unsigned SchedClass, const MachineInstr *MI,
00093                                      const TargetSchedModel* SchedModel) const {
00094     return 0;
00095   }
00096 
00097   /// \brief Temporary API to test migration to MI scheduler.
00098   bool useMachineScheduler() const;
00099 
00100   /// \brief True if the subtarget should run MachineScheduler after aggressive
00101   /// coalescing.
00102   ///
00103   /// This currently replaces the SelectionDAG scheduler with the "source" order
00104   /// scheduler. It does not yet disable the postRA scheduler.
00105   virtual bool enableMachineScheduler() const;
00106 
00107   /// \brief True if the subtarget should run PostMachineScheduler.
00108   ///
00109   /// This only takes effect if the target has configured the
00110   /// PostMachineScheduler pass to run, or if the global cl::opt flag,
00111   /// MISchedPostRA, is set.
00112   virtual bool enablePostMachineScheduler() const;
00113 
00114   /// \brief True if the subtarget should run the atomic expansion pass.
00115   virtual bool enableAtomicExpand() const;
00116 
00117   /// \brief Override generic scheduling policy within a region.
00118   ///
00119   /// This is a convenient way for targets that don't provide any custom
00120   /// scheduling heuristics (no custom MachineSchedStrategy) to make
00121   /// changes to the generic scheduling policy.
00122   virtual void overrideSchedPolicy(MachineSchedPolicy &Policy,
00123                                    MachineInstr *begin,
00124                                    MachineInstr *end,
00125                                    unsigned NumRegionInstrs) const {}
00126 
00127   // \brief Perform target specific adjustments to the latency of a schedule
00128   // dependency.
00129   virtual void adjustSchedDependency(SUnit *def, SUnit *use,
00130                                      SDep& dep) const { }
00131 
00132   // For use with PostRAScheduling: get the anti-dependence breaking that should
00133   // be performed before post-RA scheduling.
00134   virtual AntiDepBreakMode getAntiDepBreakMode() const {
00135     return ANTIDEP_NONE;
00136   }
00137 
00138   // For use with PostRAScheduling: in CriticalPathRCs, return any register
00139   // classes that should only be considered for anti-dependence breaking if they
00140   // are on the critical path.
00141   virtual void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const {
00142     return CriticalPathRCs.clear();
00143   }
00144 
00145   // For use with PostRAScheduling: get the minimum optimization level needed
00146   // to enable post-RA scheduling.
00147   virtual CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const {
00148     return CodeGenOpt::Default;
00149   }
00150 
00151   /// \brief True if the subtarget should run the local reassignment
00152   /// heuristic of the register allocator.
00153   /// This heuristic may be compile time intensive, \p OptLevel provides
00154   /// a finer grain to tune the register allocator.
00155   virtual bool enableRALocalReassignment(CodeGenOpt::Level OptLevel) const;
00156 
00157   /// \brief Enable use of alias analysis during code generation (during MI
00158   /// scheduling, DAGCombine, etc.).
00159   virtual bool useAA() const;
00160 
00161   /// \brief Enable the use of the early if conversion pass.
00162   virtual bool enableEarlyIfConversion() const { return false; }
00163 };
00164 
00165 } // End llvm namespace
00166 
00167 #endif