LLVM  10.0.0svn
MCInstrAnalysis.cpp
Go to the documentation of this file.
1 //===- MCInstrAnalysis.cpp - InstrDesc target hooks -----------------------===//
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 
10 
11 #include "llvm/ADT/APInt.h"
12 #include "llvm/MC/MCInst.h"
13 #include "llvm/MC/MCInstrDesc.h"
14 #include "llvm/MC/MCInstrInfo.h"
15 #include <cstdint>
16 
17 using namespace llvm;
18 
20  const MCInst &Inst,
21  APInt &Writes) const {
22  Writes.clearAllBits();
23  return false;
24 }
25 
26 bool MCInstrAnalysis::evaluateBranch(const MCInst &Inst, uint64_t Addr,
27  uint64_t Size, uint64_t &Target) const {
28  if (Inst.getNumOperands() == 0 ||
29  Info->get(Inst.getOpcode()).OpInfo[0].OperandType != MCOI::OPERAND_PCREL)
30  return false;
31 
32  int64_t Imm = Inst.getOperand(0).getImm();
33  Target = Addr+Size+Imm;
34  return true;
35 }
36 
39  uint64_t Size) const {
40  return None;
41 }
void clearAllBits()
Set every bit to 0.
Definition: APInt.h:1451
virtual Optional< uint64_t > evaluateMemoryOperandAddress(const MCInst &Inst, uint64_t Addr, uint64_t Size) const
Given an instruction tries to get the address of a memory operand.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
virtual bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size, uint64_t &Target) const
Given a branch instruction try to get the address the branch targets.
This file implements a class to represent arbitrary precision integral constant values and operations...
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:158
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
int64_t getImm() const
Definition: MCInst.h:75
virtual bool clearsSuperRegisters(const MCRegisterInfo &MRI, const MCInst &Inst, APInt &Writes) const
Returns true if at least one of the register writes performed by.
unsigned const MachineRegisterInfo * MRI
const MCInstrInfo * Info
unsigned getNumOperands() const
Definition: MCInst.h:181
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:179
Target - Wrapper for Target specific information.
Class for arbitrary precision integers.
Definition: APInt.h:69
OperandType
Operands are tagged with one of the values of this enum.
Definition: MCInstrDesc.h:43
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
Definition: MCInstrInfo.h:44
uint32_t Size
Definition: Profile.cpp:46
unsigned getOpcode() const
Definition: MCInst.h:171