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/ADT/Twine.h"
17#include "llvm/MC/MCContext.h"
18#include "llvm/MC/MCInst.h"
19#include "llvm/MC/MCInstrInfo.h"
20
21using namespace llvm;
22
23void MCLFIRewriter::error(const MCInst &Inst, const Twine &Msg) {
24 Ctx.reportError(Inst.getLoc(), Msg);
25}
26
27void MCLFIRewriter::warning(const MCInst &Inst, const Twine &Msg) {
28 Ctx.reportWarning(Inst.getLoc(), Msg);
29}
30
31bool MCLFIRewriter::isCall(const MCInst &Inst) const {
32 return InstInfo->get(Inst.getOpcode()).isCall();
33}
34
35bool MCLFIRewriter::isBranch(const MCInst &Inst) const {
36 return InstInfo->get(Inst.getOpcode()).isBranch();
37}
38
39bool MCLFIRewriter::isIndirectBranch(const MCInst &Inst) const {
40 return InstInfo->get(Inst.getOpcode()).isIndirectBranch();
41}
42
43bool MCLFIRewriter::isReturn(const MCInst &Inst) const {
44 return InstInfo->get(Inst.getOpcode()).isReturn();
45}
46
47bool MCLFIRewriter::mayLoad(const MCInst &Inst) const {
48 return InstInfo->get(Inst.getOpcode()).mayLoad();
49}
50
51bool MCLFIRewriter::mayStore(const MCInst &Inst) const {
52 return InstInfo->get(Inst.getOpcode()).mayStore();
53}
54
56 MCRegister Reg) const {
57 return InstInfo->get(Inst.getOpcode()).hasDefOfPhysReg(Inst, Reg, *RegInfo);
58}
59
61 MCRegister Reg) const {
62 return InstInfo->get(Inst.getOpcode())
63 .hasExplicitDefOfPhysReg(Inst, Reg, *RegInfo);
64}
This file declares the MCLFIRewriter class, an abstract class that encapsulates the rewriting logic f...
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 void error(const MCInst &Inst, const Twine &Msg)
LLVM_ABI bool mayLoad(const MCInst &Inst) const
std::unique_ptr< MCInstrInfo > InstInfo
LLVM_ABI bool isIndirectBranch(const MCInst &Inst) const
LLVM_ABI void warning(const MCInst &Inst, const Twine &Msg)
LLVM_ABI bool isCall(const MCInst &Inst) const
LLVM_ABI bool isReturn(const MCInst &Inst) const
std::unique_ptr< MCRegisterInfo > RegInfo
LLVM_ABI bool mayStore(const MCInst &Inst) const
LLVM_ABI bool explicitlyModifiesRegister(const MCInst &Inst, MCRegister Reg) const
LLVM_ABI bool isBranch(const MCInst &Inst) const
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
This is an optimization pass for GlobalISel generic memory operations.