10b57cec5SDimitry Andric //===- HexagonBitTracker.h --------------------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H 100b57cec5SDimitry Andric #define LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include "BitTracker.h" 130b57cec5SDimitry Andric #include "llvm/ADT/DenseMap.h" 140b57cec5SDimitry Andric #include <cstdint> 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric namespace llvm { 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric class HexagonInstrInfo; 190b57cec5SDimitry Andric class HexagonRegisterInfo; 200b57cec5SDimitry Andric class MachineFrameInfo; 210b57cec5SDimitry Andric class MachineFunction; 220b57cec5SDimitry Andric class MachineInstr; 230b57cec5SDimitry Andric class MachineRegisterInfo; 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric struct HexagonEvaluator : public BitTracker::MachineEvaluator { 260b57cec5SDimitry Andric using CellMapType = BitTracker::CellMapType; 270b57cec5SDimitry Andric using RegisterRef = BitTracker::RegisterRef; 280b57cec5SDimitry Andric using RegisterCell = BitTracker::RegisterCell; 290b57cec5SDimitry Andric using BranchTargetList = BitTracker::BranchTargetList; 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric HexagonEvaluator(const HexagonRegisterInfo &tri, MachineRegisterInfo &mri, 320b57cec5SDimitry Andric const HexagonInstrInfo &tii, MachineFunction &mf); 330b57cec5SDimitry Andric 340b57cec5SDimitry Andric bool evaluate(const MachineInstr &MI, const CellMapType &Inputs, 350b57cec5SDimitry Andric CellMapType &Outputs) const override; 360b57cec5SDimitry Andric bool evaluate(const MachineInstr &BI, const CellMapType &Inputs, 370b57cec5SDimitry Andric BranchTargetList &Targets, bool &FallsThru) const override; 380b57cec5SDimitry Andric 39*e8d8bef9SDimitry Andric BitTracker::BitMask mask(Register Reg, unsigned Sub) const override; 400b57cec5SDimitry Andric 41*e8d8bef9SDimitry Andric uint16_t getPhysRegBitWidth(MCRegister Reg) const override; 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric const TargetRegisterClass &composeWithSubRegIndex( 440b57cec5SDimitry Andric const TargetRegisterClass &RC, unsigned Idx) const override; 450b57cec5SDimitry Andric 460b57cec5SDimitry Andric MachineFunction &MF; 470b57cec5SDimitry Andric MachineFrameInfo &MFI; 480b57cec5SDimitry Andric const HexagonInstrInfo &TII; 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric private: 510b57cec5SDimitry Andric unsigned getUniqueDefVReg(const MachineInstr &MI) const; 520b57cec5SDimitry Andric bool evaluateLoad(const MachineInstr &MI, const CellMapType &Inputs, 530b57cec5SDimitry Andric CellMapType &Outputs) const; 540b57cec5SDimitry Andric bool evaluateFormalCopy(const MachineInstr &MI, const CellMapType &Inputs, 550b57cec5SDimitry Andric CellMapType &Outputs) const; 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric unsigned getNextPhysReg(unsigned PReg, unsigned Width) const; 580b57cec5SDimitry Andric unsigned getVirtRegFor(unsigned PReg) const; 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric // Type of formal parameter extension. 610b57cec5SDimitry Andric struct ExtType { 620b57cec5SDimitry Andric enum { SExt, ZExt }; 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric ExtType() = default; ExtTypeHexagonEvaluator::ExtType650b57cec5SDimitry Andric ExtType(char t, uint16_t w) : Type(t), Width(w) {} 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric char Type = 0; 680b57cec5SDimitry Andric uint16_t Width = 0; 690b57cec5SDimitry Andric }; 700b57cec5SDimitry Andric // Map VR -> extension type. 710b57cec5SDimitry Andric using RegExtMap = DenseMap<unsigned, ExtType>; 720b57cec5SDimitry Andric RegExtMap VRX; 730b57cec5SDimitry Andric }; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric } // end namespace llvm 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONBITTRACKER_H 78