LLVM  5.0.0
HexagonMCCodeEmitter.h
Go to the documentation of this file.
1 //===-- HexagonMCCodeEmitter.h - Hexagon Target Descriptions ----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Definition for classes that emit Hexagon machine code from MCInsts
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef HEXAGONMCCODEEMITTER_H
16 #define HEXAGONMCCODEEMITTER_H
17 
19 #include "llvm/MC/MCCodeEmitter.h"
20 #include "llvm/MC/MCExpr.h"
21 #include "llvm/MC/MCInst.h"
22 #include "llvm/MC/MCInstrInfo.h"
23 #include "llvm/MC/MCRegisterInfo.h"
26 
27 namespace llvm {
28 
30  MCContext &MCT;
31  MCInstrInfo const &MCII;
32  std::unique_ptr<unsigned> Addend;
33  std::unique_ptr<bool> Extended;
34  std::unique_ptr<MCInst const *> CurrentBundle;
35  std::unique_ptr<size_t> CurrentIndex;
36 
37  // helper routine for getMachineOpValue()
38  unsigned getExprOpValue(const MCInst &MI, const MCOperand &MO,
40  const MCSubtargetInfo &STI) const;
41 
42  Hexagon::Fixups getFixupNoBits(MCInstrInfo const &MCII, const MCInst &MI,
43  const MCOperand &MO,
44  const MCSymbolRefExpr::VariantKind kind) const;
45 
46 public:
47  HexagonMCCodeEmitter(MCInstrInfo const &aMII, MCContext &aMCT);
48 
49  // Return parse bits for instruction `MCI' inside bundle `MCB'
50  uint32_t parseBits(size_t Last, MCInst const &MCB, MCInst const &MCI) const;
51 
52  void encodeInstruction(MCInst const &MI, raw_ostream &OS,
54  MCSubtargetInfo const &STI) const override;
55 
56  void EncodeSingleInstruction(const MCInst &MI, raw_ostream &OS,
58  const MCSubtargetInfo &STI,
59  uint32_t Parse) const;
60 
61  // \brief TableGen'erated function for getting the
62  // binary encoding for an instruction.
63  uint64_t getBinaryCodeForInstr(MCInst const &MI,
65  MCSubtargetInfo const &STI) const;
66 
67  /// \brief Return binary encoding of operand.
68  unsigned getMachineOpValue(MCInst const &MI, MCOperand const &MO,
70  MCSubtargetInfo const &STI) const;
71 
72 private:
73  uint64_t computeAvailableFeatures(const FeatureBitset &FB) const;
74  void verifyInstructionPredicates(const MCInst &MI,
75  uint64_t AvailableFeatures) const;
76 }; // class HexagonMCCodeEmitter
77 
78 } // namespace llvm
79 
80 #endif /* HEXAGONMCCODEEMITTER_H */
uint64_t getBinaryCodeForInstr(MCInst const &MI, SmallVectorImpl< MCFixup > &Fixups, MCSubtargetInfo const &STI) const
uint32_t parseBits(size_t Last, MCInst const &MCB, MCInst const &MCI) const
void EncodeSingleInstruction(const MCInst &MI, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI, uint32_t Parse) const
EncodeSingleInstruction - Emit a single.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
Context object for machine code objects.
Definition: MCContext.h:59
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:159
void encodeInstruction(MCInst const &MI, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, MCSubtargetInfo const &STI) const override
EncodeInstruction - Emit the bundle.
Container class for subtarget features.
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:22
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
HexagonMCCodeEmitter(MCInstrInfo const &aMII, MCContext &aMCT)
MCSubtargetInfo - Generic base class for all target subtargets.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
IRTranslator LLVM IR MI
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:35
unsigned getMachineOpValue(MCInst const &MI, MCOperand const &MO, SmallVectorImpl< MCFixup > &Fixups, MCSubtargetInfo const &STI) const
Return binary encoding of operand.