CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
83 lines
2.8 KiB
C++
83 lines
2.8 KiB
C++
//===------------------- X86CustomBehaviour.cpp -----------------*-C++ -* -===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
/// \file
|
|
///
|
|
/// This file implements methods from the X86CustomBehaviour class.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "X86CustomBehaviour.h"
|
|
#include "MCTargetDesc/X86BaseInfo.h"
|
|
#include "TargetInfo/X86TargetInfo.h"
|
|
#include "llvm-c/Visibility.h"
|
|
#include "llvm/MC/TargetRegistry.h"
|
|
|
|
namespace llvm {
|
|
namespace mca {
|
|
|
|
void X86InstrPostProcess::setMemBarriers(Instruction &Inst, const MCInst &MCI) {
|
|
switch (MCI.getOpcode()) {
|
|
case X86::MFENCE:
|
|
Inst.setLoadBarrier(true);
|
|
Inst.setStoreBarrier(true);
|
|
break;
|
|
case X86::LFENCE:
|
|
Inst.setLoadBarrier(true);
|
|
break;
|
|
case X86::SFENCE:
|
|
Inst.setStoreBarrier(true);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void X86InstrPostProcess::useStackEngine(Instruction &Inst, const MCInst &MCI) {
|
|
// TODO(boomanaiden154): We currently do not handle PUSHF/POPF because we
|
|
// have not done the necessary benchmarking to see if they are also
|
|
// optimized by the stack engine.
|
|
// TODO: We currently just remove all RSP writes from stack operations. This
|
|
// is not fully correct because we do not model sync uops which will
|
|
// delay subsequent rsp using non-stack instructions.
|
|
if (X86::isPOP(MCI.getOpcode()) || X86::isPUSH(MCI.getOpcode())) {
|
|
auto *StackRegisterDef =
|
|
llvm::find_if(Inst.getDefs(), [](const WriteState &State) {
|
|
return State.getRegisterID() == X86::RSP;
|
|
});
|
|
assert(
|
|
StackRegisterDef != Inst.getDefs().end() &&
|
|
"Expected push instruction to implicitly use stack pointer register.");
|
|
Inst.getDefs().erase(StackRegisterDef);
|
|
}
|
|
}
|
|
|
|
void X86InstrPostProcess::postProcessInstruction(Instruction &Inst,
|
|
const MCInst &MCI) {
|
|
// Set IsALoadBarrier and IsAStoreBarrier flags.
|
|
setMemBarriers(Inst, MCI);
|
|
useStackEngine(Inst, MCI);
|
|
}
|
|
|
|
} // namespace mca
|
|
} // namespace llvm
|
|
|
|
using namespace llvm;
|
|
using namespace mca;
|
|
|
|
static InstrPostProcess *createX86InstrPostProcess(const MCSubtargetInfo &STI,
|
|
const MCInstrInfo &MCII) {
|
|
return new X86InstrPostProcess(STI, MCII);
|
|
}
|
|
|
|
/// Extern function to initialize the targets for the X86 backend
|
|
|
|
extern "C" LLVM_C_ABI void LLVMInitializeX86TargetMCA() {
|
|
TargetRegistry::RegisterInstrPostProcess(getTheX86_32Target(),
|
|
createX86InstrPostProcess);
|
|
TargetRegistry::RegisterInstrPostProcess(getTheX86_64Target(),
|
|
createX86InstrPostProcess);
|
|
}
|