LLVM  8.0.1
PPCMCCodeEmitter.h
Go to the documentation of this file.
1 //===-- PPCMCCodeEmitter.h - Convert PPC code to machine code -------------===//
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 // This file implements the PPCMCCodeEmitter class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H
15 #define LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H
16 
17 #include "llvm/MC/MCAsmInfo.h"
18 #include "llvm/MC/MCCodeEmitter.h"
20 #include "llvm/MC/MCInstrInfo.h"
21 #include "llvm/MC/MCContext.h"
22 #include "llvm/MC/MCInst.h"
23 
24 namespace llvm {
25 
27  const MCInstrInfo &MCII;
28  const MCContext &CTX;
29  bool IsLittleEndian;
30 
31 public:
33  : MCII(mcii), CTX(ctx),
34  IsLittleEndian(ctx.getAsmInfo()->isLittleEndian()) {}
35  PPCMCCodeEmitter(const PPCMCCodeEmitter &) = delete;
36  void operator=(const PPCMCCodeEmitter &) = delete;
37  ~PPCMCCodeEmitter() override = default;
38 
39  unsigned getDirectBrEncoding(const MCInst &MI, unsigned OpNo,
41  const MCSubtargetInfo &STI) const;
42  unsigned getCondBrEncoding(const MCInst &MI, unsigned OpNo,
44  const MCSubtargetInfo &STI) const;
45  unsigned getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo,
47  const MCSubtargetInfo &STI) const;
48  unsigned getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo,
50  const MCSubtargetInfo &STI) const;
51  unsigned getImm16Encoding(const MCInst &MI, unsigned OpNo,
53  const MCSubtargetInfo &STI) const;
54  unsigned getMemRIEncoding(const MCInst &MI, unsigned OpNo,
56  const MCSubtargetInfo &STI) const;
57  unsigned getMemRIXEncoding(const MCInst &MI, unsigned OpNo,
59  const MCSubtargetInfo &STI) const;
60  unsigned getMemRIX16Encoding(const MCInst &MI, unsigned OpNo,
62  const MCSubtargetInfo &STI) const;
63  unsigned getSPE8DisEncoding(const MCInst &MI, unsigned OpNo,
65  const MCSubtargetInfo &STI) const;
66  unsigned getSPE4DisEncoding(const MCInst &MI, unsigned OpNo,
68  const MCSubtargetInfo &STI) const;
69  unsigned getSPE2DisEncoding(const MCInst &MI, unsigned OpNo,
71  const MCSubtargetInfo &STI) const;
72  unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
74  const MCSubtargetInfo &STI) const;
75  unsigned getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
77  const MCSubtargetInfo &STI) const;
78  unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
80  const MCSubtargetInfo &STI) const;
81 
82  /// getMachineOpValue - Return binary encoding of operand. If the machine
83  /// operand requires relocation, record the relocation and return zero.
84  unsigned getMachineOpValue(const MCInst &MI, const MCOperand &MO,
86  const MCSubtargetInfo &STI) const;
87 
88  // getBinaryCodeForInstr - TableGen'erated function for getting the
89  // binary encoding for an instruction.
90  uint64_t getBinaryCodeForInstr(const MCInst &MI,
92  const MCSubtargetInfo &STI) const;
93 
94  void encodeInstruction(const MCInst &MI, raw_ostream &OS,
96  const MCSubtargetInfo &STI) const override;
97 
98  // Get the number of bytes used to encode the given MCInst.
99  unsigned getInstSizeInBytes(const MCInst &MI) const;
100 
101 private:
102  uint64_t computeAvailableFeatures(const FeatureBitset &FB) const;
103  void verifyInstructionPredicates(const MCInst &MI,
104  uint64_t AvailableFeatures) const;
105 };
106 
107 } // namespace llvm
108 
109 #endif // LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H
unsigned getMemRIEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
This class represents lattice values for constants.
Definition: AllocatorList.h:24
void encodeInstruction(const MCInst &MI, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const override
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
~PPCMCCodeEmitter() override=default
unsigned getImm16Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getMemRIX16Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getCondBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
Context object for machine code objects.
Definition: MCContext.h:63
unsigned getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getSPE4DisEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:161
Container class for subtarget features.
unsigned getMachineOpValue(const MCInst &MI, const MCOperand &MO, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getMachineOpValue - Return binary encoding of operand.
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:22
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
unsigned getInstSizeInBytes(const MCInst &MI) const
unsigned getSPE2DisEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getMemRIXEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getBinaryCodeForInstr(const MCInst &MI, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
PPCMCCodeEmitter(const MCInstrInfo &mcii, MCContext &ctx)
unsigned getDirectBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getTLSCallEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
Generic base class for all target subtargets.
unsigned getSPE8DisEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
void operator=(const PPCMCCodeEmitter &)=delete
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
IRTranslator LLVM IR MI
unsigned getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:35