Skip to content

Commit 4c37d70

Browse files
committed
[AMDGPU] Use function attribute for post-ra
1 parent 967bce6 commit 4c37d70

File tree

7 files changed

+50
-92
lines changed

7 files changed

+50
-92
lines changed

llvm/include/llvm/CodeGen/TargetSubtargetInfo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm/ADT/ArrayRef.h"
1717
#include "llvm/ADT/SmallVector.h"
1818
#include "llvm/ADT/StringRef.h"
19-
#include "llvm/CodeGen/MachineBasicBlock.h"
2019
#include "llvm/CodeGen/MacroFusion.h"
2120
#include "llvm/CodeGen/PBQPRAConstraint.h"
2221
#include "llvm/CodeGen/SchedulerRegistry.h"

llvm/lib/Target/AMDGPU/AMDGPUFeatures.td

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
defvar TopDown = [{ MISched::TopDown }];
10-
defvar BottomUp = [{ MISched::BottomUp }];
11-
defvar Bidirectional = [{ MISched::Bidirectional }];
12-
139
def FeatureFP64 : SubtargetFeature<"fp64",
1410
"FP64",
1511
"true",
@@ -57,21 +53,3 @@ def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
5753
"true",
5854
"Enable promote alloca pass"
5955
>;
60-
61-
def FeaturePostRATopDown : SubtargetFeature <"postra-top-down",
62-
"PostRASchedDirection",
63-
TopDown,
64-
"Force Post-RA scheduler to run top-down"
65-
>;
66-
67-
def FeaturePostRABottomUp : SubtargetFeature <"postra-bottom-up",
68-
"PostRASchedDirection",
69-
BottomUp,
70-
"Force Post-RA scheduler to run bottom-up"
71-
>;
72-
73-
def FeaturePostRABidirectional : SubtargetFeature <"postra-bidirectional",
74-
"PostRASchedDirection",
75-
Bidirectional,
76-
"Force Post-RA scheduler to run bidirectionally"
77-
>;

llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
1616

1717
#include "llvm/ADT/SmallVector.h"
18-
#include "llvm/CodeGen/MachineScheduler.h"
1918
#include "llvm/IR/CallingConv.h"
2019
#include "llvm/Support/Alignment.h"
2120
#include "llvm/TargetParser/Triple.h"
@@ -81,7 +80,6 @@ class AMDGPUSubtarget {
8180
unsigned LocalMemorySize = 0;
8281
unsigned AddressableLocalMemorySize = 0;
8382
char WavefrontSizeLog2 = 0;
84-
MISched::Direction PostRASchedDirection = MISched::TopDown;
8583

8684
public:
8785
AMDGPUSubtarget(Triple TT);
@@ -384,10 +382,6 @@ class AMDGPUSubtarget {
384382
AMDGPUDwarfFlavour getAMDGPUDwarfFlavour() const;
385383

386384
virtual ~AMDGPUSubtarget() = default;
387-
388-
MISched::Direction getPostRASchedDirection() const {
389-
return PostRASchedDirection;
390-
}
391385
};
392386

393387
} // end namespace llvm

llvm/lib/Target/AMDGPU/GCNSubtarget.cpp

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,8 @@ void GCNSubtarget::overrideSchedPolicy(MachineSchedPolicy &Policy,
346346
}
347347

348348
void GCNSubtarget::overridePostRASchedPolicy(MachineSchedPolicy &Policy,
349-
const MachineBasicBlock &MBB,
350-
unsigned NumRegionInstr) const {
351-
const Function &F = MBB.getParent()->getFunction();
349+
const SchedRegion &Region) const {
350+
const Function &F = Region.RegionBegin->getMF()->getFunction();
352351
Attribute PostRADirectionAttr = F.getFnAttribute("amdgpu-post-ra-direction");
353352
if (!PostRADirectionAttr.isValid())
354353
return;
@@ -370,39 +369,19 @@ void GCNSubtarget::overridePostRASchedPolicy(MachineSchedPolicy &Policy,
370369
PostRADirectionStr);
371370
F.getContext().diagnose(Diag);
372371
}
373-
// }
374-
375-
// switch (getPostRASchedDirection()) {
376-
// case MISched::TopDown:
377-
// Policy.OnlyTopDown = true;
378-
// Policy.OnlyBottomUp = false;
379-
// break;
380-
// case MISched::BottomUp:
381-
// Policy.OnlyTopDown = false;
382-
// Policy.OnlyBottomUp = true;
383-
// break;
384-
// case MISched::Bidirectional:
385-
// Policy.OnlyTopDown = false;
386-
// Policy.OnlyBottomUp = false;
387-
// break;
388-
// default:
389-
// break;
390-
// }
391-
392-
// LLVM_DEBUG({
393-
// const char *DirStr = "topdown";
394-
// switch (getPostRASchedDirection()) {
395-
// case MISched::BottomUp:
396-
// DirStr = "bottomup";
397-
// break;
398-
// case MISched::Bidirectional:
399-
// DirStr = "bidirectional";
400-
// break;
401-
// default:
402-
// break;
403-
// }
404-
// dbgs() << "Post-MI-sched direction: " << DirStr << '\n';
405-
// });
372+
373+
LLVM_DEBUG({
374+
const char *DirStr = "default";
375+
if (Policy.OnlyTopDown && !Policy.OnlyBottomUp)
376+
DirStr = "topdown";
377+
else if (!Policy.OnlyTopDown && Policy.OnlyBottomUp)
378+
DirStr = "bottomup";
379+
else if (!Policy.OnlyTopDown && !Policy.OnlyBottomUp)
380+
DirStr = "bidirectional";
381+
382+
dbgs() << "Post-MI-sched direction (" << F.getName() << "): " << DirStr
383+
<< '\n';
384+
});
406385
}
407386

408387
void GCNSubtarget::mirFileLoaded(MachineFunction &MF) const {

llvm/lib/Target/AMDGPU/GCNSubtarget.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,7 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
10421042
const SchedRegion &Region) const override;
10431043

10441044
void overridePostRASchedPolicy(MachineSchedPolicy &Policy,
1045-
const MachineBasicBlock &MBB,
1046-
unsigned NumRegionInstr) const override;
1045+
const SchedRegion &Region) const override;
10471046

10481047
void mirFileLoaded(MachineFunction &MF) const override;
10491048

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; REQUIRES: asserts
2+
3+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -debug-only=gcn-subtarget < %s 2>&1 | FileCheck %s
4+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 < %s 2>&1 | FileCheck -check-prefixes=WARNING %s
5+
6+
; CHECK: Post-MI-sched direction (postra-sched-topdown): topdown
7+
define float @postra-sched-topdown(float %input) nounwind #0 {
8+
%x = fadd float %input, 1.000000e+00
9+
ret float %x
10+
}
11+
12+
; CHECK: Post-MI-sched direction (postra-sched-bottomup): bottomup
13+
define float @postra-sched-bottomup(float %input) nounwind #1 {
14+
%x = fsub float %input, 1.000000e+00
15+
ret float %x
16+
}
17+
18+
; CHECK: Post-MI-sched direction (postra-sched-bidirectional): bidirectional
19+
define float @postra-sched-bidirectional(float %input) nounwind #2 {
20+
%x = fadd float %input, 1.000000e+00
21+
ret float %x
22+
}
23+
24+
; CHECK: Post-MI-sched direction (postra-sched-warning): topdown
25+
; WARNING: invalid value for postRa direction attribute
26+
define float @postra-sched-warning(float %input) nounwind #3 {
27+
%x = fsub float %input, 1.000000e+00
28+
ret float %x
29+
}
30+
31+
attributes #0 = {"amdgpu-post-ra-direction"="topdown"}
32+
attributes #1 = {"amdgpu-post-ra-direction"="bottomup"}
33+
attributes #2 = {"amdgpu-post-ra-direction"="bidirectional"}
34+
attributes #3 = {"amdgpu-post-ra-direction"="warning"}

llvm/test/CodeGen/AMDGPU/postra-sched-target-features.ll

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)