summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips/MipsInstructionSelector.cpp
diff options
context:
space:
mode:
authorPetar Avramovic <Petar.Avramovic@rt-rk.com>2019-07-10 12:55:21 +0000
committerPetar Avramovic <Petar.Avramovic@rt-rk.com>2019-07-10 12:55:21 +0000
commit7b31491ae23ac565143d82636268d075f561087d (patch)
tree1a933ef9a1de5574779203bf8abf972ddbee6c87 /llvm/lib/Target/Mips/MipsInstructionSelector.cpp
parent2bf04f25ff0d56710e12228a00fdd60501d7746e (diff)
downloadbcm5719-llvm-7b31491ae23ac565143d82636268d075f561087d.tar.gz
bcm5719-llvm-7b31491ae23ac565143d82636268d075f561087d.zip
[MIPS GlobalISel] Select float and double load and store
Select float and double load and store for MIPS32. Differential Revision: https://reviews.llvm.org/D64419 llvm-svn: 365626
Diffstat (limited to 'llvm/lib/Target/Mips/MipsInstructionSelector.cpp')
-rw-r--r--llvm/lib/Target/Mips/MipsInstructionSelector.cpp66
1 files changed, 44 insertions, 22 deletions
diff --git a/llvm/lib/Target/Mips/MipsInstructionSelector.cpp b/llvm/lib/Target/Mips/MipsInstructionSelector.cpp
index 8e597dc5e27..b7a995529b7 100644
--- a/llvm/lib/Target/Mips/MipsInstructionSelector.cpp
+++ b/llvm/lib/Target/Mips/MipsInstructionSelector.cpp
@@ -139,30 +139,49 @@ bool MipsInstructionSelector::materialize32BitImm(Register DestReg, APInt Imm,
}
/// Returning Opc indicates that we failed to select MIPS instruction opcode.
-static unsigned selectLoadStoreOpCode(unsigned Opc, unsigned MemSizeInBytes) {
- if (Opc == TargetOpcode::G_STORE)
- 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.
+static unsigned selectLoadStoreOpCode(unsigned Opc, unsigned MemSizeInBytes,
+ unsigned RegBank, bool isFP64) {
+ bool isStore = Opc == TargetOpcode::G_STORE;
+ if (RegBank == Mips::GPRBRegBankID) {
+ if (isStore)
+ 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;
+ case 2:
+ return Opc == TargetOpcode::G_SEXTLOAD ? Mips::LH : Mips::LHu;
+ case 1:
+ return Opc == TargetOpcode::G_SEXTLOAD ? Mips::LB : Mips::LBu;
+ default:
+ return Opc;
+ }
+ }
+
+ if (RegBank == Mips::FPRBRegBankID) {
switch (MemSizeInBytes) {
case 4:
- return Mips::LW;
- case 2:
- return Opc == TargetOpcode::G_SEXTLOAD ? Mips::LH : Mips::LHu;
- case 1:
- return Opc == TargetOpcode::G_SEXTLOAD ? Mips::LB : Mips::LBu;
+ return isStore ? Mips::SWC1 : Mips::LWC1;
+ case 8:
+ if (isFP64)
+ return isStore ? Mips::SDC164 : Mips::LDC164;
+ else
+ return isStore ? Mips::SDC1 : Mips::LDC1;
default:
return Opc;
}
+ }
+ return Opc;
}
bool MipsInstructionSelector::select(MachineInstr &I,
@@ -262,11 +281,14 @@ bool MipsInstructionSelector::select(MachineInstr &I,
const unsigned OpSize = MRI.getType(DestReg).getSizeInBits();
const unsigned OpMemSizeInBytes = (*I.memoperands_begin())->getSize();
- if (DestRegBank != Mips::GPRBRegBankID || OpSize != 32)
+ if (DestRegBank == Mips::GPRBRegBankID && OpSize != 32)
+ return false;
+
+ if (DestRegBank == Mips::FPRBRegBankID && OpSize != 32 && OpSize != 64)
return false;
- const unsigned NewOpc =
- selectLoadStoreOpCode(I.getOpcode(), OpMemSizeInBytes);
+ const unsigned NewOpc = selectLoadStoreOpCode(
+ I.getOpcode(), OpMemSizeInBytes, DestRegBank, STI.isFP64bit());
if (NewOpc == I.getOpcode())
return false;
OpenPOWER on IntegriCloud