1 //==-- llvm/CodeGen/GlobalISel/Utils.h ---------------------------*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// \file This file declares the API of helper functions used throughout the
11 /// GlobalISel pipeline.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_GLOBALISEL_UTILS_H
16 #define LLVM_CODEGEN_GLOBALISEL_UTILS_H
18 #include "llvm/ADT/StringRef.h"
22 class MachineFunction;
24 class MachineOptimizationRemarkEmitter;
25 class MachineOptimizationRemarkMissed;
26 class MachineRegisterInfo;
28 class RegisterBankInfo;
29 class TargetInstrInfo;
30 class TargetPassConfig;
31 class TargetRegisterInfo;
34 /// Try to constrain Reg so that it is usable by argument OpIdx of the
35 /// provided MCInstrDesc \p II. If this fails, create a new virtual
36 /// register in the correct class and insert a COPY before \p InsertPt.
37 /// The debug location of \p InsertPt is used for the new copy.
39 /// \return The virtual register constrained to the right register class.
40 unsigned constrainOperandRegClass(const MachineFunction &MF,
41 const TargetRegisterInfo &TRI,
42 MachineRegisterInfo &MRI,
43 const TargetInstrInfo &TII,
44 const RegisterBankInfo &RBI,
45 MachineInstr &InsertPt, const MCInstrDesc &II,
46 unsigned Reg, unsigned OpIdx);
48 /// Check whether an instruction \p MI is dead: it only defines dead virtual
49 /// registers, and doesn't have other side effects.
50 bool isTriviallyDead(const MachineInstr &MI, const MachineRegisterInfo &MRI);
52 /// Report an ISel error as a missed optimization remark to the LLVMContext's
53 /// diagnostic stream. Set the FailedISel MachineFunction property.
54 void reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
55 MachineOptimizationRemarkEmitter &MORE,
56 MachineOptimizationRemarkMissed &R);
58 void reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
59 MachineOptimizationRemarkEmitter &MORE,
60 const char *PassName, StringRef Msg,
61 const MachineInstr &MI);
63 } // End namespace llvm.