2012-03-08 01:41:12 +00:00
|
|
|
//==- MachineScheduler.h - MachineInstr Scheduling Pass ----------*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides a MachineSchedRegistry for registering alternative machine
|
|
|
|
// schedulers. A Target may provide an alternative scheduler implementation by
|
|
|
|
// implementing the following boilerplate:
|
|
|
|
//
|
|
|
|
// static ScheduleDAGInstrs *createCustomMachineSched(MachineSchedContext *C) {
|
|
|
|
// return new CustomMachineScheduler(C);
|
|
|
|
// }
|
|
|
|
// static MachineSchedRegistry
|
2012-03-09 00:52:20 +00:00
|
|
|
// SchedCustomRegistry("custom", "Run my target's custom scheduler",
|
|
|
|
// createCustomMachineSched);
|
|
|
|
//
|
|
|
|
// Inside <Target>PassConfig:
|
2012-07-02 19:48:37 +00:00
|
|
|
// enablePass(&MachineSchedulerID);
|
2012-03-09 00:52:20 +00:00
|
|
|
// MachineSchedRegistry::setDefault(createCustomMachineSched);
|
2012-03-08 01:41:12 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef MACHINESCHEDULER_H
|
|
|
|
#define MACHINESCHEDULER_H
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachinePassRegistry.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class AliasAnalysis;
|
|
|
|
class LiveIntervals;
|
|
|
|
class MachineDominatorTree;
|
|
|
|
class MachineLoopInfo;
|
2012-04-25 01:11:22 +00:00
|
|
|
class RegisterClassInfo;
|
2012-03-08 01:41:12 +00:00
|
|
|
class ScheduleDAGInstrs;
|
|
|
|
|
|
|
|
/// MachineSchedContext provides enough context from the MachineScheduler pass
|
|
|
|
/// for the target to instantiate a scheduler.
|
|
|
|
struct MachineSchedContext {
|
|
|
|
MachineFunction *MF;
|
|
|
|
const MachineLoopInfo *MLI;
|
|
|
|
const MachineDominatorTree *MDT;
|
2012-03-09 00:52:20 +00:00
|
|
|
const TargetPassConfig *PassConfig;
|
2012-03-08 01:41:12 +00:00
|
|
|
AliasAnalysis *AA;
|
|
|
|
LiveIntervals *LIS;
|
|
|
|
|
2012-04-24 20:36:19 +00:00
|
|
|
RegisterClassInfo *RegClassInfo;
|
2012-04-24 17:56:43 +00:00
|
|
|
|
2012-04-24 20:36:19 +00:00
|
|
|
MachineSchedContext();
|
|
|
|
virtual ~MachineSchedContext();
|
2012-03-08 01:41:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// MachineSchedRegistry provides a selection of available machine instruction
|
|
|
|
/// schedulers.
|
|
|
|
class MachineSchedRegistry : public MachinePassRegistryNode {
|
|
|
|
public:
|
|
|
|
typedef ScheduleDAGInstrs *(*ScheduleDAGCtor)(MachineSchedContext *);
|
|
|
|
|
|
|
|
// RegisterPassParser requires a (misnamed) FunctionPassCtor type.
|
|
|
|
typedef ScheduleDAGCtor FunctionPassCtor;
|
|
|
|
|
|
|
|
static MachinePassRegistry Registry;
|
|
|
|
|
|
|
|
MachineSchedRegistry(const char *N, const char *D, ScheduleDAGCtor C)
|
|
|
|
: MachinePassRegistryNode(N, D, (MachinePassCtor)C) {
|
|
|
|
Registry.Add(this);
|
|
|
|
}
|
|
|
|
~MachineSchedRegistry() { Registry.Remove(this); }
|
|
|
|
|
|
|
|
// Accessors.
|
|
|
|
//
|
|
|
|
MachineSchedRegistry *getNext() const {
|
|
|
|
return (MachineSchedRegistry *)MachinePassRegistryNode::getNext();
|
|
|
|
}
|
|
|
|
static MachineSchedRegistry *getList() {
|
|
|
|
return (MachineSchedRegistry *)Registry.getList();
|
|
|
|
}
|
|
|
|
static ScheduleDAGCtor getDefault() {
|
|
|
|
return (ScheduleDAGCtor)Registry.getDefault();
|
|
|
|
}
|
|
|
|
static void setDefault(ScheduleDAGCtor C) {
|
|
|
|
Registry.setDefault((MachinePassCtor)C);
|
|
|
|
}
|
2012-04-19 01:34:10 +00:00
|
|
|
static void setDefault(StringRef Name) {
|
|
|
|
Registry.setDefault(Name);
|
|
|
|
}
|
2012-03-08 01:41:12 +00:00
|
|
|
static void setListener(MachinePassRegistryListener *L) {
|
|
|
|
Registry.setListener(L);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
#endif
|