blob: d9dd04e1b0882fd695c9ff79437dda7f8b3967f4 [file] [log] [blame]
Eugene Zelenkoe4fc6ee2017-07-26 23:20:35 +00001//===- HexagonBitTracker.h --------------------------------------*- C++ -*-===//
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +00002//
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 Zelenkob2ca1b32017-01-04 02:02:05 +000010#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H
11#define LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000012
13#include "BitTracker.h"
14#include "llvm/ADT/DenseMap.h"
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +000015#include <cstdint>
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000016
17namespace llvm {
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +000018
19class HexagonInstrInfo;
20class HexagonRegisterInfo;
Eugene Zelenkoe4fc6ee2017-07-26 23:20:35 +000021class MachineFrameInfo;
22class MachineFunction;
23class MachineInstr;
24class MachineRegisterInfo;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000025
26struct HexagonEvaluator : public BitTracker::MachineEvaluator {
Eugene Zelenkoe4fc6ee2017-07-26 23:20:35 +000027 using CellMapType = BitTracker::CellMapType;
28 using RegisterRef = BitTracker::RegisterRef;
29 using RegisterCell = BitTracker::RegisterCell;
30 using BranchTargetList = BitTracker::BranchTargetList;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000031
Benjamin Kramerd8861512015-07-13 20:38:16 +000032 HexagonEvaluator(const HexagonRegisterInfo &tri, MachineRegisterInfo &mri,
33 const HexagonInstrInfo &tii, MachineFunction &mf);
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000034
Duncan P. N. Exon Smith98226e32016-07-12 01:55:32 +000035 bool evaluate(const MachineInstr &MI, const CellMapType &Inputs,
Benjamin Kramerd8861512015-07-13 20:38:16 +000036 CellMapType &Outputs) const override;
Duncan P. N. Exon Smith98226e32016-07-12 01:55:32 +000037 bool evaluate(const MachineInstr &BI, const CellMapType &Inputs,
Benjamin Kramerd8861512015-07-13 20:38:16 +000038 BranchTargetList &Targets, bool &FallsThru) const override;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000039
Benjamin Kramerd8861512015-07-13 20:38:16 +000040 BitTracker::BitMask mask(unsigned Reg, unsigned Sub) const override;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000041
Krzysztof Parzyszek7e604de2017-09-25 19:12:55 +000042 uint16_t getPhysRegBitWidth(unsigned Reg) const override;
43
44 const TargetRegisterClass &composeWithSubRegIndex(
45 const TargetRegisterClass &RC, unsigned Idx) const override;
46
Benjamin Kramerd8861512015-07-13 20:38:16 +000047 MachineFunction &MF;
48 MachineFrameInfo &MFI;
49 const HexagonInstrInfo &TII;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000050
51private:
Duncan P. N. Exon Smith98226e32016-07-12 01:55:32 +000052 bool evaluateLoad(const MachineInstr &MI, const CellMapType &Inputs,
Benjamin Kramerd8861512015-07-13 20:38:16 +000053 CellMapType &Outputs) const;
Duncan P. N. Exon Smith98226e32016-07-12 01:55:32 +000054 bool evaluateFormalCopy(const MachineInstr &MI, const CellMapType &Inputs,
Benjamin Kramerd8861512015-07-13 20:38:16 +000055 CellMapType &Outputs) const;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000056
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 Zelenkob2ca1b32017-01-04 02:02:05 +000063
64 ExtType() = default;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000065 ExtType(char t, uint16_t w) : Type(t), Width(w) {}
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +000066
67 char Type = 0;
68 uint16_t Width = 0;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000069 };
70 // Map VR -> extension type.
Eugene Zelenkoe4fc6ee2017-07-26 23:20:35 +000071 using RegExtMap = DenseMap<unsigned, ExtType>;
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000072 RegExtMap VRX;
73};
74
Benjamin Kramerd8861512015-07-13 20:38:16 +000075} // end namespace llvm
Krzysztof Parzyszeke53b31a2015-07-07 15:16:42 +000076
Eugene Zelenkob2ca1b32017-01-04 02:02:05 +000077#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H