Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/MCInstrInfo.h
Line
Count
Source
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
129k
                       unsigned NO) {
34
129k
    Desc = D;
35
129k
    InstrNameIndices = NI;
36
129k
    InstrNameData = ND;
37
129k
    NumOpcodes = NO;
38
129k
  }
39
40
2.34k
  unsigned getNumOpcodes() const { return NumOpcodes; }
41
42
  /// Return the machine instruction descriptor that corresponds to the
43
  /// specified instruction opcode.
44
192M
  const MCInstrDesc &get(unsigned Opcode) const {
45
192M
    assert(Opcode < NumOpcodes && "Invalid opcode!");
46
192M
    return Desc[Opcode];
47
192M
  }
48
49
  /// Returns the name for the instructions with the given opcode.
50
24.3M
  StringRef getName(unsigned Opcode) const {
51
24.3M
    assert(Opcode < NumOpcodes && "Invalid opcode!");
52
24.3M
    return StringRef(&InstrNameData[InstrNameIndices[Opcode]]);
53
24.3M
  }
54
};
55
56
} // End llvm namespace
57
58
#endif