LLVM API Documentation
00001 //===-- llvm/MC/MCInstrAnalysis.h - InstrDesc target hooks ------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the MCInstrAnalysis class which the MCTargetDescs can 00011 // derive from to give additional information to MC. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #include "llvm/MC/MCInst.h" 00016 #include "llvm/MC/MCInstrDesc.h" 00017 #include "llvm/MC/MCInstrInfo.h" 00018 00019 namespace llvm { 00020 00021 class MCInstrAnalysis { 00022 protected: 00023 friend class Target; 00024 const MCInstrInfo *Info; 00025 00026 public: 00027 MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {} 00028 00029 virtual ~MCInstrAnalysis() {} 00030 00031 virtual bool isBranch(const MCInst &Inst) const { 00032 return Info->get(Inst.getOpcode()).isBranch(); 00033 } 00034 00035 virtual bool isConditionalBranch(const MCInst &Inst) const { 00036 return Info->get(Inst.getOpcode()).isConditionalBranch(); 00037 } 00038 00039 virtual bool isUnconditionalBranch(const MCInst &Inst) const { 00040 return Info->get(Inst.getOpcode()).isUnconditionalBranch(); 00041 } 00042 00043 virtual bool isIndirectBranch(const MCInst &Inst) const { 00044 return Info->get(Inst.getOpcode()).isIndirectBranch(); 00045 } 00046 00047 virtual bool isCall(const MCInst &Inst) const { 00048 return Info->get(Inst.getOpcode()).isCall(); 00049 } 00050 00051 virtual bool isReturn(const MCInst &Inst) const { 00052 return Info->get(Inst.getOpcode()).isReturn(); 00053 } 00054 00055 /// evaluateBranch - Given a branch instruction try to get the address the 00056 /// branch targets. Otherwise return -1. 00057 virtual uint64_t 00058 evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size) const; 00059 }; 00060 00061 }