MCInstrAnalysis.h revision 41ab14b725c8f2bb3e54553d0d7d96ff184786b1
1//===-- llvm/MC/MCInstrAnalysis.h - 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// 10// This file defines the MCInstrAnalysis class which the MCTargetDescs can 11// derive from to give additional information to MC. 12// 13//===----------------------------------------------------------------------===// 14 15#include "llvm/MC/MCInst.h" 16#include "llvm/MC/MCInstrDesc.h" 17#include "llvm/MC/MCInstrInfo.h" 18 19namespace llvm { 20 21class MCInstrAnalysis { 22protected: 23 friend class Target; 24 const MCInstrInfo *Info; 25 26 MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {} 27public: 28 virtual bool isBranch(const MCInst &Inst) const { 29 return Info->get(Inst.getOpcode()).isBranch(); 30 } 31 32 virtual bool isConditionalBranch(const MCInst &Inst) const { 33 return Info->get(Inst.getOpcode()).isBranch(); 34 } 35 36 virtual bool isUnconditionalBranch(const MCInst &Inst) const { 37 return Info->get(Inst.getOpcode()).isUnconditionalBranch(); 38 } 39 40 virtual bool isIndirectBranch(const MCInst &Inst) const { 41 return Info->get(Inst.getOpcode()).isIndirectBranch(); 42 } 43 44 virtual bool isReturn(const MCInst &Inst) const { 45 return Info->get(Inst.getOpcode()).isReturn(); 46 } 47 48 /// evaluateBranch - Given a branch instruction try to get the address the 49 /// branch targets. Otherwise return -1. 50 virtual uint64_t 51 evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size) const; 52}; 53 54} 55