blob: 54741fdd686ddeed9de2a91e7754f39d7c92251f [file] [log] [blame]
Eugene Zelenkod3a6c892017-02-11 00:27:28 +00001//===- MCInstrAnalysis.cpp - InstrDesc target hooks -----------------------===//
Benjamin Kramerc22d50e2011-08-08 18:56:44 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Benjamin Kramerc22d50e2011-08-08 18:56:44 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/MC/MCInstrAnalysis.h"
Reid Kleckner5565d362019-11-13 16:36:21 -080010
Andrea Di Biagio2145b132018-06-20 10:08:11 +000011#include "llvm/ADT/APInt.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000012#include "llvm/MC/MCInst.h"
Eugene Zelenkod3a6c892017-02-11 00:27:28 +000013#include "llvm/MC/MCInstrDesc.h"
14#include "llvm/MC/MCInstrInfo.h"
15#include <cstdint>
16
Benjamin Kramerc22d50e2011-08-08 18:56:44 +000017using namespace llvm;
18
Andrea Di Biagio2145b132018-06-20 10:08:11 +000019bool MCInstrAnalysis::clearsSuperRegisters(const MCRegisterInfo &MRI,
20 const MCInst &Inst,
21 APInt &Writes) const {
22 Writes.clearAllBits();
23 return false;
24}
25
Ahmed Bougachaaa790682013-05-24 01:07:04 +000026bool MCInstrAnalysis::evaluateBranch(const MCInst &Inst, uint64_t Addr,
27 uint64_t Size, uint64_t &Target) const {
Benjamin Kramer12234162011-09-19 17:56:00 +000028 if (Inst.getNumOperands() == 0 ||
29 Info->get(Inst.getOpcode()).OpInfo[0].OperandType != MCOI::OPERAND_PCREL)
Ahmed Bougachaaa790682013-05-24 01:07:04 +000030 return false;
Benjamin Kramerc22d50e2011-08-08 18:56:44 +000031
32 int64_t Imm = Inst.getOperand(0).getImm();
Ahmed Bougachaaa790682013-05-24 01:07:04 +000033 Target = Addr+Size+Imm;
34 return true;
Benjamin Kramerc22d50e2011-08-08 18:56:44 +000035}
Seiya Nuta21277e32019-07-25 06:57:09 +000036
37Optional<uint64_t>
38MCInstrAnalysis::evaluateMemoryOperandAddress(const MCInst &Inst, uint64_t Addr,
39 uint64_t Size) const {
40 return None;
41}