@@ -1472,27 +1472,34 @@ class LLVM_ABI TargetLoweringBase {
1472
1472
// / Return how this load with extension should be treated: either it is legal,
1473
1473
// / needs to be promoted to a larger size, needs to be expanded to some other
1474
1474
// / 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 ;
1480
1481
assert (ExtType < ISD::LAST_LOADEXT_TYPE && ValI < MVT::VALUETYPE_SIZE &&
1481
1482
MemI < MVT::VALUETYPE_SIZE && " Table isn't big enough!" );
1482
1483
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 );
1484
1491
}
1485
1492
1486
1493
// / 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;
1489
1496
}
1490
1497
1491
1498
// / Return true if the specified load with extension is legal or custom
1492
1499
// / 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;
1496
1503
}
1497
1504
1498
1505
// / Same as getLoadExtAction, but for atomic loads.
@@ -2634,13 +2641,15 @@ class LLVM_ABI TargetLoweringBase {
2634
2641
// / Indicate that the specified load with extension does not work with the
2635
2642
// / specified type and indicate what to do about it.
2636
2643
void setLoadExtAction (unsigned ExtType, MVT ValVT, MVT MemVT,
2637
- LegalizeAction Action) {
2644
+ LegalizeAction Action, unsigned AddrSpace ) {
2638
2645
assert (ExtType < ISD::LAST_LOADEXT_TYPE && ValVT.isValid () &&
2639
2646
MemVT.isValid () && " Table isn't big enough!" );
2640
2647
assert ((unsigned )Action < 0x10 && " too many bits for bitfield array" );
2641
2648
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;
2644
2653
}
2645
2654
void setLoadExtAction (ArrayRef<unsigned > ExtTypes, MVT ValVT, MVT MemVT,
2646
2655
LegalizeAction Action) {
@@ -3753,8 +3762,13 @@ class LLVM_ABI TargetLoweringBase {
3753
3762
// / For each load extension type and each value type, keep a LegalizeAction
3754
3763
// / that indicates how instruction selection should deal with a load of a
3755
3764
// / 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;
3758
3772
3759
3773
// / Similar to LoadExtActions, but for atomic loads. Only Legal or Expand
3760
3774
// / (default) values are supported.
0 commit comments