Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- PPCFrameLowering.h - Define frame lowering for PowerPC --*- C++ -*-===// |
Misha Brukman | b440243 | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 2 | // |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | b440243 | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 7 | // |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // |
Nate Begeman | 6cca84e | 2005-10-16 05:39:50 +0000 | [diff] [blame] | 11 | //===----------------------------------------------------------------------===// |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 12 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 13 | #ifndef LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H |
| 14 | #define LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 15 | |
Chris Lattner | bfca1ab | 2005-10-14 23:51:18 +0000 | [diff] [blame] | 16 | #include "PPC.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/STLExtras.h" |
Anton Korobeynikov | 2f93128 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetFrameLowering.h" |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetMachine.h" |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
Eric Christopher | d104c31 | 2014-06-12 20:54:11 +0000 | [diff] [blame] | 22 | class PPCSubtarget; |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 23 | |
Anton Korobeynikov | 2f93128 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 24 | class PPCFrameLowering: public TargetFrameLowering { |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 25 | const PPCSubtarget &Subtarget; |
Eric Christopher | f71609b | 2015-02-13 00:39:27 +0000 | [diff] [blame] | 26 | const unsigned ReturnSaveOffset; |
Eric Christopher | 736d39e | 2015-02-13 00:39:36 +0000 | [diff] [blame] | 27 | const unsigned TOCSaveOffset; |
Eric Christopher | dc3a8a4 | 2015-02-13 00:39:38 +0000 | [diff] [blame] | 28 | const unsigned FramePointerSaveOffset; |
Eric Christopher | a4ae213 | 2015-02-13 22:22:57 +0000 | [diff] [blame] | 29 | const unsigned LinkageSize; |
Eric Christopher | fcd3d87 | 2015-02-13 22:48:53 +0000 | [diff] [blame] | 30 | const unsigned BasePointerSaveOffset; |
Misha Brukman | b440243 | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 31 | |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 32 | public: |
Eric Christopher | d104c31 | 2014-06-12 20:54:11 +0000 | [diff] [blame] | 33 | PPCFrameLowering(const PPCSubtarget &STI); |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 34 | |
Hal Finkel | bb420f1 | 2013-03-15 05:06:04 +0000 | [diff] [blame] | 35 | unsigned determineFrameLayout(MachineFunction &MF, |
| 36 | bool UpdateMF = true, |
| 37 | bool UseEstimate = false) const; |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 38 | |
| 39 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 40 | /// the function. |
Quentin Colombet | 61b305e | 2015-05-05 17:38:16 +0000 | [diff] [blame] | 41 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 42 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 43 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 44 | bool hasFP(const MachineFunction &MF) const override; |
Anton Korobeynikov | 3eb4fed | 2010-12-18 19:53:14 +0000 | [diff] [blame] | 45 | bool needsFP(const MachineFunction &MF) const; |
Hal Finkel | aa03c03 | 2013-03-21 19:03:19 +0000 | [diff] [blame] | 46 | void replaceFPWithRealFP(MachineFunction &MF) const; |
Anton Korobeynikov | 0eecf5d | 2010-11-18 21:19:35 +0000 | [diff] [blame] | 47 | |
Matthias Braun | 0256486 | 2015-07-14 17:17:13 +0000 | [diff] [blame] | 48 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
| 49 | RegScavenger *RS = nullptr) const override; |
Hal Finkel | 5a765fd | 2013-03-14 20:33:40 +0000 | [diff] [blame] | 50 | void processFunctionBeforeFrameFinalized(MachineFunction &MF, |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 51 | RegScavenger *RS = nullptr) const override; |
Hal Finkel | bb420f1 | 2013-03-15 05:06:04 +0000 | [diff] [blame] | 52 | void addScavengingSpillSlot(MachineFunction &MF, RegScavenger *RS) const; |
Anton Korobeynikov | 7283b8d | 2010-11-27 23:05:25 +0000 | [diff] [blame] | 53 | |
Roman Divacky | c9e23d9 | 2012-09-12 14:47:47 +0000 | [diff] [blame] | 54 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 55 | MachineBasicBlock::iterator MI, |
| 56 | const std::vector<CalleeSavedInfo> &CSI, |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 57 | const TargetRegisterInfo *TRI) const override; |
Roman Divacky | c9e23d9 | 2012-09-12 14:47:47 +0000 | [diff] [blame] | 58 | |
Eli Bendersky | 8da8716 | 2013-02-21 20:05:00 +0000 | [diff] [blame] | 59 | void eliminateCallFramePseudoInstr(MachineFunction &MF, |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 60 | MachineBasicBlock &MBB, |
| 61 | MachineBasicBlock::iterator I) const override; |
Eli Bendersky | 8da8716 | 2013-02-21 20:05:00 +0000 | [diff] [blame] | 62 | |
Roman Divacky | c9e23d9 | 2012-09-12 14:47:47 +0000 | [diff] [blame] | 63 | bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 64 | MachineBasicBlock::iterator MI, |
| 65 | const std::vector<CalleeSavedInfo> &CSI, |
| 66 | const TargetRegisterInfo *TRI) const override; |
Roman Divacky | c9e23d9 | 2012-09-12 14:47:47 +0000 | [diff] [blame] | 67 | |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 68 | /// targetHandlesStackFrameRounding - Returns true if the target is |
| 69 | /// responsible for rounding up the stack frame (probably at emitPrologue |
| 70 | /// time). |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 71 | bool targetHandlesStackFrameRounding() const override { return true; } |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 72 | |
Jim Laskey | 527c12f | 2006-12-06 17:42:06 +0000 | [diff] [blame] | 73 | /// getReturnSaveOffset - Return the previous frame offset to save the |
| 74 | /// return address. |
Eric Christopher | f71609b | 2015-02-13 00:39:27 +0000 | [diff] [blame] | 75 | unsigned getReturnSaveOffset() const { return ReturnSaveOffset; } |
Jim Laskey | 527c12f | 2006-12-06 17:42:06 +0000 | [diff] [blame] | 76 | |
Ulrich Weigand | ad0cb91 | 2014-06-18 17:52:49 +0000 | [diff] [blame] | 77 | /// getTOCSaveOffset - Return the previous frame offset to save the |
| 78 | /// TOC register -- 64-bit SVR4 ABI only. |
Eric Christopher | 736d39e | 2015-02-13 00:39:36 +0000 | [diff] [blame] | 79 | unsigned getTOCSaveOffset() const { return TOCSaveOffset; } |
Ulrich Weigand | ad0cb91 | 2014-06-18 17:52:49 +0000 | [diff] [blame] | 80 | |
Jim Laskey | 48850c1 | 2006-11-16 22:43:37 +0000 | [diff] [blame] | 81 | /// getFramePointerSaveOffset - Return the previous frame offset to save the |
| 82 | /// frame pointer. |
Eric Christopher | dc3a8a4 | 2015-02-13 00:39:38 +0000 | [diff] [blame] | 83 | unsigned getFramePointerSaveOffset() const { return FramePointerSaveOffset; } |
Anton Korobeynikov | a5ab8f1 | 2010-11-15 00:06:05 +0000 | [diff] [blame] | 84 | |
Hal Finkel | a7c54e8 | 2013-07-17 00:45:52 +0000 | [diff] [blame] | 85 | /// getBasePointerSaveOffset - Return the previous frame offset to save the |
| 86 | /// base pointer. |
Eric Christopher | fcd3d87 | 2015-02-13 22:48:53 +0000 | [diff] [blame] | 87 | unsigned getBasePointerSaveOffset() const { return BasePointerSaveOffset; } |
Hal Finkel | a7c54e8 | 2013-07-17 00:45:52 +0000 | [diff] [blame] | 88 | |
Jim Laskey | 48850c1 | 2006-11-16 22:43:37 +0000 | [diff] [blame] | 89 | /// getLinkageSize - Return the size of the PowerPC ABI linkage area. |
| 90 | /// |
Eric Christopher | a4ae213 | 2015-02-13 22:22:57 +0000 | [diff] [blame] | 91 | unsigned getLinkageSize() const { return LinkageSize; } |
Jim Laskey | 48850c1 | 2006-11-16 22:43:37 +0000 | [diff] [blame] | 92 | |
Tilmann Scheller | 336e2bd | 2009-09-27 17:58:47 +0000 | [diff] [blame] | 93 | const SpillSlot * |
Eric Christopher | d104c31 | 2014-06-12 20:54:11 +0000 | [diff] [blame] | 94 | getCalleeSavedSpillSlots(unsigned &NumEntries) const override; |
Kit Barton | d3b904d | 2015-09-10 01:55:44 +0000 | [diff] [blame^] | 95 | |
| 96 | bool enableShrinkWrapping(const MachineFunction &MF) const override; |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 97 | }; |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 98 | } // End llvm namespace |
Nate Begeman | 412602d | 2004-08-14 22:16:36 +0000 | [diff] [blame] | 99 | |
| 100 | #endif |