Added JumpTable support
Fixed some AsmPrinter issues
Added GLOBAL_OFFSET_TABLE Node handle.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44024 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/Mips/MipsISelDAGToDAG.cpp b/lib/Target/Mips/MipsISelDAGToDAG.cpp
index 6165d58..a2c1a0b 100644
--- a/lib/Target/Mips/MipsISelDAGToDAG.cpp
+++ b/lib/Target/Mips/MipsISelDAGToDAG.cpp
@@ -78,6 +78,7 @@
// Include the pieces autogenerated from the target description.
#include "MipsGenDAGISel.inc"
+ SDOperand getGlobalBaseReg();
SDNode *Select(SDOperand N);
// Complex Pattern.
@@ -124,6 +125,23 @@
ScheduleAndEmitDAG(SD);
}
+/// getGlobalBaseReg - Output the instructions required to put the
+/// GOT address into a register.
+SDOperand MipsDAGToDAGISel::getGlobalBaseReg()
+{
+ MachineFunction* MF = BB->getParent();
+ unsigned GP = 0;
+ for(MachineFunction::livein_iterator ii = MF->livein_begin(),
+ ee = MF->livein_end(); ii != ee; ++ii)
+ if (ii->first == Mips::GP) {
+ GP = ii->second;
+ break;
+ }
+ assert(GP && "GOT PTR not in liveins");
+ return CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
+ GP, MVT::i32);
+}
+
/// ComplexPattern used on MipsInstrInfo
/// Used on Mips Load/Store instructions
bool MipsDAGToDAGISel::
@@ -138,7 +156,8 @@
// on PIC code Load GA
if (TM.getRelocationModel() == Reloc::PIC_) {
- if (Addr.getOpcode() == ISD::TargetGlobalAddress) {
+ if ((Addr.getOpcode() == ISD::TargetGlobalAddress) ||
+ (Addr.getOpcode() == ISD::TargetJumpTable)){
Base = CurDAG->getRegister(Mips::GP, MVT::i32);
Offset = Addr;
return true;
@@ -253,6 +272,13 @@
return CurDAG->getTargetNode(Mips::MFHI, MVT::i32, MFInFlag);
}
+ // Get target GOT address.
+ case ISD::GLOBAL_OFFSET_TABLE: {
+ SDOperand Result = getGlobalBaseReg();
+ ReplaceUses(N, Result);
+ return NULL;
+ }
+
/// Handle direct and indirect calls when using PIC. On PIC, when
/// GOT is smaller than about 64k (small code) the GA target is
/// loaded with only one instruction. Otherwise GA's target must