Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.7 KiB

  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. #include "llvm/MC/MCInst.h"
  15. #include "llvm/MC/MCInstrDesc.h"
  16. #include "llvm/MC/MCInstrInfo.h"
  17. namespace llvm {
  18. class MCInstrAnalysis {
  19. protected:
  20. friend class Target;
  21. const MCInstrInfo *Info;
  22. public:
  23. MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
  24. virtual ~MCInstrAnalysis() {}
  25. virtual bool isBranch(const MCInst &Inst) const {
  26. return Info->get(Inst.getOpcode()).isBranch();
  27. }
  28. virtual bool isConditionalBranch(const MCInst &Inst) const {
  29. return Info->get(Inst.getOpcode()).isConditionalBranch();
  30. }
  31. virtual bool isUnconditionalBranch(const MCInst &Inst) const {
  32. return Info->get(Inst.getOpcode()).isUnconditionalBranch();
  33. }
  34. virtual bool isIndirectBranch(const MCInst &Inst) const {
  35. return Info->get(Inst.getOpcode()).isIndirectBranch();
  36. }
  37. virtual bool isCall(const MCInst &Inst) const {
  38. return Info->get(Inst.getOpcode()).isCall();
  39. }
  40. virtual bool isReturn(const MCInst &Inst) const {
  41. return Info->get(Inst.getOpcode()).isReturn();
  42. }
  43. /// evaluateBranch - Given a branch instruction try to get the address the
  44. /// branch targets. Otherwise return -1.
  45. virtual uint64_t
  46. evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size) const;
  47. };
  48. }