Skip to content

[CodeGen] Use Register in SDep interface. NFC #129734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions llvm/include/llvm/CodeGen/ScheduleDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,18 @@ class TargetRegisterInfo;
SDep() : Dep(nullptr, Data) {}

/// Constructs an SDep with the specified values.
SDep(SUnit *S, Kind kind, unsigned Reg)
: Dep(S, kind), Contents() {
SDep(SUnit *S, Kind kind, Register Reg) : Dep(S, kind), Contents() {
switch (kind) {
default:
llvm_unreachable("Reg given for non-register dependence!");
case Anti:
case Output:
assert(Reg != 0 &&
"SDep::Anti and SDep::Output must use a non-zero Reg!");
Contents.Reg = Reg;
assert(Reg && "SDep::Anti and SDep::Output must use a non-zero Reg!");
Contents.Reg = Reg.id();
Latency = 0;
break;
case Data:
Contents.Reg = Reg;
Contents.Reg = Reg.id();
Latency = 1;
break;
}
Expand Down Expand Up @@ -208,14 +206,12 @@ class TargetRegisterInfo;
}

/// Tests if this is a Data dependence that is associated with a register.
bool isAssignedRegDep() const {
return getKind() == Data && Contents.Reg != 0;
}
bool isAssignedRegDep() const { return getKind() == Data && Contents.Reg; }

/// Returns the register associated with this edge. This is only valid on
/// Data, Anti, and Output edges. On Data edges, this value may be zero,
/// meaning there is no associated register.
unsigned getReg() const {
Register getReg() const {
assert((getKind() == Data || getKind() == Anti || getKind() == Output) &&
"getReg called on non-register dependence edge!");
return Contents.Reg;
Expand All @@ -225,14 +221,14 @@ class TargetRegisterInfo;
/// Data, Anti, and Output edges. On Anti and Output edges, this value must
/// not be zero. On Data edges, the value may be zero, which would mean that
/// no specific register is associated with this edge.
void setReg(unsigned Reg) {
void setReg(Register Reg) {
assert((getKind() == Data || getKind() == Anti || getKind() == Output) &&
"setReg called on non-register dependence edge!");
assert((getKind() != Anti || Reg != 0) &&
assert((getKind() != Anti || Reg) &&
"SDep::Anti edge cannot use the zero register!");
assert((getKind() != Output || Reg != 0) &&
assert((getKind() != Output || Reg) &&
"SDep::Output edge cannot use the zero register!");
Contents.Reg = Reg;
Contents.Reg = Reg.id();
}

void dump(const TargetRegisterInfo *TRI = nullptr) const;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ unsigned AggressiveAntiDepBreaker::BreakAntiDependencies(
if ((Edge->getKind() != SDep::Anti) &&
(Edge->getKind() != SDep::Output)) continue;

MCRegister AntiDepReg = MCRegister::from(Edge->getReg());
MCRegister AntiDepReg = Edge->getReg().asMCReg();
LLVM_DEBUG(dbgs() << "\tAntidep reg: " << printReg(AntiDepReg, TRI));
assert(AntiDepReg && "Anti-dependence on reg0?");

Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/MachineScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3969,8 +3969,7 @@ void GenericScheduler::reschedulePhysReg(SUnit *SU, bool isTop) {
// Find already scheduled copies with a single physreg dependence and move
// them just above the scheduled instruction.
for (SDep &Dep : Deps) {
if (Dep.getKind() != SDep::Data ||
!Register::isPhysicalRegister(Dep.getReg()))
if (Dep.getKind() != SDep::Data || !Dep.getReg().isPhysical())
continue;
SUnit *DepSU = Dep.getSUnit();
if (isTop ? DepSU->Succs.size() > 1 : DepSU->Preds.size() > 1)
Expand Down