Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
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/ADT/StringRef.h"
17#include "llvm/MC/MCInstrDesc.h"
19#include <cassert>
20
21namespace llvm {
22
23class MCSubtargetInfo;
24
25//---------------------------------------------------------------------------
26/// Interface to description of machine instruction set.
28public:
30 const MCSubtargetInfo &,
31 std::string &);
32
33private:
34 const MCInstrDesc *LastDesc; // Raw array to allow static init'n
35 const unsigned *InstrNameIndices; // Array for name indices in InstrNameData
36 const char *InstrNameData; // Instruction name string pool
37 // Subtarget feature that an instruction is deprecated on, if any
38 // -1 implies this is not deprecated by any single feature. It may still be
39 // deprecated due to a "complex" reason, below.
40 const uint8_t *DeprecatedFeatures;
41 // A complex method to determine if a certain instruction is deprecated or
42 // not, and return the reason for deprecation.
43 const ComplexDeprecationPredicate *ComplexDeprecationInfos;
44 unsigned NumOpcodes; // Number of entries in the desc array
45
46protected:
47 // Pointer to 2d array [NumHwModes][NumRegClassByHwModes]
48 const int16_t *RegClassByHwModeTables;
50
51public:
52 /// Initialize MCInstrInfo, called by TableGen auto-generated routines.
53 /// *DO NOT USE*.
54 void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND,
55 const uint8_t *DF,
56 const ComplexDeprecationPredicate *CDI, unsigned NO,
57 const int16_t *RCHWTables = nullptr,
58 int16_t NumRegClassByHwMode = 0) {
59 LastDesc = D + NO - 1;
60 InstrNameIndices = NI;
61 InstrNameData = ND;
62 DeprecatedFeatures = DF;
63 ComplexDeprecationInfos = CDI;
64 NumOpcodes = NO;
65 RegClassByHwModeTables = RCHWTables;
66 NumRegClassByHwModes = NumRegClassByHwMode;
67 }
68
69 unsigned getNumOpcodes() const { return NumOpcodes; }
70
71 const int16_t *getRegClassByHwModeTable(unsigned ModeId) const {
73 "MCInstrInfo not properly initialized");
75 }
76
77 /// Return the ID of the register class to use for \p OpInfo, for the active
78 /// HwMode \p HwModeId. In general TargetInstrInfo's version which is already
79 /// specialized to the subtarget should be used.
80 int16_t getOpRegClassID(const MCOperandInfo &OpInfo,
81 unsigned HwModeId) const {
82 int16_t RegClass = OpInfo.RegClass;
83 if (OpInfo.isLookupRegClassByHwMode())
84 RegClass = getRegClassByHwModeTable(HwModeId)[RegClass];
85 return RegClass;
86 }
87
88 /// Return the machine instruction descriptor that corresponds to the
89 /// specified instruction opcode.
90 const MCInstrDesc &get(unsigned Opcode) const {
91 assert(Opcode < NumOpcodes && "Invalid opcode!");
92 // The table is indexed backwards from the last entry.
93 return *(LastDesc - Opcode);
94 }
95
96 /// Returns the name for the instructions with the given opcode.
97 StringRef getName(unsigned Opcode) const {
98 assert(Opcode < NumOpcodes && "Invalid opcode!");
99 return StringRef(&InstrNameData[InstrNameIndices[Opcode]]);
100 }
101
102 /// Returns true if a certain instruction is deprecated and if so
103 /// returns the reason in \p Info.
105 std::string &Info) const;
106};
107
108} // End llvm namespace
109
110#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Analysis containing CSE Info
Definition CSEInfo.cpp:27
#define LLVM_ABI
Definition Compiler.h:213
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
IRTranslator LLVM IR MI
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Describe properties that are true of each instruction in the target description file.
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Definition MCInstrInfo.h:90
void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND, const uint8_t *DF, const ComplexDeprecationPredicate *CDI, unsigned NO, const int16_t *RCHWTables=nullptr, int16_t NumRegClassByHwMode=0)
Initialize MCInstrInfo, called by TableGen auto-generated routines.
Definition MCInstrInfo.h:54
const int16_t * getRegClassByHwModeTable(unsigned ModeId) const
Definition MCInstrInfo.h:71
bool(*)(MCInst &, const MCSubtargetInfo &, std::string &) ComplexDeprecationPredicate
Definition MCInstrInfo.h:29
const int16_t * RegClassByHwModeTables
Definition MCInstrInfo.h:48
int16_t NumRegClassByHwModes
Definition MCInstrInfo.h:49
LLVM_ABI bool getDeprecatedInfo(MCInst &MI, const MCSubtargetInfo &STI, std::string &Info) const
Returns true if a certain instruction is deprecated and if so returns the reason in Info.
unsigned getNumOpcodes() const
Definition MCInstrInfo.h:69
int16_t getOpRegClassID(const MCOperandInfo &OpInfo, unsigned HwModeId) const
Return the ID of the register class to use for OpInfo, for the active HwMode HwModeId.
Definition MCInstrInfo.h:80
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
Definition MCInstrInfo.h:97
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition MCInstrDesc.h:87
Generic base class for all target subtargets.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.