tstellar / rpms / llvm

Forked from rpms/llvm 2 years ago
Clone
23feda
Index: lib/Target/ARM/ARMFrameLowering.cpp
23feda
===================================================================
23feda
--- lib/Target/ARM/ARMFrameLowering.cpp	(revision 159085)
23feda
+++ lib/Target/ARM/ARMFrameLowering.cpp	(working copy)
23feda
@@ -15,6 +15,8 @@
23feda
 #include "ARMBaseInstrInfo.h"
23feda
 #include "ARMBaseRegisterInfo.h"
23feda
 #include "ARMMachineFunctionInfo.h"
23feda
+#include "llvm/CallingConv.h"
23feda
+#include "llvm/Function.h"
23feda
 #include "MCTargetDesc/ARMAddressingModes.h"
23feda
 #include "llvm/Function.h"
23feda
 #include "llvm/CodeGen/MachineFrameInfo.h"
23feda
@@ -151,6 +153,10 @@
23feda
   int FramePtrSpillFI = 0;
23feda
   int D8SpillFI = 0;
23feda
 
23feda
+  // All calls are tail calls in GHC calling conv, and functions have no prologue/epilogue.
23feda
+  if (MF.getFunction()->getCallingConv() == CallingConv::GHC)
23feda
+    return;
23feda
+
23feda
   // Allocate the vararg register save area. This is not counted in NumBytes.
23feda
   if (VARegSaveSize)
23feda
     emitSPUpdate(isARM, MBB, MBBI, dl, TII, -VARegSaveSize,
23feda
@@ -354,6 +360,10 @@
23feda
   int NumBytes = (int)MFI->getStackSize();
23feda
   unsigned FramePtr = RegInfo->getFrameRegister(MF);
23feda
 
23feda
+  // All calls are tail calls in GHC calling conv, and functions have no prologue/epilogue.
23feda
+  if (MF.getFunction()->getCallingConv() == CallingConv::GHC)
23feda
+    return;
23feda
+
23feda
   if (!AFI->hasStackFrame()) {
23feda
     if (NumBytes != 0)
23feda
       emitSPUpdate(isARM, MBB, MBBI, dl, TII, NumBytes);
23feda
Index: lib/Target/ARM/ARMISelLowering.cpp
23feda
===================================================================
23feda
--- lib/Target/ARM/ARMISelLowering.cpp	(revision 159085)
23feda
+++ lib/Target/ARM/ARMISelLowering.cpp	(working copy)
23feda
@@ -1171,6 +1171,8 @@
23feda
     return (Return ? RetCC_ARM_AAPCS : CC_ARM_AAPCS);
23feda
   case CallingConv::ARM_APCS:
23feda
     return (Return ? RetCC_ARM_APCS : CC_ARM_APCS);
23feda
+  case CallingConv::GHC:
23feda
+    return (Return ? RetCC_ARM_APCS : CC_ARM_APCS_GHC);
23feda
   }
23feda
 }
23feda
 
23feda
Index: lib/Target/ARM/ARMCallingConv.td
23feda
===================================================================
23feda
--- lib/Target/ARM/ARMCallingConv.td	(revision 159085)
23feda
+++ lib/Target/ARM/ARMCallingConv.td	(working copy)
23feda
@@ -79,7 +79,26 @@
23feda
   CCDelegateTo<retcc_arm_apcs>
23feda
 ]>;
23feda
 
23feda
+//===----------------------------------------------------------------------===//
23feda
+// ARM APCS Calling Convention for GHC
23feda
+//===----------------------------------------------------------------------===//
23feda
 
23feda
+def CC_ARM_APCS_GHC : CallingConv<[
23feda
+  // Handle all vector types as either f64 or v2f64.
23feda
+  CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
23feda
+  CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
23feda
+
23feda
+  CCIfType<[v2f64], CCAssignToReg<[Q4, Q5]>>,
23feda
+  CCIfType<[f64], CCAssignToReg<[D8, D9, D10, D11]>>,
23feda
+  CCIfType<[f32], CCAssignToReg<[S16, S17, S18, S19, S20, S21, S22, S23]>>,
23feda
+
23feda
+  // Promote i8/i16 arguments to i32.
23feda
+  CCIfType<[i8, i16], CCPromoteToType<i32>>,
23feda
+
23feda
+  // Pass in STG registers: Base, Sp, Hp, R1, R2, R3, R4, SpLim
23feda
+  CCIfType<[i32], CCAssignToReg<[R4, R5, R6, R7, R8, R9, R10, R11]>>
23feda
+]>;
23feda
+
23feda
 //===----------------------------------------------------------------------===//
23feda
 // ARM AAPCS (EABI) Calling Convention, common parts
23feda
 //===----------------------------------------------------------------------===//
23feda
@@ -171,3 +190,9 @@
23feda
 // iOS ABI deviates from ARM standard ABI. R9 is not a callee-saved register.
23feda
 // Also save R7-R4 first to match the stack frame fixed spill areas.
23feda
 def CSR_iOS : CalleeSavedRegs<(add LR, R7, R6, R5, R4, (sub CSR_AAPCS, R9))>;
23feda
+
23feda
+// GHC set of callee saved regs is empty as all those regs are
23feda
+// used for passing STG regs around
23feda
+// sub/add LR is a workaround for not being able to compile empty list:
23feda
+// def CSR_GHC : CalleeSavedRegs<()>;
23feda
+def CSR_GHC : CalleeSavedRegs<(sub (add LR), LR)>;
23feda
Index: lib/Target/ARM/ARMFastISel.cpp
23feda
===================================================================
23feda
--- lib/Target/ARM/ARMFastISel.cpp	(revision 159085)
23feda
+++ lib/Target/ARM/ARMFastISel.cpp	(working copy)
23feda
@@ -1835,6 +1835,11 @@
23feda
     return (Return ? RetCC_ARM_AAPCS: CC_ARM_AAPCS);
23feda
   case CallingConv::ARM_APCS:
23feda
     return (Return ? RetCC_ARM_APCS: CC_ARM_APCS);
23feda
+  case CallingConv::GHC:
23feda
+    if (Return)
23feda
+      llvm_unreachable("Can't return in GHC call convention");
23feda
+    else
23feda
+      return CC_ARM_APCS_GHC;
23feda
   }
23feda
 }
23feda
 
23feda
--- lib/Target/ARM/ARMBaseRegisterInfo.cpp.orig	2012-07-12 09:59:58.181723592 +0100
23feda
+++ lib/Target/ARM/ARMBaseRegisterInfo.cpp	2012-07-12 10:01:15.301344412 +0100
23feda
@@ -62,7 +62,19 @@
23feda
 
23feda
 const uint16_t*
23feda
 ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
23feda
-  return (STI.isTargetIOS()) ? CSR_iOS_SaveList : CSR_AAPCS_SaveList;
23feda
+  bool ghcCall = false;
23feda
+
23feda
+  if (MF) {
23feda
+    const Function *F = MF->getFunction();
23feda
+    ghcCall = (F ? F->getCallingConv() == CallingConv::GHC : false);
23feda
+  }
23feda
+
23feda
+  if (ghcCall) {
23feda
+      return CSR_GHC_SaveList;
23feda
+  }
23feda
+  else {
23feda
+      return (STI.isTargetIOS()) ? CSR_iOS_SaveList : CSR_AAPCS_SaveList;
23feda
+  }
23feda
 }
23feda
 
23feda
 const uint32_t*