diff --git a/llvm/include/llvm/CodeGen/MachineScheduler.h b/llvm/include/llvm/CodeGen/MachineScheduler.h index e7a7091acee64..1635eae758590 100644 --- a/llvm/include/llvm/CodeGen/MachineScheduler.h +++ b/llvm/include/llvm/CodeGen/MachineScheduler.h @@ -116,6 +116,7 @@ enum Direction { } // namespace MISched LLVM_ABI extern cl::opt PreRADirection; +LLVM_ABI extern cl::opt PostRADirection; LLVM_ABI extern cl::opt VerifyScheduling; #ifndef NDEBUG extern cl::opt ViewMISchedDAGs; diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index 76cba2949af60..72e1fce07f33e 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -190,7 +190,7 @@ cl::opt PreRADirection( clEnumValN(MISched::Bidirectional, "bidirectional", "Force bidirectional pre reg-alloc list scheduling"))); -static cl::opt PostRADirection( +cl::opt PostRADirection( "misched-postra-direction", cl::Hidden, cl::desc("Post reg-alloc list scheduling direction"), cl::init(MISched::Unspecified), diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index c3536113e9bef..28d8b08cf32a5 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -1144,6 +1144,23 @@ GCNTargetMachine::createMachineScheduler(MachineSchedContext *C) const { ScheduleDAGInstrs * GCNTargetMachine::createPostMachineScheduler(MachineSchedContext *C) const { + Attribute PostRADirectionAttr = + C->MF->getFunction().getFnAttribute("misched-postra-direction"); + + if (PostRADirectionAttr.isValid()) { + StringRef PostRADirectionStr = PostRADirectionAttr.getValueAsString(); + if (PostRADirectionStr == "topdown") + PostRADirection = MISched::TopDown; + else if (PostRADirectionStr == "bottomup") + PostRADirection = MISched::BottomUp; + else if (PostRADirectionStr == "bidirectional") + PostRADirection = MISched::Bidirectional; + else + reportFatalUsageError( + Twine("invalid value for 'misched-postra-direction' attribute: ") + + PostRADirectionStr); + } + ScheduleDAGMI *DAG = new GCNPostScheduleDAGMILive(C, std::make_unique(C), /*RemoveKillFlags=*/true);