@@ -1322,37 +1322,37 @@ bool SITargetLowering::getAddrModeArguments(IntrinsicInst *II,
1322
1322
}
1323
1323
}
1324
1324
1325
- bool SITargetLowering::isLegalFlatAddressingMode(const AddrMode &AM) const {
1325
+ bool SITargetLowering::isLegalFlatAddressingMode(const AddrMode &AM,
1326
+ unsigned AddrSpace,
1327
+ uint64_t FlatVariant) const {
1326
1328
if (!Subtarget->hasFlatInstOffsets()) {
1327
1329
// Flat instructions do not have offsets, and only have the register
1328
1330
// address.
1329
1331
return AM.BaseOffs == 0 && AM.Scale == 0;
1330
1332
}
1331
1333
1332
1334
return AM.Scale == 0 &&
1333
- (AM.BaseOffs == 0 ||
1334
- Subtarget->getInstrInfo()->isLegalFLATOffset(
1335
- AM.BaseOffs, AMDGPUAS::FLAT_ADDRESS, SIInstrFlags::FLAT));
1335
+ (AM.BaseOffs == 0 || Subtarget->getInstrInfo()->isLegalFLATOffset(
1336
+ AM.BaseOffs, AddrSpace, FlatVariant));
1336
1337
}
1337
1338
1338
1339
bool SITargetLowering::isLegalGlobalAddressingMode(const AddrMode &AM) const {
1339
1340
if (Subtarget->hasFlatGlobalInsts())
1340
- return AM.Scale == 0 &&
1341
- (AM.BaseOffs == 0 || Subtarget->getInstrInfo()->isLegalFLATOffset(
1342
- AM.BaseOffs, AMDGPUAS::GLOBAL_ADDRESS,
1343
- SIInstrFlags::FlatGlobal));
1341
+ return isLegalFlatAddressingMode(AM, AMDGPUAS::GLOBAL_ADDRESS,
1342
+ SIInstrFlags::FlatGlobal);
1344
1343
1345
1344
if (!Subtarget->hasAddr64() || Subtarget->useFlatForGlobal()) {
1346
- // Assume the we will use FLAT for all global memory accesses
1347
- // on VI.
1348
- // FIXME: This assumption is currently wrong. On VI we still use
1349
- // MUBUF instructions for the r + i addressing mode. As currently
1350
- // implemented, the MUBUF instructions only work on buffer < 4GB.
1351
- // It may be possible to support > 4GB buffers with MUBUF instructions,
1352
- // by setting the stride value in the resource descriptor which would
1353
- // increase the size limit to (stride * 4GB). However, this is risky,
1354
- // because it has never been validated.
1355
- return isLegalFlatAddressingMode(AM);
1345
+ // Assume the we will use FLAT for all global memory accesses
1346
+ // on VI.
1347
+ // FIXME: This assumption is currently wrong. On VI we still use
1348
+ // MUBUF instructions for the r + i addressing mode. As currently
1349
+ // implemented, the MUBUF instructions only work on buffer < 4GB.
1350
+ // It may be possible to support > 4GB buffers with MUBUF instructions,
1351
+ // by setting the stride value in the resource descriptor which would
1352
+ // increase the size limit to (stride * 4GB). However, this is risky,
1353
+ // because it has never been validated.
1354
+ return isLegalFlatAddressingMode(AM, AMDGPUAS::FLAT_ADDRESS,
1355
+ SIInstrFlags::FLAT);
1356
1356
}
1357
1357
1358
1358
return isLegalMUBUFAddressingMode(AM);
@@ -1449,7 +1449,10 @@ bool SITargetLowering::isLegalAddressingMode(const DataLayout &DL,
1449
1449
}
1450
1450
1451
1451
if (AS == AMDGPUAS::PRIVATE_ADDRESS)
1452
- return isLegalMUBUFAddressingMode(AM);
1452
+ return Subtarget->enableFlatScratch()
1453
+ ? isLegalFlatAddressingMode(AM, AMDGPUAS::PRIVATE_ADDRESS,
1454
+ SIInstrFlags::FlatScratch)
1455
+ : isLegalMUBUFAddressingMode(AM);
1453
1456
1454
1457
if (AS == AMDGPUAS::LOCAL_ADDRESS ||
1455
1458
(AS == AMDGPUAS::REGION_ADDRESS && Subtarget->hasGDS())) {
@@ -1475,7 +1478,8 @@ bool SITargetLowering::isLegalAddressingMode(const DataLayout &DL,
1475
1478
// computation. We don't have instructions that compute pointers with any
1476
1479
// addressing modes, so treat them as having no offset like flat
1477
1480
// instructions.
1478
- return isLegalFlatAddressingMode(AM);
1481
+ return isLegalFlatAddressingMode(AM, AMDGPUAS::FLAT_ADDRESS,
1482
+ SIInstrFlags::FLAT);
1479
1483
}
1480
1484
1481
1485
// Assume a user alias of global for unknown address spaces.
0 commit comments