Path: blob/main/contrib/llvm-project/llvm/lib/Target/X86/MCA/X86CustomBehaviour.cpp
35294 views
//===------------------- X86CustomBehaviour.cpp -----------------*-C++ -* -===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7/// \file8///9/// This file implements methods from the X86CustomBehaviour class.10///11//===----------------------------------------------------------------------===//1213#include "X86CustomBehaviour.h"14#include "TargetInfo/X86TargetInfo.h"15#include "MCTargetDesc/X86BaseInfo.h"16#include "llvm/MC/TargetRegistry.h"17#include "llvm/Support/WithColor.h"1819namespace llvm {20namespace mca {2122void X86InstrPostProcess::setMemBarriers(std::unique_ptr<Instruction> &Inst,23const MCInst &MCI) {24switch (MCI.getOpcode()) {25case X86::MFENCE:26Inst->setLoadBarrier(true);27Inst->setStoreBarrier(true);28break;29case X86::LFENCE:30Inst->setLoadBarrier(true);31break;32case X86::SFENCE:33Inst->setStoreBarrier(true);34break;35}36}3738void X86InstrPostProcess::postProcessInstruction(39std::unique_ptr<Instruction> &Inst, const MCInst &MCI) {40// Currently, we only modify certain instructions' IsALoadBarrier and41// IsAStoreBarrier flags.42setMemBarriers(Inst, MCI);43}4445} // namespace mca46} // namespace llvm4748using namespace llvm;49using namespace mca;5051static InstrPostProcess *createX86InstrPostProcess(const MCSubtargetInfo &STI,52const MCInstrInfo &MCII) {53return new X86InstrPostProcess(STI, MCII);54}5556/// Extern function to initialize the targets for the X86 backend5758extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86TargetMCA() {59TargetRegistry::RegisterInstrPostProcess(getTheX86_32Target(),60createX86InstrPostProcess);61TargetRegistry::RegisterInstrPostProcess(getTheX86_64Target(),62createX86InstrPostProcess);63}646566