OSDN Git Service

Support to provide exception and selector registers.
authorJim Laskey <jlaskey@mac.com>
Wed, 21 Feb 2007 22:54:50 +0000 (22:54 +0000)
committerJim Laskey <jlaskey@mac.com>
Wed, 21 Feb 2007 22:54:50 +0000 (22:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34482 91177308-0d34-0410-b5e6-96231b3b80d8

19 files changed:
include/llvm/Target/MRegisterInfo.h
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMRegisterInfo.cpp
lib/Target/ARM/ARMRegisterInfo.h
lib/Target/Alpha/AlphaISelLowering.cpp
lib/Target/Alpha/AlphaRegisterInfo.cpp
lib/Target/Alpha/AlphaRegisterInfo.h
lib/Target/IA64/IA64ISelLowering.cpp
lib/Target/IA64/IA64RegisterInfo.cpp
lib/Target/IA64/IA64RegisterInfo.h
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/PowerPC/PPCRegisterInfo.h
lib/Target/Sparc/SparcISelDAGToDAG.cpp
lib/Target/Sparc/SparcRegisterInfo.cpp
lib/Target/Sparc/SparcRegisterInfo.h
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86RegisterInfo.cpp
lib/Target/X86/X86RegisterInfo.h

index da111e6..3e38ccc 100644 (file)
@@ -469,7 +469,15 @@ public:
   /// getRARegister - This method should return the register where the return
   /// address can be found.
   virtual unsigned getRARegister() const = 0;
-                            
+  
+  /// getEHExceptionRegister - This method should return the register containing
+  /// the address of the exception info on entry to a landing pad.
+  virtual unsigned getEHExceptionRegister() const = 0;
+  
+  /// getEHHandlerRegister - This method should return the register containing
+  /// the switch table selection on entry to an landing pad.
+  virtual unsigned getEHHandlerRegister() const = 0;
+
   /// getLocation - This method should return the actual location of a frame
   /// variable given the frame index.  The location is returned in ML.
   /// Subclasses should override this method for special handling of frame
index 90d02b8..37b1feb 100644 (file)
@@ -1190,6 +1190,9 @@ SDOperand ARMTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
     return LowerFORMAL_ARGUMENTS(Op, DAG);
   case ISD::RETURNADDR:    break;
   case ISD::FRAMEADDR:     break;
+  // Exception address and exception selector.  Currently unimplemented.
+  case ISD::EXCEPTIONADDR: break;
+  case ISD::EHSELECTION:   break;
   }
   return SDOperand();
 }
index 41f5e46..9805892 100644 (file)
@@ -1287,5 +1287,15 @@ unsigned ARMRegisterInfo::getFrameRegister(MachineFunction &MF) const {
   return STI.useThumbBacktraces() ? ARM::R7 : ARM::R11;
 }
 
+unsigned ARMRegisterInfo::getEHExceptionRegister() const {
+  assert(0 && "What is the exception register");
+  return 0;
+}
+
+unsigned ARMRegisterInfo::getEHHandlerRegister() const {
+  assert(0 && "What is the exception handler register");
+  return 0;
+}
+
 #include "ARMGenRegisterInfo.inc"
 
index d5c8021..35674ef 100644 (file)
@@ -85,6 +85,10 @@ public:
   // Debug information queries.
   unsigned getRARegister() const;
   unsigned getFrameRegister(MachineFunction &MF) const;
+
+  // Exception handling queries.
+  unsigned getEHExceptionRegister() const;
+  unsigned getEHHandlerRegister() const;
 };
 
 } // end namespace llvm
index 1674d44..12b299a 100644 (file)
@@ -548,8 +548,11 @@ SDOperand AlphaTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
     return DAG.getNode(AlphaISD::GlobalRetAddr, MVT::i64);
       //FIXME: implement
   case ISD::FRAMEADDR:          break;
+  // Exception address and exception selector.  Currently unimplemented.
+  case ISD::EXCEPTIONADDR: break;
+  case ISD::EHSELECTION:   break;
   }
-
+  
   return SDOperand();
 }
 
index f08195e..d6260e8 100644 (file)
@@ -399,6 +399,16 @@ unsigned AlphaRegisterInfo::getFrameRegister(MachineFunction &MF) const {
   return hasFP(MF) ? Alpha::R15 : Alpha::R30;
 }
 
+unsigned AlphaRegisterInfo::getEHExceptionRegister() const {
+  assert(0 && "What is the exception register");
+  return 0;
+}
+
+unsigned AlphaRegisterInfo::getEHHandlerRegister() const {
+  assert(0 && "What is the exception handler register");
+  return 0;
+}
+
 #include "AlphaGenRegisterInfo.inc"
 
 std::string AlphaRegisterInfo::getPrettyName(unsigned reg)
index 4629aaa..b1642f4 100644 (file)
@@ -68,6 +68,10 @@ struct AlphaRegisterInfo : public AlphaGenRegisterInfo {
   unsigned getRARegister() const;
   unsigned getFrameRegister(MachineFunction &MF) const;
 
+  // Exception handling queries.
+  unsigned getEHExceptionRegister() const;
+  unsigned getEHHandlerRegister() const;
+
   static std::string getPrettyName(unsigned reg);
 };
 
index 1c7c51d..9a1c57b 100644 (file)
@@ -590,6 +590,9 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) {
   // Frame & Return address.  Currently unimplemented
   case ISD::RETURNADDR:         break;
   case ISD::FRAMEADDR:          break;
+  // Exception address and exception selector.  Currently unimplemented.
+  case ISD::EXCEPTIONADDR: break;
+  case ISD::EHSELECTION:   break;
   }
   return SDOperand();
 }
index f5f8226..1e451c4 100644 (file)
@@ -360,5 +360,15 @@ unsigned IA64RegisterInfo::getFrameRegister(MachineFunction &MF) const {
   return hasFP(MF) ? IA64::r5 : IA64::r12;
 }
 
+unsigned IA64RegisterInfo::getEHExceptionRegister() const {
+  assert(0 && "What is the exception register");
+  return 0;
+}
+
+unsigned IA64RegisterInfo::getEHHandlerRegister() const {
+  assert(0 && "What is the exception handler register");
+  return 0;
+}
+
 #include "IA64GenRegisterInfo.inc"
 
index 9a97712..17df2e9 100644 (file)
@@ -64,6 +64,10 @@ struct IA64RegisterInfo : public IA64GenRegisterInfo {
   // Debug information queries.
   unsigned getRARegister() const;
   unsigned getFrameRegister(MachineFunction &MF) const;
+
+  // Exception handling queries.
+  unsigned getEHExceptionRegister() const;
+  unsigned getEHHandlerRegister() const;
 };
 
 } // End llvm namespace
index f8c970e..9c2867e 100644 (file)
@@ -2610,6 +2610,30 @@ static SDOperand LowerMUL(SDOperand Op, SelectionDAG &DAG) {
   }
 }
 
+/// LowerEXCEPTIONADDR - Replace EXCEPTIONADDR with a copy from the exception
+/// register.  The register was made live in the ISel.
+static SDOperand LowerEXCEPTIONADDR(SDOperand Op, SelectionDAG &DAG) {
+  const MRegisterInfo *MRI = DAG.getTargetLoweringInfo().
+                                 getTargetMachine().
+                                 getRegisterInfo();
+  MVT::ValueType VT = Op.Val->getValueType(0);
+  unsigned Reg = MRI->getEHExceptionRegister();
+  SDOperand Result = DAG.getCopyFromReg(Op.getOperand(0), Reg, VT);
+  return Result.getValue(Op.ResNo);
+}
+
+/// LowerEXCEPTIONADDR - Replace EHSELECTION with a copy from the exception
+/// selection register.  The register was made live in the ISel.
+static SDOperand LowerEHSELECTION(SDOperand Op, SelectionDAG &DAG) {
+  const MRegisterInfo *MRI = DAG.getTargetLoweringInfo().
+                                 getTargetMachine().
+                                 getRegisterInfo();
+  MVT::ValueType VT = Op.Val->getValueType(0);
+  unsigned Reg = MRI->getEHHandlerRegister();
+  SDOperand Result = DAG.getCopyFromReg(Op.getOperand(1), Reg, VT);
+  return Result.getValue(Op.ResNo);
+}
+
 /// LowerOperation - Provide custom lowering hooks for some operations.
 ///
 SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
@@ -2647,6 +2671,10 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
   // Frame & Return address.  Currently unimplemented
   case ISD::RETURNADDR:         break;
   case ISD::FRAMEADDR:          break;
+  
+  // Exception address and exception selector.
+  case ISD::EXCEPTIONADDR:      return LowerEXCEPTIONADDR(Op, DAG);
+  case ISD::EHSELECTION:        return LowerEHSELECTION(Op, DAG);
   }
   return SDOperand();
 }
index 7553634..38e57da 100644 (file)
@@ -1022,7 +1022,6 @@ void PPCRegisterInfo::emitEpilogue(MachineFunction &MF,
 
 unsigned PPCRegisterInfo::getRARegister() const {
   return !Subtarget.isPPC64() ? PPC::LR : PPC::LR8;
-  
 }
 
 unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const {
@@ -1040,5 +1039,13 @@ void PPCRegisterInfo::getInitialFrameState(std::vector<MachineMove> &Moves)
   Moves.push_back(MachineMove(0, Dst, Src));
 }
 
+unsigned PPCRegisterInfo::getEHExceptionRegister() const {
+  return !Subtarget.isPPC64() ? PPC::R3 : PPC::X3;
+}
+
+unsigned PPCRegisterInfo::getEHHandlerRegister() const {
+  return !Subtarget.isPPC64() ? PPC::R4 : PPC::X4;
+}
+
 #include "PPCGenRegisterInfo.inc"
 
index 6c30f6b..eedb627 100644 (file)
@@ -89,6 +89,10 @@ public:
   unsigned getRARegister() const;
   unsigned getFrameRegister(MachineFunction &MF) const;
   void getInitialFrameState(std::vector<MachineMove> &Moves) const;
+
+  // Exception handling queries.
+  unsigned getEHExceptionRegister() const;
+  unsigned getEHHandlerRegister() const;
 };
 
 } // end namespace llvm
index 647007e..59c7901 100644 (file)
@@ -871,6 +871,9 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) {
   // Frame & Return address.  Currently unimplemented
   case ISD::RETURNADDR:         break;
   case ISD::FRAMEADDR:          break;
+  // Exception address and exception selector.  Currently unimplemented.
+  case ISD::EXCEPTIONADDR: break;
+  case ISD::EHSELECTION:   break;
   }
   return SDOperand();
 }
index dab0b10..4ea31e2 100644 (file)
@@ -250,5 +250,15 @@ unsigned SparcRegisterInfo::getFrameRegister(MachineFunction &MF) const {
   return SP::G1;
 }
 
+unsigned SparcRegisterInfo::getEHExceptionRegister() const {
+  assert(0 && "What is the exception register");
+  return 0;
+}
+
+unsigned SparcRegisterInfo::getEHHandlerRegister() const {
+  assert(0 && "What is the exception handler register");
+  return 0;
+}
+
 #include "SparcGenRegisterInfo.inc"
 
index 763156a..426cc66 100644 (file)
@@ -70,6 +70,10 @@ struct SparcRegisterInfo : public SparcGenRegisterInfo {
   // Debug information queries.
   unsigned getRARegister() const;
   unsigned getFrameRegister(MachineFunction &MF) const;
+
+  // Exception handling queries.
+  unsigned getEHExceptionRegister() const;
+  unsigned getEHHandlerRegister() const;
 };
 
 } // end namespace llvm
index 839eb8a..801c22d 100644 (file)
@@ -4675,7 +4675,11 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
   case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG);
   case ISD::RETURNADDR:         return LowerRETURNADDR(Op, DAG);
   case ISD::FRAMEADDR:          return LowerFRAMEADDR(Op, DAG);
+  // Exception address and exception selector.  Currently unimplemented.
+  case ISD::EXCEPTIONADDR: break;
+  case ISD::EHSELECTION:   break;
   }
+  return SDOperand();
 }
 
 const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const {
index 65e847e..75a2c75 100644 (file)
@@ -1193,6 +1193,16 @@ void X86RegisterInfo::getInitialFrameState(std::vector<MachineMove> &Moves)
   Moves.push_back(MachineMove(0, Dst, Src));
 }
 
+unsigned X86RegisterInfo::getEHExceptionRegister() const {
+  assert(0 && "What is the exception register");
+  return 0;
+}
+
+unsigned X86RegisterInfo::getEHHandlerRegister() const {
+  assert(0 && "What is the exception handler register");
+  return 0;
+}
+
 namespace llvm {
 unsigned getX86SubSuperRegister(unsigned Reg, MVT::ValueType VT, bool High) {
   switch (VT) {
index d504675..5516616 100644 (file)
@@ -101,6 +101,10 @@ public:
   unsigned getRARegister() const;
   unsigned getFrameRegister(MachineFunction &MF) const;
   void getInitialFrameState(std::vector<MachineMove> &Moves) const;
+
+  // Exception handling queries.
+  unsigned getEHExceptionRegister() const;
+  unsigned getEHHandlerRegister() const;
 };
 
 // getX86SubSuperRegister - X86 utility function. It returns the sub or super