10b57cec5SDimitry Andric //===- llvm/CodeGen/SchedulerRegistry.h -------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file contains the implementation for instruction scheduler function 100b57cec5SDimitry Andric // pass registry (RegisterScheduler). 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #ifndef LLVM_CODEGEN_SCHEDULERREGISTRY_H 150b57cec5SDimitry Andric #define LLVM_CODEGEN_SCHEDULERREGISTRY_H 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric #include "llvm/CodeGen/MachinePassRegistry.h" 180b57cec5SDimitry Andric #include "llvm/Support/CodeGen.h" 190b57cec5SDimitry Andric 200b57cec5SDimitry Andric namespace llvm { 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 230b57cec5SDimitry Andric /// 240b57cec5SDimitry Andric /// RegisterScheduler class - Track the registration of instruction schedulers. 250b57cec5SDimitry Andric /// 260b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric class ScheduleDAGSDNodes; 290b57cec5SDimitry Andric class SelectionDAGISel; 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric class RegisterScheduler 32*5f757f3fSDimitry Andric : public MachinePassRegistryNode<ScheduleDAGSDNodes *(*)(SelectionDAGISel *, 33*5f757f3fSDimitry Andric CodeGenOptLevel)> { 340b57cec5SDimitry Andric public: 350b57cec5SDimitry Andric using FunctionPassCtor = ScheduleDAGSDNodes *(*)(SelectionDAGISel *, 36*5f757f3fSDimitry Andric CodeGenOptLevel); 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric static MachinePassRegistry<FunctionPassCtor> Registry; 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric RegisterScheduler(const char *N, const char *D, FunctionPassCtor C) 410b57cec5SDimitry Andric : MachinePassRegistryNode(N, D, C) { 420b57cec5SDimitry Andric Registry.Add(this); 430b57cec5SDimitry Andric } 440b57cec5SDimitry Andric ~RegisterScheduler() { Registry.Remove(this); } 450b57cec5SDimitry Andric 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric // Accessors. 480b57cec5SDimitry Andric RegisterScheduler *getNext() const { 490b57cec5SDimitry Andric return (RegisterScheduler *)MachinePassRegistryNode::getNext(); 500b57cec5SDimitry Andric } 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric static RegisterScheduler *getList() { 530b57cec5SDimitry Andric return (RegisterScheduler *)Registry.getList(); 540b57cec5SDimitry Andric } 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric static void setListener(MachinePassRegistryListener<FunctionPassCtor> *L) { 570b57cec5SDimitry Andric Registry.setListener(L); 580b57cec5SDimitry Andric } 590b57cec5SDimitry Andric }; 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric /// createBURRListDAGScheduler - This creates a bottom up register usage 620b57cec5SDimitry Andric /// reduction list scheduler. 630b57cec5SDimitry Andric ScheduleDAGSDNodes *createBURRListDAGScheduler(SelectionDAGISel *IS, 64*5f757f3fSDimitry Andric CodeGenOptLevel OptLevel); 650b57cec5SDimitry Andric 66*5f757f3fSDimitry Andric /// createSourceListDAGScheduler - This creates a bottom up list scheduler that 670b57cec5SDimitry Andric /// schedules nodes in source code order when possible. 680b57cec5SDimitry Andric ScheduleDAGSDNodes *createSourceListDAGScheduler(SelectionDAGISel *IS, 69*5f757f3fSDimitry Andric CodeGenOptLevel OptLevel); 700b57cec5SDimitry Andric 710b57cec5SDimitry Andric /// createHybridListDAGScheduler - This creates a bottom up register pressure 720b57cec5SDimitry Andric /// aware list scheduler that make use of latency information to avoid stalls 730b57cec5SDimitry Andric /// for long latency instructions in low register pressure mode. In high 740b57cec5SDimitry Andric /// register pressure mode it schedules to reduce register pressure. 750b57cec5SDimitry Andric ScheduleDAGSDNodes *createHybridListDAGScheduler(SelectionDAGISel *IS, 76*5f757f3fSDimitry Andric CodeGenOptLevel); 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric /// createILPListDAGScheduler - This creates a bottom up register pressure 790b57cec5SDimitry Andric /// aware list scheduler that tries to increase instruction level parallelism 800b57cec5SDimitry Andric /// in low register pressure mode. In high register pressure mode it schedules 810b57cec5SDimitry Andric /// to reduce register pressure. 820b57cec5SDimitry Andric ScheduleDAGSDNodes *createILPListDAGScheduler(SelectionDAGISel *IS, 83*5f757f3fSDimitry Andric CodeGenOptLevel); 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric /// createFastDAGScheduler - This creates a "fast" scheduler. 860b57cec5SDimitry Andric /// 870b57cec5SDimitry Andric ScheduleDAGSDNodes *createFastDAGScheduler(SelectionDAGISel *IS, 88*5f757f3fSDimitry Andric CodeGenOptLevel OptLevel); 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric /// createVLIWDAGScheduler - Scheduler for VLIW targets. This creates top down 910b57cec5SDimitry Andric /// DFA driven list scheduler with clustering heuristic to control 920b57cec5SDimitry Andric /// register pressure. 930b57cec5SDimitry Andric ScheduleDAGSDNodes *createVLIWDAGScheduler(SelectionDAGISel *IS, 94*5f757f3fSDimitry Andric CodeGenOptLevel OptLevel); 950b57cec5SDimitry Andric /// createDefaultScheduler - This creates an instruction scheduler appropriate 960b57cec5SDimitry Andric /// for the target. 970b57cec5SDimitry Andric ScheduleDAGSDNodes *createDefaultScheduler(SelectionDAGISel *IS, 98*5f757f3fSDimitry Andric CodeGenOptLevel OptLevel); 990b57cec5SDimitry Andric 1000b57cec5SDimitry Andric /// createDAGLinearizer - This creates a "no-scheduling" scheduler which 1010b57cec5SDimitry Andric /// linearize the DAG using topological order. 1020b57cec5SDimitry Andric ScheduleDAGSDNodes *createDAGLinearizer(SelectionDAGISel *IS, 103*5f757f3fSDimitry Andric CodeGenOptLevel OptLevel); 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric } // end namespace llvm 1060b57cec5SDimitry Andric 1070b57cec5SDimitry Andric #endif // LLVM_CODEGEN_SCHEDULERREGISTRY_H 108