LLVM 20.0.0git
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"
19#include "llvm/MC/MCInstrInfo.h"
20#include "llvm/MC/MCContext.h"
21#include "llvm/MC/MCInst.h"
22
23namespace llvm {
24
26 const MCInstrInfo &MCII;
27 const MCContext &CTX;
28 bool IsLittleEndian;
29
30public:
32 : MCII(mcii), CTX(ctx),
33 IsLittleEndian(ctx.getAsmInfo()->isLittleEndian()) {}
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 uint64_t getImm34Encoding(const MCInst &MI, unsigned OpNo,
55 const MCSubtargetInfo &STI,
56 MCFixupKind Fixup) const;
57 uint64_t getImm34EncodingNoPCRel(const MCInst &MI, unsigned OpNo,
59 const MCSubtargetInfo &STI) const;
60 uint64_t getImm34EncodingPCRel(const MCInst &MI, unsigned OpNo,
62 const MCSubtargetInfo &STI) const;
63 unsigned getDispRIEncoding(const MCInst &MI, unsigned OpNo,
65 const MCSubtargetInfo &STI) const;
66 unsigned getDispRIXEncoding(const MCInst &MI, unsigned OpNo,
68 const MCSubtargetInfo &STI) const;
69 unsigned getDispRIX16Encoding(const MCInst &MI, unsigned OpNo,
71 const MCSubtargetInfo &STI) const;
72 unsigned getDispRIHashEncoding(const MCInst &MI, unsigned OpNo,
74 const MCSubtargetInfo &STI) const;
75 uint64_t getDispRI34PCRelEncoding(const MCInst &MI, unsigned OpNo,
77 const MCSubtargetInfo &STI) const;
78 uint64_t getDispRI34Encoding(const MCInst &MI, unsigned OpNo,
80 const MCSubtargetInfo &STI) const;
81 unsigned getDispSPE8Encoding(const MCInst &MI, unsigned OpNo,
83 const MCSubtargetInfo &STI) const;
84 unsigned getDispSPE4Encoding(const MCInst &MI, unsigned OpNo,
86 const MCSubtargetInfo &STI) const;
87 unsigned getDispSPE2Encoding(const MCInst &MI, unsigned OpNo,
89 const MCSubtargetInfo &STI) const;
90 unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
92 const MCSubtargetInfo &STI) const;
93 unsigned getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
95 const MCSubtargetInfo &STI) const;
96 unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
98 const MCSubtargetInfo &STI) const;
99 unsigned getVSRpEvenEncoding(const MCInst &MI, unsigned OpNo,
101 const MCSubtargetInfo &STI) const;
102
103 /// getMachineOpValue - Return binary encoding of operand. If the machine
104 /// operand requires relocation, record the relocation and return zero.
105 uint64_t getMachineOpValue(const MCInst &MI, const MCOperand &MO,
107 const MCSubtargetInfo &STI) const;
108
109 // getBinaryCodeForInstr - TableGen'erated function for getting the
110 // binary encoding for an instruction.
113 const MCSubtargetInfo &STI) const;
114
117 const MCSubtargetInfo &STI) const override;
118
119 // Get the number of bytes used to encode the given MCInst.
120 unsigned getInstSizeInBytes(const MCInst &MI) const;
121
122 // Is this instruction a prefixed instruction.
123 bool isPrefixedInstruction(const MCInst &MI) const;
124
125 /// Check if Opcode corresponds to a call instruction that should be marked
126 /// with the NOTOC relocation.
127 bool isNoTOCCallInstr(const MCInst &MI) const;
128};
129
130} // namespace llvm
131
132#endif // LLVM_LIB_TARGET_PPC_MCCODEEMITTER_PPCCODEEMITTER_H
IRTranslator LLVM IR MI
PowerPC TLS Dynamic Call Fixup
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:21
Context object for machine code objects.
Definition: MCContext.h:83
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:36
Generic base class for all target subtargets.
unsigned getDispSPE2Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getImm34EncodingNoPCRel(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
void operator=(const PPCMCCodeEmitter &)=delete
unsigned getDispRIHashEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getDispRI34Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDirectBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDispRIXEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDispSPE8Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
void encodeInstruction(const MCInst &MI, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const override
Encode the given Inst to bytes and append to CB.
unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
PPCMCCodeEmitter(const MCInstrInfo &mcii, MCContext &ctx)
bool isNoTOCCallInstr(const MCInst &MI) const
Check if Opcode corresponds to a call instruction that should be marked with the NOTOC relocation.
unsigned getDispRIX16Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
~PPCMCCodeEmitter() override=default
uint64_t getDispRI34PCRelEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
bool isPrefixedInstruction(const MCInst &MI) const
unsigned getDispSPE4Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDispRIEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getImm34EncodingPCRel(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getMachineOpValue(const MCInst &MI, const MCOperand &MO, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getMachineOpValue - Return binary encoding of operand.
unsigned getImm16Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getVSRpEvenEncoding(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
uint64_t getImm34Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI, MCFixupKind Fixup) const
PPCMCCodeEmitter(const PPCMCCodeEmitter &)=delete
unsigned getInstSizeInBytes(const MCInst &MI) const
unsigned getCondBrEncoding(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
unsigned get_crbitm_encoding(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: SmallVector.h:586
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:21