blob: 280b5cf68c98599c5b6d9434c4e0a4469f6ffa9b [file] [log] [blame]
Eugene Zelenkod3a6c892017-02-11 00:27:28 +00001//===- MCInstrAnalysis.cpp - InstrDesc target hooks -----------------------===//
Benjamin Kramerc22d50e2011-08-08 18:56:44 +00002//
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
10#include "llvm/MC/MCInstrAnalysis.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000011#include "llvm/MC/MCInst.h"
Eugene Zelenkod3a6c892017-02-11 00:27:28 +000012#include "llvm/MC/MCInstrDesc.h"
13#include "llvm/MC/MCInstrInfo.h"
14#include <cstdint>
15
Benjamin Kramerc22d50e2011-08-08 18:56:44 +000016using namespace llvm;
17
Ahmed Bougachaaa790682013-05-24 01:07:04 +000018bool MCInstrAnalysis::evaluateBranch(const MCInst &Inst, uint64_t Addr,
19 uint64_t Size, uint64_t &Target) const {
Benjamin Kramer12234162011-09-19 17:56:00 +000020 if (Inst.getNumOperands() == 0 ||
21 Info->get(Inst.getOpcode()).OpInfo[0].OperandType != MCOI::OPERAND_PCREL)
Ahmed Bougachaaa790682013-05-24 01:07:04 +000022 return false;
Benjamin Kramerc22d50e2011-08-08 18:56:44 +000023
24 int64_t Imm = Inst.getOperand(0).getImm();
Ahmed Bougachaaa790682013-05-24 01:07:04 +000025 Target = Addr+Size+Imm;
26 return true;
Benjamin Kramerc22d50e2011-08-08 18:56:44 +000027}