diff options
author | Akira Hatanaka <ahatanak@gmail.com> | 2011-05-26 18:59:03 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanak@gmail.com> | 2011-05-26 18:59:03 +0000 |
commit | cf0cd8005c81853ddea3ce26b71491c48dc4984e (patch) | |
tree | 8504fe1b3c8d40159cd615639cf06dcd359837f5 /lib/Target | |
parent | 32bfb2c513c4efdc1db9967ddfecce8c922dda4f (diff) | |
download | external_llvm-cf0cd8005c81853ddea3ce26b71491c48dc4984e.zip external_llvm-cf0cd8005c81853ddea3ce26b71491c48dc4984e.tar.gz external_llvm-cf0cd8005c81853ddea3ce26b71491c48dc4984e.tar.bz2 |
Add support for C++ exception handling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132131 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/Mips/MipsEmitGPRestore.cpp | 14 | ||||
-rw-r--r-- | lib/Target/Mips/MipsFrameLowering.cpp | 48 | ||||
-rw-r--r-- | lib/Target/Mips/MipsFrameLowering.h | 2 | ||||
-rw-r--r-- | lib/Target/Mips/MipsISelLowering.cpp | 8 | ||||
-rw-r--r-- | lib/Target/Mips/MipsMCAsmInfo.cpp | 6 | ||||
-rw-r--r-- | lib/Target/Mips/MipsRegisterInfo.cpp | 3 |
6 files changed, 68 insertions, 13 deletions
diff --git a/lib/Target/Mips/MipsEmitGPRestore.cpp b/lib/Target/Mips/MipsEmitGPRestore.cpp index 5b84ad8..f49d490 100644 --- a/lib/Target/Mips/MipsEmitGPRestore.cpp +++ b/lib/Target/Mips/MipsEmitGPRestore.cpp @@ -55,6 +55,20 @@ bool Inserter::runOnMachineFunction(MachineFunction &F) { MachineBasicBlock& MBB = *MFI; MachineBasicBlock::iterator I = MFI->begin(); + // If MBB is a landing pad, insert instruction that restores $gp after + // EH_LABEL. + if (MBB.isLandingPad()) { + // Find EH_LABEL first. + for (; I->getOpcode() != TargetOpcode::EH_LABEL; ++I) ; + + // Insert lw. + ++I; + DebugLoc dl = I != MBB.end() ? I->getDebugLoc() : DebugLoc(); + BuildMI(MBB, I, dl, TII->get(Mips::LW), Mips::GP).addImm(0) + .addFrameIndex(FI); + Changed = true; + } + while (I != MFI->end()) { if (I->getOpcode() != Mips::JALR) { ++I; diff --git a/lib/Target/Mips/MipsFrameLowering.cpp b/lib/Target/Mips/MipsFrameLowering.cpp index 41ad187..45a1e71 100644 --- a/lib/Target/Mips/MipsFrameLowering.cpp +++ b/lib/Target/Mips/MipsFrameLowering.cpp @@ -182,24 +182,49 @@ void MipsFrameLowering::emitPrologue(MachineFunction &MF) const { if (ATUsed) BuildMI(MBB, MBBI, dl, TII.get(Mips::ATMACRO)); - // if framepointer enabled, set it to point to the stack pointer. - if (hasFP(MF)) { - // Find the instruction past the last instruction that saves a callee-saved - // register to the stack. - const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); + // Find the instruction past the last instruction that saves a callee-saved + // register to the stack. + const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); - for (unsigned i = 0; i < CSI.size(); ++i) - ++MBBI; + for (unsigned i = 0; i < CSI.size(); ++i) + ++MBBI; + // if framepointer enabled, set it to point to the stack pointer. + if (hasFP(MF)) // Insert instruction "move $fp, $sp" at this location. BuildMI(MBB, MBBI, dl, TII.get(Mips::ADDu), Mips::FP) .addReg(Mips::SP).addReg(Mips::ZERO); - } // Restore GP from the saved stack location if (MipsFI->needGPSaveRestore()) BuildMI(MBB, MBBI, dl, TII.get(Mips::CPRESTORE)) .addImm(MFI->getObjectOffset(MipsFI->getGPFI())); + + // EH Frame infomation. + MachineModuleInfo &MMI = MF.getMMI(); + std::vector<MachineMove> &Moves = MMI.getFrameMoves(); + MCSymbol *FrameLabel = MMI.getContext().CreateTempSymbol(); + BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::PROLOG_LABEL)).addSym(FrameLabel); + + if (hasFP(MF)) { + MachineLocation SPDst(Mips::FP); + MachineLocation SPSrc(Mips::SP); + Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc)); + } + + if (StackSize) { + MachineLocation SPDst(MachineLocation::VirtualFP); + MachineLocation SPSrc(MachineLocation::VirtualFP, -StackSize); + Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc)); + } + + for (std::vector<CalleeSavedInfo>::const_iterator I = CSI.begin(), + E = CSI.end(); I != E; ++I) { + int64_t Offset = MFI->getObjectOffset(I->getFrameIdx()); + MachineLocation CSDst(MachineLocation::VirtualFP, Offset); + MachineLocation CSSrc(I->getReg()); + Moves.push_back(MachineMove(FrameLabel, CSDst, CSSrc)); + } } void MipsFrameLowering::emitEpilogue(MachineFunction &MF, @@ -243,6 +268,13 @@ void MipsFrameLowering::emitEpilogue(MachineFunction &MF, } } +void +MipsFrameLowering::getInitialFrameState(std::vector<MachineMove> &Moves) const { + MachineLocation Dst(MachineLocation::VirtualFP); + MachineLocation Src(Mips::SP, 0); + Moves.push_back(MachineMove(0, Dst, Src)); +} + void MipsFrameLowering:: processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS) const { diff --git a/lib/Target/Mips/MipsFrameLowering.h b/lib/Target/Mips/MipsFrameLowering.h index a778fde..78c78ee 100644 --- a/lib/Target/Mips/MipsFrameLowering.h +++ b/lib/Target/Mips/MipsFrameLowering.h @@ -39,6 +39,8 @@ public: bool hasFP(const MachineFunction &MF) const; + void getInitialFrameState(std::vector<MachineMove> &Moves) const; + void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS) const; }; diff --git a/lib/Target/Mips/MipsISelLowering.cpp b/lib/Target/Mips/MipsISelLowering.cpp index 834b1bf..4c42561 100644 --- a/lib/Target/Mips/MipsISelLowering.cpp +++ b/lib/Target/Mips/MipsISelLowering.cpp @@ -141,8 +141,9 @@ MipsTargetLowering(MipsTargetMachine &TM) setOperationAction(ISD::FLOG10, MVT::f32, Expand); setOperationAction(ISD::FEXP, MVT::f32, Expand); - setOperationAction(ISD::EH_LABEL, MVT::Other, Expand); - + setOperationAction(ISD::EXCEPTIONADDR, MVT::i32, Expand); + setOperationAction(ISD::EHSELECTION, MVT::i32, Expand); + setOperationAction(ISD::VAARG, MVT::Other, Expand); setOperationAction(ISD::VACOPY, MVT::Other, Expand); setOperationAction(ISD::VAEND, MVT::Other, Expand); @@ -176,6 +177,9 @@ MipsTargetLowering(MipsTargetMachine &TM) setStackPointerRegisterToSaveRestore(Mips::SP); computeRegisterProperties(); + + setExceptionPointerRegister(Mips::A0); + setExceptionSelectorRegister(Mips::A1); } MVT::SimpleValueType MipsTargetLowering::getSetCCResultType(EVT VT) const { diff --git a/lib/Target/Mips/MipsMCAsmInfo.cpp b/lib/Target/Mips/MipsMCAsmInfo.cpp index 73da9d4..c86bf40 100644 --- a/lib/Target/Mips/MipsMCAsmInfo.cpp +++ b/lib/Target/Mips/MipsMCAsmInfo.cpp @@ -17,11 +17,15 @@ using namespace llvm; MipsMCAsmInfo::MipsMCAsmInfo(const Target &T, StringRef TT) { AlignmentIsInBytes = false; Data16bitsDirective = "\t.half\t"; - Data32bitsDirective = "\t.word\t"; + Data32bitsDirective = "\t.4byte\t"; Data64bitsDirective = 0; PrivateGlobalPrefix = "$"; CommentString = "#"; ZeroDirective = "\t.space\t"; GPRel32Directive = "\t.gpword\t"; WeakRefDirective = "\t.weak\t"; + + SupportsDebugInformation = true; + ExceptionsType = ExceptionHandling::DwarfCFI; + HasLEB128 = true; } diff --git a/lib/Target/Mips/MipsRegisterInfo.cpp b/lib/Target/Mips/MipsRegisterInfo.cpp index be67065..7674c6d 100644 --- a/lib/Target/Mips/MipsRegisterInfo.cpp +++ b/lib/Target/Mips/MipsRegisterInfo.cpp @@ -283,8 +283,7 @@ getEHHandlerRegister() const { int MipsRegisterInfo:: getDwarfRegNum(unsigned RegNum, bool isEH) const { - llvm_unreachable("What is the dwarf register number"); - return -1; + return MipsGenRegisterInfo::getDwarfRegNumFull(RegNum, 0); } #include "MipsGenRegisterInfo.inc" |