Skip to content

LoadableByAddress: Replace some magic constants #78445

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
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
20 changes: 14 additions & 6 deletions lib/IRGen/LoadableByAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3422,6 +3422,9 @@ struct Properties {
uint16_t numRegisters = 0;

public:
static uint16_t MaxNumUses;
static uint16_t MaxNumRegisters;

void addConstructor() {
sawConstructor = true;
}
Expand Down Expand Up @@ -3458,17 +3461,19 @@ struct Properties {
}

void addUse() {
if (use == 65535)
if (use == MaxNumUses)
return;
++use;
}
uint16_t numUses() const {
return use;
}

void setAsVeryLargeType() {
setNumRegisters(MaxNumRegisters);
}
void setNumRegisters(unsigned regs) {
if (regs > 65535) {
regs = 65535;
if (regs > MaxNumRegisters) {
numRegisters = MaxNumRegisters;
return;
}
numRegisters = regs;
Expand All @@ -3479,6 +3484,9 @@ struct Properties {
};
}

uint16_t Properties::MaxNumUses = 65535;
uint16_t Properties::MaxNumRegisters = 65535;

namespace {
class LargeLoadableHeuristic {
GenericEnvironment *genEnv;
Expand Down Expand Up @@ -3560,7 +3568,7 @@ void LargeLoadableHeuristic::propagate(PostOrderFunctionInfo &po) {
if (isLargeLoadableType(proj.getType())) {
auto opdTy = proj.getOperand(0)->getType();
auto entry = largeTypeProperties[opdTy];
entry.setNumRegisters(65535);
entry.setAsVeryLargeType();
largeTypeProperties[opdTy] = entry;
}
}
Expand Down Expand Up @@ -3612,7 +3620,7 @@ void LargeLoadableHeuristic::visit(SILInstruction *i) {
if (numRegisters(resTy) > NumRegistersLargeType) {
// Force the source type to be indirect.
auto entry = largeTypeProperties[opdTy];
entry.setNumRegisters(65535);
entry.setAsVeryLargeType();
largeTypeProperties[opdTy] = entry;
return;
}
Expand Down