Home | History | Annotate | Download | only in GlobalISel
      1 //==-- llvm/CodeGen/GlobalISel/Utils.h ---------------------------*- C++ -*-==//
      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 //
     10 /// \file This file declares the API of helper functions used throughout the
     11 /// GlobalISel pipeline.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_CODEGEN_GLOBALISEL_UTILS_H
     16 #define LLVM_CODEGEN_GLOBALISEL_UTILS_H
     17 
     18 #include "llvm/ADT/StringRef.h"
     19 
     20 namespace llvm {
     21 
     22 class MachineFunction;
     23 class MachineInstr;
     24 class MachineOptimizationRemarkEmitter;
     25 class MachineOptimizationRemarkMissed;
     26 class MachineRegisterInfo;
     27 class MCInstrDesc;
     28 class RegisterBankInfo;
     29 class TargetInstrInfo;
     30 class TargetPassConfig;
     31 class TargetRegisterInfo;
     32 class Twine;
     33 class ConstantFP;
     34 
     35 /// Try to constrain Reg so that it is usable by argument OpIdx of the
     36 /// provided MCInstrDesc \p II. If this fails, create a new virtual
     37 /// register in the correct class and insert a COPY before \p InsertPt.
     38 /// The debug location of \p InsertPt is used for the new copy.
     39 ///
     40 /// \return The virtual register constrained to the right register class.
     41 unsigned constrainOperandRegClass(const MachineFunction &MF,
     42                                   const TargetRegisterInfo &TRI,
     43                                   MachineRegisterInfo &MRI,
     44                                   const TargetInstrInfo &TII,
     45                                   const RegisterBankInfo &RBI,
     46                                   MachineInstr &InsertPt, const MCInstrDesc &II,
     47                                   unsigned Reg, unsigned OpIdx);
     48 
     49 /// Check whether an instruction \p MI is dead: it only defines dead virtual
     50 /// registers, and doesn't have other side effects.
     51 bool isTriviallyDead(const MachineInstr &MI, const MachineRegisterInfo &MRI);
     52 
     53 /// Report an ISel error as a missed optimization remark to the LLVMContext's
     54 /// diagnostic stream.  Set the FailedISel MachineFunction property.
     55 void reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
     56                         MachineOptimizationRemarkEmitter &MORE,
     57                         MachineOptimizationRemarkMissed &R);
     58 
     59 void reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
     60                         MachineOptimizationRemarkEmitter &MORE,
     61                         const char *PassName, StringRef Msg,
     62                         const MachineInstr &MI);
     63 
     64 Optional<int64_t> getConstantVRegVal(unsigned VReg,
     65                                      const MachineRegisterInfo &MRI);
     66 const ConstantFP* getConstantFPVRegVal(unsigned VReg,
     67                                        const MachineRegisterInfo &MRI);
     68 
     69 } // End namespace llvm.
     70 #endif
     71