LLVM  10.0.0svn
PPCMCCodeEmitter.h
Go to the documentation of this file.
1 //===-- PPCMCCodeEmitter.h - Convert PPC code to machine code -------------===//
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 implements the PPCMCCodeEmitter class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H
14 #define LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H
15 
16 #include "llvm/MC/MCAsmInfo.h"
17 #include "llvm/MC/MCCodeEmitter.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/MC/MCContext.h"
21 #include "llvm/MC/MCInst.h"
22 
23 namespace llvm {
24 
26  const MCInstrInfo &MCII;
27  const MCContext &CTX;
28  bool IsLittleEndian;
29 
30 public:
32  : MCII(mcii), CTX(ctx),
33  IsLittleEndian(ctx.getAsmInfo()->isLittleEndian()) {}
34  PPCMCCodeEmitter(const PPCMCCodeEmitter &) = delete;
35  void operator=(const PPCMCCodeEmitter &) = delete;
36  ~PPCMCCodeEmitter() override = default;
37 
38  unsigned getDirectBrEncoding(const MCInst &MI, unsigned OpNo,
40  const MCSubtargetInfo &STI) const;
41  unsigned getCondBrEncoding(const MCInst &MI, unsigned OpNo,
43  const MCSubtargetInfo &STI) const;
44  unsigned getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo,
46  const MCSubtargetInfo &STI) const;
47  unsigned getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo,
49  const MCSubtargetInfo &STI) const;
50  unsigned getImm16Encoding(const MCInst &MI, unsigned OpNo,
52  const MCSubtargetInfo &STI) const;
53  unsigned getMemRIEncoding(const MCInst &MI, unsigned OpNo,
55  const MCSubtargetInfo &STI) const;
56  unsigned getMemRIXEncoding(const MCInst &MI, unsigned OpNo,
58  const MCSubtargetInfo &STI) const;
59  unsigned getMemRIX16Encoding(const MCInst &MI, unsigned OpNo,
61  const MCSubtargetInfo &STI) const;
62  unsigned getSPE8DisEncoding(const MCInst &MI, unsigned OpNo,
64  const MCSubtargetInfo &STI) const;
65  unsigned getSPE4DisEncoding(const MCInst &MI, unsigned OpNo,
67  const MCSubtargetInfo &STI) const;
68  unsigned getSPE2DisEncoding(const MCInst &MI, unsigned OpNo,
70  const MCSubtargetInfo &STI) const;
71  unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
73  const MCSubtargetInfo &STI) const;
74  unsigned getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
76  const MCSubtargetInfo &STI) const;
77  unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
79  const MCSubtargetInfo &STI) const;
80 
81  /// getMachineOpValue - Return binary encoding of operand. If the machine
82  /// operand requires relocation, record the relocation and return zero.
83  unsigned getMachineOpValue(const MCInst &MI, const MCOperand &MO,
85  const MCSubtargetInfo &STI) const;
86 
87  // getBinaryCodeForInstr - TableGen'erated function for getting the
88  // binary encoding for an instruction.
89  uint64_t getBinaryCodeForInstr(const MCInst &MI,
91  const MCSubtargetInfo &STI) const;
92 
93  void encodeInstruction(const MCInst &MI, raw_ostream &OS,
95  const MCSubtargetInfo &STI) const override;
96 
97  // Get the number of bytes used to encode the given MCInst.
98  unsigned getInstSizeInBytes(const MCInst &MI) const;
99 
100 private:
101  FeatureBitset computeAvailableFeatures(const FeatureBitset &FB) const;
102  void
103  verifyInstructionPredicates(const MCInst &MI,
104  const FeatureBitset &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:23
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:41
Context object for machine code objects.
Definition: MCContext.h:64
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:158
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:21
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:23
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:45
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:34