LLVM 24.0.0git
X86MCLFIRewriter.h
Go to the documentation of this file.
1//===- X86MCLFIRewriter.h ---------------------------------------*- C++ -*-===//
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 declares the X86MCLFIRewriter class, the X86 specific
10// subclass of MCLFIRewriter.
11//
12//===----------------------------------------------------------------------===//
13#ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCLFIREWRITER_H
14#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCLFIREWRITER_H
15
16#include "llvm/MC/MCInstrInfo.h"
19
20namespace llvm {
21class MCContext;
22class MCInst;
23class MCStreamer;
24class MCSubtargetInfo;
25
26namespace X86 {
27
28constexpr unsigned LFIBundleSize = 32;
29
31public:
32 X86MCLFIRewriter(MCContext &Ctx, std::unique_ptr<MCRegisterInfo> &&RI,
33 std::unique_ptr<MCInstrInfo> &&II)
34 : MCLFIRewriter(Ctx, std::move(RI), std::move(II)) {}
35
36 bool rewriteInst(const MCInst &Inst, MCStreamer &Out,
37 const MCSubtargetInfo &STI) override;
38
39private:
40 /// Recursion guard to prevent infinite loops when emitting instructions.
41 bool Guard = false;
42
43 void doRewriteInst(const MCInst &Inst, MCStreamer &Out,
44 const MCSubtargetInfo &STI);
45
46 void rewriteSyscall(const MCInst &Inst, MCStreamer &Out,
47 const MCSubtargetInfo &STI);
48
49 /// Emit the mask sequence that turns an arbitrary value in Reg into a
50 /// bundle-aligned address inside the sandbox.
51 void emitSandboxBranchReg(MCRegister Reg, MCStreamer &Out,
52 const MCSubtargetInfo &STI);
53
54 void rewriteIndirectBranch(const MCInst &Inst, MCStreamer &Out,
55 const MCSubtargetInfo &STI);
56 void rewriteDirectCall(const MCInst &Inst, MCStreamer &Out,
57 const MCSubtargetInfo &STI);
58 void rewriteReturn(const MCInst &Inst, MCStreamer &Out,
59 const MCSubtargetInfo &STI);
60
61 bool isFSAccess(const MCInst &Inst);
62 void rewriteFSAccess(const MCInst &Inst, MCStreamer &Out,
63 const MCSubtargetInfo &STI);
64};
65
66} // namespace X86
67} // namespace llvm
68#endif // LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCLFIREWRITER_H
This file declares the MCLFIRewriter class, an abstract class that encapsulates the rewriting logic f...
Register Reg
uint64_t IntrinsicInst * II
Context object for machine code objects.
Definition MCContext.h:83
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
MCLFIRewriter(MCContext &Ctx, std::unique_ptr< MCRegisterInfo > &&RI, std::unique_ptr< MCInstrInfo > &&II)
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
Streaming machine code generation interface.
Definition MCStreamer.h:222
Generic base class for all target subtargets.
X86MCLFIRewriter(MCContext &Ctx, std::unique_ptr< MCRegisterInfo > &&RI, std::unique_ptr< MCInstrInfo > &&II)
bool rewriteInst(const MCInst &Inst, MCStreamer &Out, const MCSubtargetInfo &STI) override
Define some predicates that are used for node matching.
constexpr unsigned LFIBundleSize
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878