Skip to content

Commit 99e87a3

Browse files
Initial conversion of LoadExtActions to map
1 parent 6b26dd5 commit 99e87a3

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,27 +1472,34 @@ class LLVM_ABI TargetLoweringBase {
14721472
/// Return how this load with extension should be treated: either it is legal,
14731473
/// needs to be promoted to a larger size, needs to be expanded to some other
14741474
/// code sequence, or the target has a custom expander for it.
1475-
LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT,
1476-
EVT MemVT) const {
1477-
if (ValVT.isExtended() || MemVT.isExtended()) return Expand;
1478-
unsigned ValI = (unsigned) ValVT.getSimpleVT().SimpleTy;
1479-
unsigned MemI = (unsigned) MemVT.getSimpleVT().SimpleTy;
1475+
LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT, EVT MemVT,
1476+
unsigned AddrSpace) const {
1477+
if (ValVT.isExtended() || MemVT.isExtended())
1478+
return Expand;
1479+
unsigned ValI = (unsigned)ValVT.getSimpleVT().SimpleTy;
1480+
unsigned MemI = (unsigned)MemVT.getSimpleVT().SimpleTy;
14801481
assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValI < MVT::VALUETYPE_SIZE &&
14811482
MemI < MVT::VALUETYPE_SIZE && "Table isn't big enough!");
14821483
unsigned Shift = 4 * ExtType;
1483-
return (LegalizeAction)((LoadExtActions[ValI][MemI] >> Shift) & 0xf);
1484+
1485+
if (!LoadExtActions.count(AddrSpace)) {
1486+
return Legal; // default
1487+
}
1488+
return (
1489+
LegalizeAction)((LoadExtActions.at(AddrSpace)[ValI][MemI] >> Shift) &
1490+
0xf);
14841491
}
14851492

14861493
/// Return true if the specified load with extension is legal on this target.
1487-
bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT) const {
1488-
return getLoadExtAction(ExtType, ValVT, MemVT) == Legal;
1494+
bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT, unsigned AddrSpace) const {
1495+
return getLoadExtAction(ExtType, ValVT, MemVT, AddrSpace) == Legal;
14891496
}
14901497

14911498
/// Return true if the specified load with extension is legal or custom
14921499
/// on this target.
1493-
bool isLoadExtLegalOrCustom(unsigned ExtType, EVT ValVT, EVT MemVT) const {
1494-
return getLoadExtAction(ExtType, ValVT, MemVT) == Legal ||
1495-
getLoadExtAction(ExtType, ValVT, MemVT) == Custom;
1500+
bool isLoadExtLegalOrCustom(unsigned ExtType, EVT ValVT, EVT MemVT, unsigned AddrSpace) const {
1501+
return getLoadExtAction(ExtType, ValVT, MemVT, AddrSpace) == Legal ||
1502+
getLoadExtAction(ExtType, ValVT, MemVT, AddrSpace) == Custom;
14961503
}
14971504

14981505
/// Same as getLoadExtAction, but for atomic loads.
@@ -2634,13 +2641,15 @@ class LLVM_ABI TargetLoweringBase {
26342641
/// Indicate that the specified load with extension does not work with the
26352642
/// specified type and indicate what to do about it.
26362643
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT,
2637-
LegalizeAction Action) {
2644+
LegalizeAction Action, unsigned AddrSpace) {
26382645
assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValVT.isValid() &&
26392646
MemVT.isValid() && "Table isn't big enough!");
26402647
assert((unsigned)Action < 0x10 && "too many bits for bitfield array");
26412648
unsigned Shift = 4 * ExtType;
2642-
LoadExtActions[ValVT.SimpleTy][MemVT.SimpleTy] &= ~((uint16_t)0xF << Shift);
2643-
LoadExtActions[ValVT.SimpleTy][MemVT.SimpleTy] |= (uint16_t)Action << Shift;
2649+
LoadExtActions[AddrSpace][ValVT.SimpleTy][MemVT.SimpleTy] &=
2650+
~((uint16_t)0xF << Shift);
2651+
LoadExtActions[AddrSpace][ValVT.SimpleTy][MemVT.SimpleTy] |=
2652+
(uint16_t)Action << Shift;
26442653
}
26452654
void setLoadExtAction(ArrayRef<unsigned> ExtTypes, MVT ValVT, MVT MemVT,
26462655
LegalizeAction Action) {
@@ -3753,8 +3762,13 @@ class LLVM_ABI TargetLoweringBase {
37533762
/// For each load extension type and each value type, keep a LegalizeAction
37543763
/// that indicates how instruction selection should deal with a load of a
37553764
/// specific value type and extension type. Uses 4-bits to store the action
3756-
/// for each of the 4 load ext types.
3757-
uint16_t LoadExtActions[MVT::VALUETYPE_SIZE][MVT::VALUETYPE_SIZE];
3765+
/// for each of the 4 load ext types. These actions can be specified for each
3766+
/// address space.
3767+
using LoadExtActionMapTy =
3768+
std::array<std::array<uint16_t, MVT::VALUETYPE_SIZE>,
3769+
MVT::VALUETYPE_SIZE>;
3770+
using LoadExtActionMap = std::map<unsigned, LoadExtActionMapTy>;
3771+
LoadExtActionMap LoadExtActions;
37583772

37593773
/// Similar to LoadExtActions, but for atomic loads. Only Legal or Expand
37603774
/// (default) values are supported.

0 commit comments

Comments
 (0)