LLVM API Documentation

MCInstrAnalysis.h
Go to the documentation of this file.
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 #ifndef LLVM_MC_MCINSTRANALYSIS_H
00016 #define LLVM_MC_MCINSTRANALYSIS_H
00017 
00018 #include "llvm/MC/MCInst.h"
00019 #include "llvm/MC/MCInstrDesc.h"
00020 #include "llvm/MC/MCInstrInfo.h"
00021 
00022 namespace llvm {
00023 
00024 class MCInstrAnalysis {
00025 protected:
00026   friend class Target;
00027   const MCInstrInfo *Info;
00028 
00029 public:
00030   MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
00031 
00032   virtual ~MCInstrAnalysis() {}
00033 
00034   virtual bool isBranch(const MCInst &Inst) const {
00035     return Info->get(Inst.getOpcode()).isBranch();
00036   }
00037 
00038   virtual bool isConditionalBranch(const MCInst &Inst) const {
00039     return Info->get(Inst.getOpcode()).isConditionalBranch();
00040   }
00041 
00042   virtual bool isUnconditionalBranch(const MCInst &Inst) const {
00043     return Info->get(Inst.getOpcode()).isUnconditionalBranch();
00044   }
00045 
00046   virtual bool isIndirectBranch(const MCInst &Inst) const {
00047     return Info->get(Inst.getOpcode()).isIndirectBranch();
00048   }
00049 
00050   virtual bool isCall(const MCInst &Inst) const {
00051     return Info->get(Inst.getOpcode()).isCall();
00052   }
00053 
00054   virtual bool isReturn(const MCInst &Inst) const {
00055     return Info->get(Inst.getOpcode()).isReturn();
00056   }
00057 
00058   virtual bool isTerminator(const MCInst &Inst) const {
00059     return Info->get(Inst.getOpcode()).isTerminator();
00060   }
00061 
00062   /// evaluateBranch - Given a branch instruction try to get the address the
00063   /// branch targets. Return true on success, and the address in Target.
00064   virtual bool
00065   evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
00066                  uint64_t &Target) const;
00067 };
00068 
00069 } // End llvm namespace
00070 
00071 #endif