LLVM  6.0.0svn
MCInstrAnalysis.cpp
Go to the documentation of this file.
1 //===- MCInstrAnalysis.cpp - InstrDesc target hooks -----------------------===//
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 #include "llvm/MC/MCInst.h"
12 #include "llvm/MC/MCInstrDesc.h"
13 #include "llvm/MC/MCInstrInfo.h"
14 #include <cstdint>
15 
16 using namespace llvm;
17 
18 bool MCInstrAnalysis::evaluateBranch(const MCInst &Inst, uint64_t Addr,
19  uint64_t Size, uint64_t &Target) const {
20  if (Inst.getNumOperands() == 0 ||
21  Info->get(Inst.getOpcode()).OpInfo[0].OperandType != MCOI::OPERAND_PCREL)
22  return false;
23 
24  int64_t Imm = Inst.getOperand(0).getImm();
25  Target = Addr+Size+Imm;
26  return true;
27 }
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
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.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:159
int64_t getImm() const
Definition: MCInst.h:76
const MCInstrInfo * Info
unsigned getNumOperands() const
Definition: MCInst.h:182
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:180
Target - Wrapper for Target specific information.
OperandType
Types of operands to CF instructions.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
Definition: MCInstrInfo.h:45
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
unsigned getOpcode() const
Definition: MCInst.h:172