PageRenderTime 17ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/3rd_party/llvm/include/llvm/MC/MCInstrInfo.h

https://code.google.com/p/softart/
C++ Header | 62 lines | 30 code | 10 blank | 22 comment | 2 complexity | 9bd9d1052f8abc66aa37b97fa81ac10f MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, JSON, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0, LGPL-3.0, BSD-2-Clause
 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
20namespace llvm {
21
22//---------------------------------------------------------------------------
23///
24/// MCInstrInfo - Interface to description of machine instruction set
25///
26class MCInstrInfo {
27  const MCInstrDesc *Desc;          // Raw array to allow static init'n
28  const unsigned *InstrNameIndices; // Array for name indices in InstrNameData
29  const char *InstrNameData;        // Instruction name string pool
30  unsigned NumOpcodes;              // Number of entries in the desc array
31
32public:
33  /// InitMCInstrInfo - Initialize MCInstrInfo, called by TableGen
34  /// auto-generated routines. *DO NOT USE*.
35  void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND,
36                       unsigned NO) {
37    Desc = D;
38    InstrNameIndices = NI;
39    InstrNameData = ND;
40    NumOpcodes = NO;
41  }
42
43  unsigned getNumOpcodes() const { return NumOpcodes; }
44
45  /// get - Return the machine instruction descriptor that corresponds to the
46  /// specified instruction opcode.
47  ///
48  const MCInstrDesc &get(unsigned Opcode) const {
49    assert(Opcode < NumOpcodes && "Invalid opcode!");
50    return Desc[Opcode];
51  }
52
53  /// getName - Returns the name for the instructions with the given opcode.
54  const char *getName(unsigned Opcode) const {
55    assert(Opcode < NumOpcodes && "Invalid opcode!");
56    return &InstrNameData[InstrNameIndices[Opcode]];
57  }
58};
59
60} // End llvm namespace
61
62#endif