LLVM 23.0.0git
MCLFIRewriter.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file implements the MCLFIRewriter class, a base class that
11/// encapsulates the rewriting logic for MCInsts.
12///
13//===----------------------------------------------------------------------===//
14
16#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCInst.h"
18#include "llvm/MC/MCInstrInfo.h"
19
20namespace llvm {
21
22void MCLFIRewriter::error(const MCInst &Inst, const char Msg[]) {
23 Ctx.reportError(Inst.getLoc(), Msg);
24}
25
26bool MCLFIRewriter::isCall(const MCInst &Inst) const {
27 return InstInfo->get(Inst.getOpcode()).isCall();
28}
29
30bool MCLFIRewriter::isBranch(const MCInst &Inst) const {
31 return InstInfo->get(Inst.getOpcode()).isBranch();
32}
33
34bool MCLFIRewriter::isIndirectBranch(const MCInst &Inst) const {
35 return InstInfo->get(Inst.getOpcode()).isIndirectBranch();
36}
37
38bool MCLFIRewriter::isReturn(const MCInst &Inst) const {
39 return InstInfo->get(Inst.getOpcode()).isReturn();
40}
41
42bool MCLFIRewriter::mayLoad(const MCInst &Inst) const {
43 return InstInfo->get(Inst.getOpcode()).mayLoad();
44}
45
46bool MCLFIRewriter::mayStore(const MCInst &Inst) const {
47 return InstInfo->get(Inst.getOpcode()).mayStore();
48}
49
51 MCRegister Reg) const {
52 return InstInfo->get(Inst.getOpcode()).hasDefOfPhysReg(Inst, Reg, *RegInfo);
53}
54} // namespace llvm
This file declares the MCLFIRewriter class, an abstract class that encapsulates the rewriting logic f...
Register Reg
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
SMLoc getLoc() const
Definition MCInst.h:208
unsigned getOpcode() const
Definition MCInst.h:202
LLVM_ABI bool mayModifyRegister(const MCInst &Inst, MCRegister Reg) const
LLVM_ABI bool mayLoad(const MCInst &Inst) const
LLVM_ABI bool isCall(const MCInst &Inst) const
std::unique_ptr< MCInstrInfo > InstInfo
LLVM_ABI bool mayStore(const MCInst &Inst) const
LLVM_ABI bool isReturn(const MCInst &Inst) const
std::unique_ptr< MCRegisterInfo > RegInfo
LLVM_ABI void error(const MCInst &Inst, const char Msg[])
LLVM_ABI bool isIndirectBranch(const MCInst &Inst) const
LLVM_ABI bool isBranch(const MCInst &Inst) const
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26