LLVM  3.7.0
MCInstrAnalysis.cpp
Go to the documentation of this file.
1 //===-- MCInstrAnalysis.cpp - InstrDesc target hooks ------------*- 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 
11 using namespace llvm;
12 
13 bool MCInstrAnalysis::evaluateBranch(const MCInst &Inst, uint64_t Addr,
14  uint64_t Size, uint64_t &Target) const {
15  if (Inst.getNumOperands() == 0 ||
16  Info->get(Inst.getOpcode()).OpInfo[0].OperandType != MCOI::OPERAND_PCREL)
17  return false;
18 
19  int64_t Imm = Inst.getOperand(0).getImm();
20  Target = Addr+Size+Imm;
21  return true;
22 }
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
const MCInstrInfo * Info
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.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
Definition: MCInstrInfo.h:45
unsigned getOpcode() const
Definition: MCInst.h:159
Target - Wrapper for Target specific information.
int64_t getImm() const
Definition: MCInst.h:74
OperandType
Types of operands to CF instructions.
unsigned getNumOperands() const
Definition: MCInst.h:166
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:164