//===- HexagonMCChecker.h - Instruction bundle checking ---------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This implements the checking of insns inside a bundle according to the // packet constraint rules of the Hexagon ISA. // //===----------------------------------------------------------------------===// #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCCHECKER_H #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCCHECKER_H #include "MCTargetDesc/HexagonMCInstrInfo.h" #include "MCTargetDesc/HexagonMCTargetDesc.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/SMLoc.h" #include #include namespace llvm { class MCContext; class MCInst; class MCInstrInfo; class MCRegisterInfo; class MCSubtargetInfo; /// Check for a valid bundle. class HexagonMCChecker { MCContext &Context; MCInst &MCB; const MCRegisterInfo &RI; MCInstrInfo const &MCII; MCSubtargetInfo const &STI; bool ReportErrors; /// Set of definitions: register #, if predicated, if predicated true. using PredSense = std::pair; static const PredSense Unconditional; using PredSet = std::multiset; using PredSetIterator = std::multiset::iterator; using DefsIterator = DenseMap::iterator; DenseMap Defs; /// Set of weak definitions whose clashes should be enforced selectively. using SoftDefsIterator = std::set::iterator; std::set SoftDefs; /// Set of temporary definitions not committed to the register file. using TmpDefsIterator = std::set::iterator; std::set TmpDefs; /// Set of new predicates used. using NewPredsIterator = std::set::iterator; std::set NewPreds; /// Set of predicates defined late. using LatePredsIterator = std::multiset::iterator; std::multiset LatePreds; /// Set of uses. using UsesIterator = std::set::iterator; std::set Uses; /// Pre-defined set of read-only registers. using ReadOnlyIterator = std::set::iterator; std::set ReadOnly; // Contains the vector-pair-registers with the even number // first ("v0:1", e.g.) used/def'd in this packet. std::set ReversePairs; void init(); void init(MCInst const &); void initReg(MCInst const &, unsigned, unsigned &PredReg, bool &isTrue); bool registerUsed(unsigned Register); std::tuple registerProducer(unsigned Register, HexagonMCInstrInfo::PredicateInfo Predicated); // Checks performed. bool checkBranches(); bool checkPredicates(); bool checkNewValues(); bool checkRegisters(); bool checkRegistersReadOnly(); void checkRegisterCurDefs(); bool checkSolo(); bool checkShuffle(); bool checkSlots(); bool checkAXOK(); bool checkHWLoop(); bool checkCOFMax1(); bool checkLegalVecRegPair(); static void compoundRegisterMap(unsigned &); bool isPredicateRegister(unsigned R) const { return (Hexagon::P0 == R || Hexagon::P1 == R || Hexagon::P2 == R || Hexagon::P3 == R); } bool isLoopRegister(unsigned R) const { return (Hexagon::SA0 == R || Hexagon::LC0 == R || Hexagon::SA1 == R || Hexagon::LC1 == R); } public: explicit HexagonMCChecker(MCContext &Context, MCInstrInfo const &MCII, MCSubtargetInfo const &STI, MCInst &mcb, const MCRegisterInfo &ri, bool ReportErrors = true); explicit HexagonMCChecker(HexagonMCChecker const &Check, MCSubtargetInfo const &STI, bool CopyReportErrors); bool check(bool FullCheck = true); void reportErrorRegisters(unsigned Register); void reportErrorNewValue(unsigned Register); void reportError(SMLoc Loc, Twine const &Msg); void reportNote(SMLoc Loc, Twine const &Msg); void reportError(Twine const &Msg); void reportWarning(Twine const &Msg); void reportBranchErrors(); }; } // end namespace llvm #endif // LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCCHECKER_H