MCInstrInfo.h revision 224133
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 {
27224133Sdim  const MCInstrDesc *Desc;  // Raw array to allow static init'n
28224133Sdim  unsigned NumOpcodes;      // Number of entries in the desc array
29224133Sdim
30224133Sdimpublic:
31224133Sdim  /// InitMCInstrInfo - Initialize MCInstrInfo, called by TableGen
32224133Sdim  /// auto-generated routines. *DO NOT USE*.
33224133Sdim  void InitMCInstrInfo(const MCInstrDesc *D, unsigned NO) {
34224133Sdim    Desc = D;
35224133Sdim    NumOpcodes = NO;
36224133Sdim  }
37224133Sdim
38224133Sdim  unsigned getNumOpcodes() const { return NumOpcodes; }
39224133Sdim
40224133Sdim  /// get - Return the machine instruction descriptor that corresponds to the
41224133Sdim  /// specified instruction opcode.
42224133Sdim  ///
43224133Sdim  const MCInstrDesc &get(unsigned Opcode) const {
44224133Sdim    assert(Opcode < NumOpcodes && "Invalid opcode!");
45224133Sdim    return Desc[Opcode];
46224133Sdim  }
47224133Sdim};
48224133Sdim
49224133Sdim} // End llvm namespace
50224133Sdim
51224133Sdim#endif
52