1169689Skan//===-- llvm/MC/MCInstrInfo.h - Target Instruction Info ---------*- C++ -*-===//
2169689Skan//
3169689Skan//                     The LLVM Compiler Infrastructure
4169689Skan//
5169689Skan// This file is distributed under the University of Illinois Open Source
6169689Skan// License. See LICENSE.TXT for details.
7169689Skan//
8169689Skan//===----------------------------------------------------------------------===//
9169689Skan//
10169689Skan// This file describes the target machine instruction set.
11169689Skan//
12169689Skan//===----------------------------------------------------------------------===//
13169689Skan
14169689Skan#ifndef LLVM_MC_MCINSTRINFO_H
15169689Skan#define LLVM_MC_MCINSTRINFO_H
16169689Skan
17169689Skan#include "llvm/MC/MCInstrDesc.h"
18169689Skan#include <cassert>
19169689Skan
20169689Skannamespace llvm {
21169689Skan
22169689Skan//---------------------------------------------------------------------------
23169689Skan///
24169689Skan/// MCInstrInfo - Interface to description of machine instruction set
25169689Skan///
26169689Skanclass MCInstrInfo {
27169689Skan  const MCInstrDesc *Desc;          // Raw array to allow static init'n
28169689Skan  const unsigned *InstrNameIndices; // Array for name indices in InstrNameData
29169689Skan  const char *InstrNameData;        // Instruction name string pool
30169689Skan  unsigned NumOpcodes;              // Number of entries in the desc array
31169689Skan
32169689Skanpublic:
33169689Skan  /// InitMCInstrInfo - Initialize MCInstrInfo, called by TableGen
34169689Skan  /// auto-generated routines. *DO NOT USE*.
35169689Skan  void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND,
36169689Skan                       unsigned NO) {
37169689Skan    Desc = D;
38169689Skan    InstrNameIndices = NI;
39169689Skan    InstrNameData = ND;
40169689Skan    NumOpcodes = NO;
41169689Skan  }
42169689Skan
43169689Skan  unsigned getNumOpcodes() const { return NumOpcodes; }
44169689Skan
45169689Skan  /// get - Return the machine instruction descriptor that corresponds to the
46169689Skan  /// specified instruction opcode.
47169689Skan  ///
48169689Skan  const MCInstrDesc &get(unsigned Opcode) const {
49169689Skan    assert(Opcode < NumOpcodes && "Invalid opcode!");
50169689Skan    return Desc[Opcode];
51169689Skan  }
52169689Skan
53169689Skan  /// getName - Returns the name for the instructions with the given opcode.
54169689Skan  const char *getName(unsigned Opcode) const {
55169689Skan    assert(Opcode < NumOpcodes && "Invalid opcode!");
56169689Skan    return &InstrNameData[InstrNameIndices[Opcode]];
57169689Skan  }
58169689Skan};
59169689Skan
60169689Skan} // End llvm namespace
61169689Skan
62169689Skan#endif
63169689Skan