LLVM 24.0.0git
LoongArchMemoryBarrierOpt.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "loongarch-memory-barrier-opt"
#define LOONGARCH_MEMORY_BARRIER_OPT_NAME    "LoongArch Memory Barrier Optimisation pass"
#define AMO_CASES
#define CASE(Name, Suffix)

Functions

static bool checkAllPathSafe (const MachineBasicBlock *MBBA, const MachineBasicBlock *MBBB, bool IsAToB)
static unsigned resolveBarrierRedundancy (const MachineInstr *A, const MachineInstr *B, const MachineDominatorTree *MDT, const MachinePostDominatorTree *MPDT)
static void updateMB (InstBarrier &I, BarrierHint Hint)
static void replaceAM (InstBarrier &I, MachineFunction &MF)
static bool eliminateRedundantBarrier (InstBarrier &IA, InstBarrier &IB, MachineFunction &MF, const MachineDominatorTree *MDT, const MachinePostDominatorTree *MPDT)
static bool runMemoryBarrierOpt (MachineFunction &MF, const MachineDominatorTree *MDT, const MachinePostDominatorTree *MPDT)
 INITIALIZE_PASS_BEGIN (LoongArchMemoryBarrierOptLegacy, DEBUG_TYPE, LOONGARCH_MEMORY_BARRIER_OPT_NAME, false, false) INITIALIZE_PASS_END(LoongArchMemoryBarrierOptLegacy

Variables

static cl::opt< bool > RequireNoPathBypass ("loongarch-require-no-path-bypass", cl::desc("Optimize only when no paths bypass either memory barrier"), cl::init(true), cl::Hidden)
static cl::opt< bool > MergeAMOWithMB ("loongarch-merge-amo-with-dbar", cl::desc("Merge AMOs with DBARs into AMO_DB during optimization"), cl::init(true), cl::Hidden)
static cl::opt< bool > ReplaceEliminatedMBToNop ("loongarch-replace-eliminated-dbar-to-nop", cl::desc("Replace eliminated DBARs with NOPs to preserve code layout"), cl::init(false), cl::Hidden)
 DEBUG_TYPE
 LOONGARCH_MEMORY_BARRIER_OPT_NAME
 false

Macro Definition Documentation

◆ AMO_CASES

#define AMO_CASES
Value:
CASE(AMSWAP, B) \
CASE(AMSWAP, H) \
CASE(AMSWAP, W) \
CASE(AMSWAP, D) \
CASE(AMADD, B) \
CASE(AMADD, H) \
CASE(AMADD, W) \
CASE(AMADD, D) \
CASE(AMAND, W) \
CASE(AMAND, D) \
CASE(AMOR, W) \
CASE(AMOR, D) \
CASE(AMXOR, W) \
CASE(AMXOR, D) \
CASE(AMMAX, W) \
CASE(AMMAX, D) \
CASE(AMMAX, WU) \
CASE(AMMAX, DU) \
CASE(AMMIN, W) \
CASE(AMMIN, D) \
CASE(AMMIN, WU) \
CASE(AMMIN, DU) \
CASE(AMCAS, B) \
CASE(AMCAS, H) \
CASE(AMCAS, W) \
CASE(AMCAS, D)
#define CASE(ATTRNAME, AANAME,...)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define H(x, y, z)
Definition MD5.cpp:56

Definition at line 53 of file LoongArchMemoryBarrierOpt.cpp.

◆ CASE

#define CASE ( Name,
Suffix )
Value:
case LoongArch::Name##_##Suffix: \
return std::nullopt; \
[[fallthrough]]; \
case LoongArch::Name##__DB_##Suffix: \
return LoongArch::Name##__DB_##Suffix;
#define _
static cl::opt< bool > MergeAMOWithMB("loongarch-merge-amo-with-dbar", cl::desc("Merge AMOs with DBARs into AMO_DB during optimization"), cl::init(true), cl::Hidden)

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loongarch-memory-barrier-opt"

Definition at line 32 of file LoongArchMemoryBarrierOpt.cpp.

◆ LOONGARCH_MEMORY_BARRIER_OPT_NAME

#define LOONGARCH_MEMORY_BARRIER_OPT_NAME    "LoongArch Memory Barrier Optimisation pass"

Definition at line 33 of file LoongArchMemoryBarrierOpt.cpp.

Referenced by INITIALIZE_PASS_BEGIN().

Function Documentation

◆ checkAllPathSafe()

◆ eliminateRedundantBarrier()

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( LoongArchMemoryBarrierOptLegacy ,
DEBUG_TYPE ,
LOONGARCH_MEMORY_BARRIER_OPT_NAME ,
false ,
false  )

◆ replaceAM()

void replaceAM ( InstBarrier & I,
MachineFunction & MF )
static

Definition at line 305 of file LoongArchMemoryBarrierOpt.cpp.

References llvm::MachineFunction::getSubtarget(), and I.

Referenced by eliminateRedundantBarrier().

◆ resolveBarrierRedundancy()

◆ runMemoryBarrierOpt()

◆ updateMB()

void updateMB ( InstBarrier & I,
BarrierHint Hint )
static

Definition at line 298 of file LoongArchMemoryBarrierOpt.cpp.

References assert(), and I.

Referenced by eliminateRedundantBarrier().

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 417 of file LoongArchMemoryBarrierOpt.cpp.

◆ false

false

Definition at line 418 of file LoongArchMemoryBarrierOpt.cpp.

◆ LOONGARCH_MEMORY_BARRIER_OPT_NAME

LOONGARCH_MEMORY_BARRIER_OPT_NAME

Definition at line 418 of file LoongArchMemoryBarrierOpt.cpp.

◆ MergeAMOWithMB

cl::opt< bool > MergeAMOWithMB("loongarch-merge-amo-with-dbar", cl::desc("Merge AMOs with DBARs into AMO_DB during optimization"), cl::init(true), cl::Hidden) ( "loongarch-merge-amo-with-dbar" ,
cl::desc("Merge AMOs with DBARs into AMO_DB during optimization") ,
cl::init(true) ,
cl::Hidden  )
static

◆ ReplaceEliminatedMBToNop

cl::opt< bool > ReplaceEliminatedMBToNop("loongarch-replace-eliminated-dbar-to-nop", cl::desc("Replace eliminated DBARs with NOPs to preserve code layout"), cl::init(false), cl::Hidden) ( "loongarch-replace-eliminated-dbar-to-nop" ,
cl::desc("Replace eliminated DBARs with NOPs to preserve code layout") ,
cl::init(false) ,
cl::Hidden  )
static

◆ RequireNoPathBypass

cl::opt< bool > RequireNoPathBypass("loongarch-require-no-path-bypass", cl::desc("Optimize only when no paths bypass either memory barrier"), cl::init(true), cl::Hidden) ( "loongarch-require-no-path-bypass" ,
cl::desc("Optimize only when no paths bypass either memory barrier") ,
cl::init(true) ,
cl::Hidden  )
static