1 //===-- PPCMCCodeEmitter.h - Convert PPC code to machine code -------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the PPCMCCodeEmitter class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H
15 #define LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H
17 #include "llvm/MC/MCAsmInfo.h"
18 #include "llvm/MC/MCCodeEmitter.h"
19 #include "llvm/MC/MCSubtargetInfo.h"
20 #include "llvm/MC/MCInstrInfo.h"
21 #include "llvm/MC/MCContext.h"
22 #include "llvm/MC/MCInst.h"
26 class PPCMCCodeEmitter : public MCCodeEmitter {
27 const MCInstrInfo &MCII;
32 PPCMCCodeEmitter(const MCInstrInfo &mcii, MCContext &ctx)
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;
39 unsigned getDirectBrEncoding(const MCInst &MI, unsigned OpNo,
40 SmallVectorImpl<MCFixup> &Fixups,
41 const MCSubtargetInfo &STI) const;
42 unsigned getCondBrEncoding(const MCInst &MI, unsigned OpNo,
43 SmallVectorImpl<MCFixup> &Fixups,
44 const MCSubtargetInfo &STI) const;
45 unsigned getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo,
46 SmallVectorImpl<MCFixup> &Fixups,
47 const MCSubtargetInfo &STI) const;
48 unsigned getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo,
49 SmallVectorImpl<MCFixup> &Fixups,
50 const MCSubtargetInfo &STI) const;
51 unsigned getImm16Encoding(const MCInst &MI, unsigned OpNo,
52 SmallVectorImpl<MCFixup> &Fixups,
53 const MCSubtargetInfo &STI) const;
54 unsigned getMemRIEncoding(const MCInst &MI, unsigned OpNo,
55 SmallVectorImpl<MCFixup> &Fixups,
56 const MCSubtargetInfo &STI) const;
57 unsigned getMemRIXEncoding(const MCInst &MI, unsigned OpNo,
58 SmallVectorImpl<MCFixup> &Fixups,
59 const MCSubtargetInfo &STI) const;
60 unsigned getMemRIX16Encoding(const MCInst &MI, unsigned OpNo,
61 SmallVectorImpl<MCFixup> &Fixups,
62 const MCSubtargetInfo &STI) const;
63 unsigned getSPE8DisEncoding(const MCInst &MI, unsigned OpNo,
64 SmallVectorImpl<MCFixup> &Fixups,
65 const MCSubtargetInfo &STI) const;
66 unsigned getSPE4DisEncoding(const MCInst &MI, unsigned OpNo,
67 SmallVectorImpl<MCFixup> &Fixups,
68 const MCSubtargetInfo &STI) const;
69 unsigned getSPE2DisEncoding(const MCInst &MI, unsigned OpNo,
70 SmallVectorImpl<MCFixup> &Fixups,
71 const MCSubtargetInfo &STI) const;
72 unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
73 SmallVectorImpl<MCFixup> &Fixups,
74 const MCSubtargetInfo &STI) const;
75 unsigned getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
76 SmallVectorImpl<MCFixup> &Fixups,
77 const MCSubtargetInfo &STI) const;
78 unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
79 SmallVectorImpl<MCFixup> &Fixups,
80 const MCSubtargetInfo &STI) const;
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,
85 SmallVectorImpl<MCFixup> &Fixups,
86 const MCSubtargetInfo &STI) const;
88 // getBinaryCodeForInstr - TableGen'erated function for getting the
89 // binary encoding for an instruction.
90 uint64_t getBinaryCodeForInstr(const MCInst &MI,
91 SmallVectorImpl<MCFixup> &Fixups,
92 const MCSubtargetInfo &STI) const;
94 void encodeInstruction(const MCInst &MI, raw_ostream &OS,
95 SmallVectorImpl<MCFixup> &Fixups,
96 const MCSubtargetInfo &STI) const override;
98 // Get the number of bytes used to encode the given MCInst.
99 unsigned getInstSizeInBytes(const MCInst &MI) const;
102 uint64_t computeAvailableFeatures(const FeatureBitset &FB) const;
103 void verifyInstructionPredicates(const MCInst &MI,
104 uint64_t AvailableFeatures) const;
109 #endif // LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H