LLVM API Documentation
00001 //===-- llvm/MC/MCInstrInfo.h - Target Instruction Info ---------*- 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 describes the target machine instruction set. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_MC_MCINSTRINFO_H 00015 #define LLVM_MC_MCINSTRINFO_H 00016 00017 #include "llvm/MC/MCInstrDesc.h" 00018 #include <cassert> 00019 00020 namespace llvm { 00021 00022 //--------------------------------------------------------------------------- 00023 /// 00024 /// MCInstrInfo - Interface to description of machine instruction set 00025 /// 00026 class MCInstrInfo { 00027 const MCInstrDesc *Desc; // Raw array to allow static init'n 00028 const unsigned *InstrNameIndices; // Array for name indices in InstrNameData 00029 const char *InstrNameData; // Instruction name string pool 00030 unsigned NumOpcodes; // Number of entries in the desc array 00031 00032 public: 00033 /// InitMCInstrInfo - Initialize MCInstrInfo, called by TableGen 00034 /// auto-generated routines. *DO NOT USE*. 00035 void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND, 00036 unsigned NO) { 00037 Desc = D; 00038 InstrNameIndices = NI; 00039 InstrNameData = ND; 00040 NumOpcodes = NO; 00041 } 00042 00043 unsigned getNumOpcodes() const { return NumOpcodes; } 00044 00045 /// get - Return the machine instruction descriptor that corresponds to the 00046 /// specified instruction opcode. 00047 /// 00048 const MCInstrDesc &get(unsigned Opcode) const { 00049 assert(Opcode < NumOpcodes && "Invalid opcode!"); 00050 return Desc[Opcode]; 00051 } 00052 00053 /// getName - Returns the name for the instructions with the given opcode. 00054 const char *getName(unsigned Opcode) const { 00055 assert(Opcode < NumOpcodes && "Invalid opcode!"); 00056 return &InstrNameData[InstrNameIndices[Opcode]]; 00057 } 00058 }; 00059 00060 } // End llvm namespace 00061 00062 #endif