diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
commit | 01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch) | |
tree | 4def12e759965de927d963ac65840d663ef9d1ea /lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp | |
parent | f0f4822ed4b66e3579e92a89f368f8fb860e218e (diff) | |
download | src-01095a5d43bbfde13731688ddcf6048ebb8b7721.tar.gz src-01095a5d43bbfde13731688ddcf6048ebb8b7721.zip |
Notes
Diffstat (limited to 'lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp')
-rw-r--r-- | lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp b/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp index 10fe606985dd..5a94cce4ce57 100644 --- a/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp +++ b/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp @@ -21,7 +21,6 @@ #include "HexagonSubtarget.h" #include "HexagonTargetMachine.h" #include "HexagonTargetObjectFile.h" -#include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/LatencyPriorityQueue.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineFunctionPass.h" @@ -32,14 +31,11 @@ #include "llvm/CodeGen/ScheduleDAGInstrs.h" #include "llvm/CodeGen/ScheduleHazardRecognizer.h" #include "llvm/CodeGen/SchedulerRegistry.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegisterInfo.h" -#include <map> using namespace llvm; @@ -61,6 +57,10 @@ class HexagonSplitConst32AndConst64 : public MachineFunctionPass { return "Hexagon Split Const32s and Const64s"; } bool runOnMachineFunction(MachineFunction &Fn) override; + MachineFunctionProperties getRequiredProperties() const override { + return MachineFunctionProperties().set( + MachineFunctionProperties::Property::AllVRegsAllocated); + } }; @@ -72,7 +72,7 @@ bool HexagonSplitConst32AndConst64::runOnMachineFunction(MachineFunction &Fn) { const HexagonTargetObjectFile &TLOF = *static_cast<const HexagonTargetObjectFile *>( Fn.getTarget().getObjFileLowering()); - if (TLOF.IsSmallDataEnabled()) + if (TLOF.isSmallDataEnabled()) return true; const TargetInstrInfo *TII = Fn.getSubtarget().getInstrInfo(); @@ -86,55 +86,56 @@ bool HexagonSplitConst32AndConst64::runOnMachineFunction(MachineFunction &Fn) { MachineBasicBlock::iterator MII = MBB->begin(); MachineBasicBlock::iterator MIE = MBB->end (); while (MII != MIE) { - MachineInstr *MI = MII; - int Opc = MI->getOpcode(); + MachineInstr &MI = *MII; + int Opc = MI.getOpcode(); if (Opc == Hexagon::CONST32_Int_Real && - MI->getOperand(1).isBlockAddress()) { - int DestReg = MI->getOperand(0).getReg(); - MachineOperand &Symbol = MI->getOperand (1); - - BuildMI (*MBB, MII, MI->getDebugLoc(), - TII->get(Hexagon::LO), DestReg).addOperand(Symbol); - BuildMI (*MBB, MII, MI->getDebugLoc(), - TII->get(Hexagon::HI), DestReg).addOperand(Symbol); + MI.getOperand(1).isBlockAddress()) { + int DestReg = MI.getOperand(0).getReg(); + MachineOperand &Symbol = MI.getOperand(1); + + BuildMI(*MBB, MII, MI.getDebugLoc(), TII->get(Hexagon::LO), DestReg) + .addOperand(Symbol); + BuildMI(*MBB, MII, MI.getDebugLoc(), TII->get(Hexagon::HI), DestReg) + .addOperand(Symbol); // MBB->erase returns the iterator to the next instruction, which is the // one we want to process next - MII = MBB->erase (MI); + MII = MBB->erase(&MI); continue; } else if (Opc == Hexagon::CONST32_Int_Real || Opc == Hexagon::CONST32_Float_Real) { - int DestReg = MI->getOperand(0).getReg(); + int DestReg = MI.getOperand(0).getReg(); // We have to convert an FP immediate into its corresponding integer // representation int64_t ImmValue; if (Opc == Hexagon::CONST32_Float_Real) { - APFloat Val = MI->getOperand(1).getFPImm()->getValueAPF(); + APFloat Val = MI.getOperand(1).getFPImm()->getValueAPF(); ImmValue = *Val.bitcastToAPInt().getRawData(); } else - ImmValue = MI->getOperand(1).getImm(); + ImmValue = MI.getOperand(1).getImm(); - BuildMI(*MBB, MII, MI->getDebugLoc(), - TII->get(Hexagon::A2_tfrsi), DestReg).addImm(ImmValue); - MII = MBB->erase (MI); + BuildMI(*MBB, MII, MI.getDebugLoc(), TII->get(Hexagon::A2_tfrsi), + DestReg) + .addImm(ImmValue); + MII = MBB->erase(&MI); continue; } else if (Opc == Hexagon::CONST64_Int_Real || Opc == Hexagon::CONST64_Float_Real) { - int DestReg = MI->getOperand(0).getReg(); + int DestReg = MI.getOperand(0).getReg(); // We have to convert an FP immediate into its corresponding integer // representation int64_t ImmValue; if (Opc == Hexagon::CONST64_Float_Real) { - APFloat Val = MI->getOperand(1).getFPImm()->getValueAPF(); + APFloat Val = MI.getOperand(1).getFPImm()->getValueAPF(); ImmValue = *Val.bitcastToAPInt().getRawData(); } else - ImmValue = MI->getOperand(1).getImm(); + ImmValue = MI.getOperand(1).getImm(); unsigned DestLo = TRI->getSubReg(DestReg, Hexagon::subreg_loreg); unsigned DestHi = TRI->getSubReg(DestReg, Hexagon::subreg_hireg); @@ -142,11 +143,13 @@ bool HexagonSplitConst32AndConst64::runOnMachineFunction(MachineFunction &Fn) { int32_t LowWord = (ImmValue & 0xFFFFFFFF); int32_t HighWord = (ImmValue >> 32) & 0xFFFFFFFF; - BuildMI(*MBB, MII, MI->getDebugLoc(), - TII->get(Hexagon::A2_tfrsi), DestLo).addImm(LowWord); - BuildMI (*MBB, MII, MI->getDebugLoc(), - TII->get(Hexagon::A2_tfrsi), DestHi).addImm(HighWord); - MII = MBB->erase (MI); + BuildMI(*MBB, MII, MI.getDebugLoc(), TII->get(Hexagon::A2_tfrsi), + DestLo) + .addImm(LowWord); + BuildMI(*MBB, MII, MI.getDebugLoc(), TII->get(Hexagon::A2_tfrsi), + DestHi) + .addImm(HighWord); + MII = MBB->erase(&MI); continue; } ++MII; |