| Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 1 | //===-- MipsMachineFunctionInfo.h - Private data used for Mips ----*- C++ -*-=// | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 2 | // | 
|  | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
| Chris Lattner | 4ee451d | 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. | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 7 | // | 
| Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 9 | // | 
|  | 10 | // This file declares the Mips specific subclass of MachineFunctionInfo. | 
|  | 11 | // | 
| Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 13 |  | 
|  | 14 | #ifndef MIPS_MACHINE_FUNCTION_INFO_H | 
|  | 15 | #define MIPS_MACHINE_FUNCTION_INFO_H | 
|  | 16 |  | 
| Akira Hatanaka | da0a357 | 2011-05-20 01:17:58 +0000 | [diff] [blame] | 17 | #include <utility> | 
| Dan Gohman | d68a076 | 2009-01-05 17:59:02 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SmallVector.h" | 
| Bruno Cardoso Lopes | 2d4575e | 2007-08-28 05:04:41 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/VectorExtras.h" | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineFunction.h" | 
| Bruno Cardoso Lopes | 2d4575e | 2007-08-28 05:04:41 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineFrameInfo.h" | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 22 |  | 
|  | 23 | namespace llvm { | 
|  | 24 |  | 
|  | 25 | /// MipsFunctionInfo - This class is derived from MachineFunction private | 
|  | 26 | /// Mips target-specific information for each MachineFunction. | 
|  | 27 | class MipsFunctionInfo : public MachineFunctionInfo { | 
|  | 28 |  | 
|  | 29 | private: | 
| Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 30 | /// SRetReturnReg - Some subtargets require that sret lowering includes | 
|  | 31 | /// returning the value of the returned struct in a register. This field | 
|  | 32 | /// holds the virtual register into which the sret argument is passed. | 
|  | 33 | unsigned SRetReturnReg; | 
|  | 34 |  | 
| Dan Gohman | 9911405 | 2009-06-03 20:30:14 +0000 | [diff] [blame] | 35 | /// GlobalBaseReg - keeps track of the virtual register initialized for | 
|  | 36 | /// use as the global base register. This is used for PIC in some PIC | 
|  | 37 | /// relocation models. | 
|  | 38 | unsigned GlobalBaseReg; | 
|  | 39 |  | 
| Dan Gohman | 1e93df6 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 40 | /// VarArgsFrameIndex - FrameIndex for start of varargs area. | 
|  | 41 | int VarArgsFrameIndex; | 
|  | 42 |  | 
| Akira Hatanaka | da0a357 | 2011-05-20 01:17:58 +0000 | [diff] [blame] | 43 | // Range of frame object indices. | 
|  | 44 | // InArgFIRange: Range of indices of all frame objects created during call to | 
|  | 45 | //               LowerFormalArguments. | 
|  | 46 | // OutArgFIRange: Range of indices of all frame objects created during call to | 
|  | 47 | //                LowerCall except for the frame object for restoring $gp. | 
|  | 48 | std::pair<int, int> InArgFIRange, OutArgFIRange; | 
|  | 49 | int GPFI; // Index of the frame object for restoring $gp | 
| Akira Hatanaka | f15f498 | 2011-05-25 17:52:48 +0000 | [diff] [blame] | 50 | unsigned MaxCallFrameSize; | 
| Bruno Cardoso Lopes | 4e694c9 | 2011-05-31 02:54:07 +0000 | [diff] [blame^] | 51 |  | 
|  | 52 | /// AtomicFrameIndex - To implement atomic.swap and atomic.cmp.swap | 
|  | 53 | /// intrinsics, it is necessary to use a temporary stack location. | 
|  | 54 | /// This field holds the frame index of this location. | 
|  | 55 | int AtomicFrameIndex; | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 56 | public: | 
| Che-Liang Chiou | acf1d48 | 2010-09-28 10:06:53 +0000 | [diff] [blame] | 57 | MipsFunctionInfo(MachineFunction& MF) | 
| Akira Hatanaka | f8928c0 | 2011-05-23 20:34:30 +0000 | [diff] [blame] | 58 | : SRetReturnReg(0), GlobalBaseReg(0), | 
| Akira Hatanaka | da0a357 | 2011-05-20 01:17:58 +0000 | [diff] [blame] | 59 | VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)), | 
| Bruno Cardoso Lopes | 4e694c9 | 2011-05-31 02:54:07 +0000 | [diff] [blame^] | 60 | OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), MaxCallFrameSize(0), | 
|  | 61 | AtomicFrameIndex(-1) | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 62 | {} | 
|  | 63 |  | 
| Akira Hatanaka | da0a357 | 2011-05-20 01:17:58 +0000 | [diff] [blame] | 64 | bool isInArgFI(int FI) const { | 
|  | 65 | return FI <= InArgFIRange.first && FI >= InArgFIRange.second; | 
|  | 66 | } | 
|  | 67 | void setLastInArgFI(int FI) { InArgFIRange.second = FI; } | 
|  | 68 |  | 
|  | 69 | bool isOutArgFI(int FI) const { | 
|  | 70 | return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second; | 
|  | 71 | } | 
|  | 72 | void extendOutArgFIRange(int FirstFI, int LastFI) { | 
|  | 73 | if (!OutArgFIRange.second) | 
|  | 74 | // this must be the first time this function was called. | 
|  | 75 | OutArgFIRange.first = FirstFI; | 
|  | 76 | OutArgFIRange.second = LastFI; | 
|  | 77 | } | 
|  | 78 |  | 
| Akira Hatanaka | 69c19f7 | 2011-05-23 20:16:59 +0000 | [diff] [blame] | 79 | int getGPFI() const { return GPFI; } | 
|  | 80 | void setGPFI(int FI) { GPFI = FI; } | 
|  | 81 | bool needGPSaveRestore() const { return getGPFI(); } | 
| Akira Hatanaka | da0a357 | 2011-05-20 01:17:58 +0000 | [diff] [blame] | 82 | bool isGPFI(int FI) const { return GPFI && GPFI == FI; } | 
| Bruno Cardoso Lopes | 0a60400 | 2007-10-09 03:01:19 +0000 | [diff] [blame] | 83 |  | 
| Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 84 | unsigned getSRetReturnReg() const { return SRetReturnReg; } | 
|  | 85 | void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } | 
| Dan Gohman | 9911405 | 2009-06-03 20:30:14 +0000 | [diff] [blame] | 86 |  | 
|  | 87 | unsigned getGlobalBaseReg() const { return GlobalBaseReg; } | 
|  | 88 | void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; } | 
| Dan Gohman | 1e93df6 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 89 |  | 
|  | 90 | int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } | 
|  | 91 | void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } | 
| Akira Hatanaka | da0a357 | 2011-05-20 01:17:58 +0000 | [diff] [blame] | 92 |  | 
| Akira Hatanaka | f15f498 | 2011-05-25 17:52:48 +0000 | [diff] [blame] | 93 | unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; } | 
|  | 94 | void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; } | 
| Bruno Cardoso Lopes | 4e694c9 | 2011-05-31 02:54:07 +0000 | [diff] [blame^] | 95 |  | 
|  | 96 | int getAtomicFrameIndex() const { return AtomicFrameIndex; } | 
|  | 97 | void setAtomicFrameIndex(int Index) { AtomicFrameIndex = Index; } | 
| Bruno Cardoso Lopes | 4215a59 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 98 | }; | 
|  | 99 |  | 
|  | 100 | } // end of namespace llvm | 
|  | 101 |  | 
| Bruno Cardoso Lopes | 2d4575e | 2007-08-28 05:04:41 +0000 | [diff] [blame] | 102 | #endif // MIPS_MACHINE_FUNCTION_INFO_H |