LLVM  10.0.0svn
MCInstrInfo.h
Go to the documentation of this file.
1 //===-- llvm/MC/MCInstrInfo.h - Target Instruction Info ---------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file describes the target machine instruction set.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_MC_MCINSTRINFO_H
14 #define LLVM_MC_MCINSTRINFO_H
15 
16 #include "llvm/MC/MCInstrDesc.h"
17 #include <cassert>
18 
19 namespace llvm {
20 
21 //---------------------------------------------------------------------------
22 /// Interface to description of machine instruction set.
23 class MCInstrInfo {
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
28 
29 public:
30  /// Initialize MCInstrInfo, called by TableGen auto-generated routines.
31  /// *DO NOT USE*.
32  void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND,
33  unsigned NO) {
34  Desc = D;
35  InstrNameIndices = NI;
36  InstrNameData = ND;
37  NumOpcodes = NO;
38  }
39 
40  unsigned getNumOpcodes() const { return NumOpcodes; }
41 
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!");
46  return Desc[Opcode];
47  }
48 
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]]);
53  }
54 };
55 
56 } // End llvm namespace
57 
58 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:178
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:23
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
Definition: MCInstrInfo.h:50
void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND, unsigned NO)
Initialize MCInstrInfo, called by TableGen auto-generated routines.
Definition: MCInstrInfo.h:32
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
unsigned getNumOpcodes() const
Definition: MCInstrInfo.h:40
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48