diff options
| author | Petar Avramovic <Petar.Avramovic@rt-rk.com> | 2019-02-08 14:27:23 +0000 |
|---|---|---|
| committer | Petar Avramovic <Petar.Avramovic@rt-rk.com> | 2019-02-08 14:27:23 +0000 |
| commit | c98b26d32685dfc2d55d50b6dd584a1a97183abf (patch) | |
| tree | 30af6d302fd40306438c23fdc6a1d4a1d5f44716 /llvm/lib | |
| parent | e44c21f5a4219ce61939376e79e40bb4bebc32f2 (diff) | |
| download | bcm5719-llvm-c98b26d32685dfc2d55d50b6dd584a1a97183abf.tar.gz bcm5719-llvm-c98b26d32685dfc2d55d50b6dd584a1a97183abf.zip | |
[MIPS GlobalISel] Select any extending load and truncating store
Make behavior of G_LOAD in widenScalar same as for G_ZEXTLOAD and
G_SEXTLOAD. That is perform widenScalarDst to size given by the target
and avoid additional checks in common code. Targets can reorder or add
additional rules in LegalizeRuleSet for the opcode to achieve desired
behavior.
Select extending load that does not have specified type of extension
into zero extending load.
Select truncating store that stores number of bytes indicated by size
in MachineMemoperand.
Differential Revision: https://reviews.llvm.org/D57454
llvm-svn: 353520
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsInstructionSelector.cpp | 5 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsLegalizerInfo.cpp | 6 |
3 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp index b01cb27bfad..367afc62a25 100644 --- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp @@ -1208,13 +1208,6 @@ LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) { return Legalized; case TargetOpcode::G_LOAD: - // For some types like i24, we might try to widen to i32. To properly handle - // this we should be using a dedicated extending load, until then avoid - // trying to legalize. - if (alignTo(MRI.getType(MI.getOperand(0).getReg()).getSizeInBits(), 8) != - WideTy.getSizeInBits()) - return UnableToLegalize; - LLVM_FALLTHROUGH; case TargetOpcode::G_SEXTLOAD: case TargetOpcode::G_ZEXTLOAD: Observer.changingInstr(MI); diff --git a/llvm/lib/Target/Mips/MipsInstructionSelector.cpp b/llvm/lib/Target/Mips/MipsInstructionSelector.cpp index eb8c919d38c..2ea76f51874 100644 --- a/llvm/lib/Target/Mips/MipsInstructionSelector.cpp +++ b/llvm/lib/Target/Mips/MipsInstructionSelector.cpp @@ -96,10 +96,15 @@ static unsigned selectLoadStoreOpCode(unsigned Opc, unsigned MemSizeInBytes) { switch (MemSizeInBytes) { case 4: return Mips::SW; + case 2: + return Mips::SH; + case 1: + return Mips::SB; default: return Opc; } else + // Unspecified extending load is selected into zeroExtending load. switch (MemSizeInBytes) { case 4: return Mips::LW; diff --git a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp index e277b6194cc..2fe6c481091 100644 --- a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp +++ b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp @@ -36,7 +36,11 @@ MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) { .lowerFor({{s32, s1}}); getActionDefinitionsBuilder({G_LOAD, G_STORE}) - .legalForCartesianProduct({p0, s32}, {p0}); + .legalForTypesWithMemSize({{s32, p0, 8}, + {s32, p0, 16}, + {s32, p0, 32}, + {p0, p0, 32}}) + .minScalar(0, s32); getActionDefinitionsBuilder({G_ZEXTLOAD, G_SEXTLOAD}) .legalForTypesWithMemSize({{s32, p0, 8}, |

