1224133Sdim//===-- llvm/MC/MCInstrInfo.h - Target Instruction Info ---------*- C++ -*-===//
2224133Sdim//
3224133Sdim//                     The LLVM Compiler Infrastructure
4224133Sdim//
5224133Sdim// This file is distributed under the University of Illinois Open Source
6224133Sdim// License. See LICENSE.TXT for details.
7224133Sdim//
8224133Sdim//===----------------------------------------------------------------------===//
9224133Sdim//
10224133Sdim// This file describes the target machine instruction set.
11224133Sdim//
12224133Sdim//===----------------------------------------------------------------------===//
13224133Sdim
14224133Sdim#ifndef LLVM_MC_MCINSTRINFO_H
15224133Sdim#define LLVM_MC_MCINSTRINFO_H
16224133Sdim
17224133Sdim#include "llvm/MC/MCInstrDesc.h"
18224133Sdim#include <cassert>
19224133Sdim
20224133Sdimnamespace llvm {
21224133Sdim
22224133Sdim//---------------------------------------------------------------------------
23224133Sdim///
24224133Sdim/// MCInstrInfo - Interface to description of machine instruction set
25224133Sdim///
26224133Sdimclass MCInstrInfo {
27234353Sdim  const MCInstrDesc *Desc;          // Raw array to allow static init'n
28234353Sdim  const unsigned *InstrNameIndices; // Array for name indices in InstrNameData
29234353Sdim  const char *InstrNameData;        // Instruction name string pool
30234353Sdim  unsigned NumOpcodes;              // Number of entries in the desc array
31224133Sdim
32224133Sdimpublic:
33224133Sdim  /// InitMCInstrInfo - Initialize MCInstrInfo, called by TableGen
34224133Sdim  /// auto-generated routines. *DO NOT USE*.
35234353Sdim  void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND,
36234353Sdim                       unsigned NO) {
37224133Sdim    Desc = D;
38234353Sdim    InstrNameIndices = NI;
39234353Sdim    InstrNameData = ND;
40224133Sdim    NumOpcodes = NO;
41224133Sdim  }
42224133Sdim
43224133Sdim  unsigned getNumOpcodes() const { return NumOpcodes; }
44224133Sdim
45224133Sdim  /// get - Return the machine instruction descriptor that corresponds to the
46224133Sdim  /// specified instruction opcode.
47224133Sdim  ///
48224133Sdim  const MCInstrDesc &get(unsigned Opcode) const {
49224133Sdim    assert(Opcode < NumOpcodes && "Invalid opcode!");
50224133Sdim    return Desc[Opcode];
51224133Sdim  }
52234353Sdim
53234353Sdim  /// getName - Returns the name for the instructions with the given opcode.
54234353Sdim  const char *getName(unsigned Opcode) const {
55234353Sdim    assert(Opcode < NumOpcodes && "Invalid opcode!");
56234353Sdim    return &InstrNameData[InstrNameIndices[Opcode]];
57234353Sdim  }
58224133Sdim};
59224133Sdim
60224133Sdim} // End llvm namespace
61224133Sdim
62224133Sdim#endif
63