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