/3rd_party/llvm/include/llvm/MC/MCInstrInfo.h

https://code.google.com/p/softart/ · C++ Header · 62 lines · 30 code · 10 blank · 22 comment · 2 complexity · 9bd9d1052f8abc66aa37b97fa81ac10f MD5 · raw file

  1. //===-- llvm/MC/MCInstrInfo.h - Target Instruction Info ---------*- 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 describes the target machine instruction set.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCINSTRINFO_H
  14. #define LLVM_MC_MCINSTRINFO_H
  15. #include "llvm/MC/MCInstrDesc.h"
  16. #include <cassert>
  17. namespace llvm {
  18. //---------------------------------------------------------------------------
  19. ///
  20. /// MCInstrInfo - Interface to description of machine instruction set
  21. ///
  22. class MCInstrInfo {
  23. const MCInstrDesc *Desc; // Raw array to allow static init'n
  24. const unsigned *InstrNameIndices; // Array for name indices in InstrNameData
  25. const char *InstrNameData; // Instruction name string pool
  26. unsigned NumOpcodes; // Number of entries in the desc array
  27. public:
  28. /// InitMCInstrInfo - Initialize MCInstrInfo, called by TableGen
  29. /// auto-generated routines. *DO NOT USE*.
  30. void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND,
  31. unsigned NO) {
  32. Desc = D;
  33. InstrNameIndices = NI;
  34. InstrNameData = ND;
  35. NumOpcodes = NO;
  36. }
  37. unsigned getNumOpcodes() const { return NumOpcodes; }
  38. /// get - Return the machine instruction descriptor that corresponds to the
  39. /// specified instruction opcode.
  40. ///
  41. const MCInstrDesc &get(unsigned Opcode) const {
  42. assert(Opcode < NumOpcodes && "Invalid opcode!");
  43. return Desc[Opcode];
  44. }
  45. /// getName - Returns the name for the instructions with the given opcode.
  46. const char *getName(unsigned Opcode) const {
  47. assert(Opcode < NumOpcodes && "Invalid opcode!");
  48. return &InstrNameData[InstrNameIndices[Opcode]];
  49. }
  50. };
  51. } // End llvm namespace
  52. #endif