LLVM  3.7.0
MCInstrAnalysis.h
Go to the documentation of this file.
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 #ifndef LLVM_MC_MCINSTRANALYSIS_H
16 #define LLVM_MC_MCINSTRANALYSIS_H
17 
18 #include "llvm/MC/MCInst.h"
19 #include "llvm/MC/MCInstrDesc.h"
20 #include "llvm/MC/MCInstrInfo.h"
21 
22 namespace llvm {
23 
25 protected:
26  friend class Target;
27  const MCInstrInfo *Info;
28 
29 public:
30  MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
31 
32  virtual ~MCInstrAnalysis() {}
33 
34  virtual bool isBranch(const MCInst &Inst) const {
35  return Info->get(Inst.getOpcode()).isBranch();
36  }
37 
38  virtual bool isConditionalBranch(const MCInst &Inst) const {
39  return Info->get(Inst.getOpcode()).isConditionalBranch();
40  }
41 
42  virtual bool isUnconditionalBranch(const MCInst &Inst) const {
43  return Info->get(Inst.getOpcode()).isUnconditionalBranch();
44  }
45 
46  virtual bool isIndirectBranch(const MCInst &Inst) const {
47  return Info->get(Inst.getOpcode()).isIndirectBranch();
48  }
49 
50  virtual bool isCall(const MCInst &Inst) const {
51  return Info->get(Inst.getOpcode()).isCall();
52  }
53 
54  virtual bool isReturn(const MCInst &Inst) const {
55  return Info->get(Inst.getOpcode()).isReturn();
56  }
57 
58  virtual bool isTerminator(const MCInst &Inst) const {
59  return Info->get(Inst.getOpcode()).isTerminator();
60  }
61 
62  /// \brief Given a branch instruction try to get the address the branch
63  /// targets. Return true on success, and the address in Target.
64  virtual bool
65  evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
66  uint64_t &Target) const;
67 };
68 
69 } // End llvm namespace
70 
71 #endif
virtual bool isBranch(const MCInst &Inst) const
virtual bool isReturn(const MCInst &Inst) const
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
virtual bool isIndirectBranch(const MCInst &Inst) const
virtual bool isUnconditionalBranch(const MCInst &Inst) const
const MCInstrInfo * Info
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
virtual bool isCall(const MCInst &Inst) const
virtual bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size, uint64_t &Target) const
Given a branch instruction try to get the address the branch targets.
virtual bool isTerminator(const MCInst &Inst) const
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
Definition: MCInstrInfo.h:45
virtual bool isConditionalBranch(const MCInst &Inst) const
unsigned getOpcode() const
Definition: MCInst.h:159
Target - Wrapper for Target specific information.
MCInstrAnalysis(const MCInstrInfo *Info)