Skip to content

Commit 29bcd2c

Browse files
Merge pull request #78445 from aschwaighofer/loadable_by_address_magic_constant
LoadableByAddress: Replace some magic constants
2 parents c20a5b7 + 7aef2b5 commit 29bcd2c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,6 +3422,9 @@ struct Properties {
34223422
uint16_t numRegisters = 0;
34233423

34243424
public:
3425+
static uint16_t MaxNumUses;
3426+
static uint16_t MaxNumRegisters;
3427+
34253428
void addConstructor() {
34263429
sawConstructor = true;
34273430
}
@@ -3458,17 +3461,19 @@ struct Properties {
34583461
}
34593462

34603463
void addUse() {
3461-
if (use == 65535)
3464+
if (use == MaxNumUses)
34623465
return;
34633466
++use;
34643467
}
34653468
uint16_t numUses() const {
34663469
return use;
34673470
}
3468-
3471+
void setAsVeryLargeType() {
3472+
setNumRegisters(MaxNumRegisters);
3473+
}
34693474
void setNumRegisters(unsigned regs) {
3470-
if (regs > 65535) {
3471-
regs = 65535;
3475+
if (regs > MaxNumRegisters) {
3476+
numRegisters = MaxNumRegisters;
34723477
return;
34733478
}
34743479
numRegisters = regs;
@@ -3479,6 +3484,9 @@ struct Properties {
34793484
};
34803485
}
34813486

3487+
uint16_t Properties::MaxNumUses = 65535;
3488+
uint16_t Properties::MaxNumRegisters = 65535;
3489+
34823490
namespace {
34833491
class LargeLoadableHeuristic {
34843492
GenericEnvironment *genEnv;
@@ -3560,7 +3568,7 @@ void LargeLoadableHeuristic::propagate(PostOrderFunctionInfo &po) {
35603568
if (isLargeLoadableType(proj.getType())) {
35613569
auto opdTy = proj.getOperand(0)->getType();
35623570
auto entry = largeTypeProperties[opdTy];
3563-
entry.setNumRegisters(65535);
3571+
entry.setAsVeryLargeType();
35643572
largeTypeProperties[opdTy] = entry;
35653573
}
35663574
}
@@ -3612,7 +3620,7 @@ void LargeLoadableHeuristic::visit(SILInstruction *i) {
36123620
if (numRegisters(resTy) > NumRegistersLargeType) {
36133621
// Force the source type to be indirect.
36143622
auto entry = largeTypeProperties[opdTy];
3615-
entry.setNumRegisters(65535);
3623+
entry.setAsVeryLargeType();
36163624
largeTypeProperties[opdTy] = entry;
36173625
return;
36183626
}

0 commit comments

Comments
 (0)