Eugene Zelenko | e4fc6ee | 2017-07-26 23:20:35 +0000 | [diff] [blame] | 1 | //===- HexagonBitTracker.h --------------------------------------*- C++ -*-===// |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Eugene Zelenko | b2ca1b3 | 2017-01-04 02:02:05 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H |
| 11 | #define LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 12 | |
| 13 | #include "BitTracker.h" |
| 14 | #include "llvm/ADT/DenseMap.h" |
Eugene Zelenko | b2ca1b3 | 2017-01-04 02:02:05 +0000 | [diff] [blame] | 15 | #include <cstdint> |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 16 | |
| 17 | namespace llvm { |
Eugene Zelenko | b2ca1b3 | 2017-01-04 02:02:05 +0000 | [diff] [blame] | 18 | |
| 19 | class HexagonInstrInfo; |
| 20 | class HexagonRegisterInfo; |
Eugene Zelenko | e4fc6ee | 2017-07-26 23:20:35 +0000 | [diff] [blame] | 21 | class MachineFrameInfo; |
| 22 | class MachineFunction; |
| 23 | class MachineInstr; |
| 24 | class MachineRegisterInfo; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 25 | |
| 26 | struct HexagonEvaluator : public BitTracker::MachineEvaluator { |
Eugene Zelenko | e4fc6ee | 2017-07-26 23:20:35 +0000 | [diff] [blame] | 27 | using CellMapType = BitTracker::CellMapType; |
| 28 | using RegisterRef = BitTracker::RegisterRef; |
| 29 | using RegisterCell = BitTracker::RegisterCell; |
| 30 | using BranchTargetList = BitTracker::BranchTargetList; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 31 | |
Benjamin Kramer | d886151 | 2015-07-13 20:38:16 +0000 | [diff] [blame] | 32 | HexagonEvaluator(const HexagonRegisterInfo &tri, MachineRegisterInfo &mri, |
| 33 | const HexagonInstrInfo &tii, MachineFunction &mf); |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 34 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 35 | bool evaluate(const MachineInstr &MI, const CellMapType &Inputs, |
Benjamin Kramer | d886151 | 2015-07-13 20:38:16 +0000 | [diff] [blame] | 36 | CellMapType &Outputs) const override; |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 37 | bool evaluate(const MachineInstr &BI, const CellMapType &Inputs, |
Benjamin Kramer | d886151 | 2015-07-13 20:38:16 +0000 | [diff] [blame] | 38 | BranchTargetList &Targets, bool &FallsThru) const override; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 39 | |
Benjamin Kramer | d886151 | 2015-07-13 20:38:16 +0000 | [diff] [blame] | 40 | BitTracker::BitMask mask(unsigned Reg, unsigned Sub) const override; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 41 | |
Krzysztof Parzyszek | 7e604de | 2017-09-25 19:12:55 +0000 | [diff] [blame] | 42 | uint16_t getPhysRegBitWidth(unsigned Reg) const override; |
| 43 | |
| 44 | const TargetRegisterClass &composeWithSubRegIndex( |
| 45 | const TargetRegisterClass &RC, unsigned Idx) const override; |
| 46 | |
Benjamin Kramer | d886151 | 2015-07-13 20:38:16 +0000 | [diff] [blame] | 47 | MachineFunction &MF; |
| 48 | MachineFrameInfo &MFI; |
| 49 | const HexagonInstrInfo &TII; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 50 | |
| 51 | private: |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 52 | bool evaluateLoad(const MachineInstr &MI, const CellMapType &Inputs, |
Benjamin Kramer | d886151 | 2015-07-13 20:38:16 +0000 | [diff] [blame] | 53 | CellMapType &Outputs) const; |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 54 | bool evaluateFormalCopy(const MachineInstr &MI, const CellMapType &Inputs, |
Benjamin Kramer | d886151 | 2015-07-13 20:38:16 +0000 | [diff] [blame] | 55 | CellMapType &Outputs) const; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 56 | |
| 57 | unsigned getNextPhysReg(unsigned PReg, unsigned Width) const; |
| 58 | unsigned getVirtRegFor(unsigned PReg) const; |
| 59 | |
| 60 | // Type of formal parameter extension. |
| 61 | struct ExtType { |
| 62 | enum { SExt, ZExt }; |
Eugene Zelenko | b2ca1b3 | 2017-01-04 02:02:05 +0000 | [diff] [blame] | 63 | |
| 64 | ExtType() = default; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 65 | ExtType(char t, uint16_t w) : Type(t), Width(w) {} |
Eugene Zelenko | b2ca1b3 | 2017-01-04 02:02:05 +0000 | [diff] [blame] | 66 | |
| 67 | char Type = 0; |
| 68 | uint16_t Width = 0; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 69 | }; |
| 70 | // Map VR -> extension type. |
Eugene Zelenko | e4fc6ee | 2017-07-26 23:20:35 +0000 | [diff] [blame] | 71 | using RegExtMap = DenseMap<unsigned, ExtType>; |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 72 | RegExtMap VRX; |
| 73 | }; |
| 74 | |
Benjamin Kramer | d886151 | 2015-07-13 20:38:16 +0000 | [diff] [blame] | 75 | } // end namespace llvm |
Krzysztof Parzyszek | e53b31a | 2015-07-07 15:16:42 +0000 | [diff] [blame] | 76 | |
Eugene Zelenko | b2ca1b3 | 2017-01-04 02:02:05 +0000 | [diff] [blame] | 77 | #endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H |