Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 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"
18
#include <cassert>
19
 
20
namespace llvm {
21
 
22
class MCSubtargetInfo;
23
 
24
//---------------------------------------------------------------------------
25
/// Interface to description of machine instruction set.
26
class MCInstrInfo {
27
public:
28
  using ComplexDeprecationPredicate = bool (*)(MCInst &,
29
                                               const MCSubtargetInfo &,
30
                                               std::string &);
31
 
32
private:
33
  const MCInstrDesc *LastDesc;      // Raw array to allow static init'n
34
  const unsigned *InstrNameIndices; // Array for name indices in InstrNameData
35
  const char *InstrNameData;        // Instruction name string pool
36
  // Subtarget feature that an instruction is deprecated on, if any
37
  // -1 implies this is not deprecated by any single feature. It may still be
38
  // deprecated due to a "complex" reason, below.
39
  const uint8_t *DeprecatedFeatures;
40
  // A complex method to determine if a certain instruction is deprecated or
41
  // not, and return the reason for deprecation.
42
  const ComplexDeprecationPredicate *ComplexDeprecationInfos;
43
  unsigned NumOpcodes;              // Number of entries in the desc array
44
 
45
public:
46
  /// Initialize MCInstrInfo, called by TableGen auto-generated routines.
47
  /// *DO NOT USE*.
48
  void InitMCInstrInfo(const MCInstrDesc *D, const unsigned *NI, const char *ND,
49
                       const uint8_t *DF,
50
                       const ComplexDeprecationPredicate *CDI, unsigned NO) {
51
    LastDesc = D + NO - 1;
52
    InstrNameIndices = NI;
53
    InstrNameData = ND;
54
    DeprecatedFeatures = DF;
55
    ComplexDeprecationInfos = CDI;
56
    NumOpcodes = NO;
57
  }
58
 
59
  unsigned getNumOpcodes() const { return NumOpcodes; }
60
 
61
  /// Return the machine instruction descriptor that corresponds to the
62
  /// specified instruction opcode.
63
  const MCInstrDesc &get(unsigned Opcode) const {
64
    assert(Opcode < NumOpcodes && "Invalid opcode!");
65
    // The table is indexed backwards from the last entry.
66
    return *(LastDesc - Opcode);
67
  }
68
 
69
  /// Returns the name for the instructions with the given opcode.
70
  StringRef getName(unsigned Opcode) const {
71
    assert(Opcode < NumOpcodes && "Invalid opcode!");
72
    return StringRef(&InstrNameData[InstrNameIndices[Opcode]]);
73
  }
74
 
75
  /// Returns true if a certain instruction is deprecated and if so
76
  /// returns the reason in \p Info.
77
  bool getDeprecatedInfo(MCInst &MI, const MCSubtargetInfo &STI,
78
                         std::string &Info) const;
79
};
80
 
81
} // End llvm namespace
82
 
83
#endif