1 //===-- llvm/MC/MCInstrInfo.h - Target Instruction Info ---------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the target machine instruction set.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_MC_MCINSTRINFO_H
14 #define LLVM_MC_MCINSTRINFO_H
16 #include "llvm/MC/MCInstrDesc.h"
21 //---------------------------------------------------------------------------
22 /// Interface to description of machine instruction set.
24 const MCInstrDesc
*Desc
; // Raw array to allow static init'n
25 const unsigned *InstrNameIndices
; // Array for name indices in InstrNameData
26 const char *InstrNameData
; // Instruction name string pool
27 unsigned NumOpcodes
; // Number of entries in the desc array
30 /// Initialize MCInstrInfo, called by TableGen auto-generated routines.
32 void InitMCInstrInfo(const MCInstrDesc
*D
, const unsigned *NI
, const char *ND
,
35 InstrNameIndices
= NI
;
40 unsigned getNumOpcodes() const { return NumOpcodes
; }
42 /// Return the machine instruction descriptor that corresponds to the
43 /// specified instruction opcode.
44 const MCInstrDesc
&get(unsigned Opcode
) const {
45 assert(Opcode
< NumOpcodes
&& "Invalid opcode!");
49 /// Returns the name for the instructions with the given opcode.
50 StringRef
getName(unsigned Opcode
) const {
51 assert(Opcode
< NumOpcodes
&& "Invalid opcode!");
52 return StringRef(&InstrNameData
[InstrNameIndices
[Opcode
]]);
56 } // End llvm namespace