LLVM 20.0.0git
X86CustomBehaviour.cpp
Go to the documentation of this file.
1//===------------------- X86CustomBehaviour.cpp -----------------*-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/// \file
9///
10/// This file implements methods from the X86CustomBehaviour class.
11///
12//===----------------------------------------------------------------------===//
13
14#include "X86CustomBehaviour.h"
18
19namespace llvm {
20namespace mca {
21
22void X86InstrPostProcess::setMemBarriers(std::unique_ptr<Instruction> &Inst,
23 const MCInst &MCI) {
24 switch (MCI.getOpcode()) {
25 case X86::MFENCE:
26 Inst->setLoadBarrier(true);
27 Inst->setStoreBarrier(true);
28 break;
29 case X86::LFENCE:
30 Inst->setLoadBarrier(true);
31 break;
32 case X86::SFENCE:
33 Inst->setStoreBarrier(true);
34 break;
35 }
36}
37
39 std::unique_ptr<Instruction> &Inst, const MCInst &MCI) {
40 // Currently, we only modify certain instructions' IsALoadBarrier and
41 // IsAStoreBarrier flags.
42 setMemBarriers(Inst, MCI);
43}
44
45} // namespace mca
46} // namespace llvm
47
48using namespace llvm;
49using namespace mca;
50
52 const MCInstrInfo &MCII) {
53 return new X86InstrPostProcess(STI, MCII);
54}
55
56/// Extern function to initialize the targets for the X86 backend
57
63}
#define LLVM_C_ABI
Definition: Compiler.h:218
LLVM_C_ABI void LLVMInitializeX86TargetMCA()
Extern function to initialize the targets for the X86 backend.
static InstrPostProcess * createX86InstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
This file defines the X86CustomBehaviour class which inherits from CustomBehaviour.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:185
unsigned getOpcode() const
Definition: MCInst.h:199
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
Generic base class for all target subtargets.
Class which can be overriden by targets to modify the mca::Instruction objects before the pipeline st...
void postProcessInstruction(std::unique_ptr< Instruction > &Inst, const MCInst &MCI) override
This method can be overriden by targets to modify the mca::Instruction object after it has been lower...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Target & getTheX86_32Target()
Target & getTheX86_64Target()
static void RegisterInstrPostProcess(Target &T, Target::InstrPostProcessCtorTy Fn)
RegisterInstrPostProcess - Register an InstrPostProcess implementation for the given target.