xref: /freebsd-src/contrib/llvm-project/llvm/include/llvm/Transforms/Utils/LowerAtomic.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
181ad6265SDimitry Andric //===- LowerAtomic.h - Lower atomic intrinsics ------------------*- C++ -*-===//
281ad6265SDimitry Andric //
381ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
481ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
581ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
681ad6265SDimitry Andric //
781ad6265SDimitry Andric //===----------------------------------------------------------------------===//
881ad6265SDimitry Andric /// \file
981ad6265SDimitry Andric // This pass lowers atomic intrinsics to non-atomic form for use in a known
1081ad6265SDimitry Andric // non-preemptible environment.
1181ad6265SDimitry Andric ///
1281ad6265SDimitry Andric //===----------------------------------------------------------------------===//
1381ad6265SDimitry Andric 
14fcaf7f86SDimitry Andric #ifndef LLVM_TRANSFORMS_UTILS_LOWERATOMIC_H
15fcaf7f86SDimitry Andric #define LLVM_TRANSFORMS_UTILS_LOWERATOMIC_H
1681ad6265SDimitry Andric 
1781ad6265SDimitry Andric #include "llvm/IR/Instructions.h"
1881ad6265SDimitry Andric 
1981ad6265SDimitry Andric namespace llvm {
2081ad6265SDimitry Andric 
2181ad6265SDimitry Andric class IRBuilderBase;
2281ad6265SDimitry Andric 
2381ad6265SDimitry Andric /// Convert the given Cmpxchg into primitive load and compare.
2481ad6265SDimitry Andric bool lowerAtomicCmpXchgInst(AtomicCmpXchgInst *CXI);
2581ad6265SDimitry Andric 
2681ad6265SDimitry Andric /// Convert the given RMWI into primitive load and stores,
2781ad6265SDimitry Andric /// assuming that doing so is legal. Return true if the lowering
2881ad6265SDimitry Andric /// succeeds.
2981ad6265SDimitry Andric bool lowerAtomicRMWInst(AtomicRMWInst *RMWI);
3081ad6265SDimitry Andric 
3181ad6265SDimitry Andric /// Emit IR to implement the given atomicrmw operation on values in registers,
3281ad6265SDimitry Andric /// returning the new value.
3381ad6265SDimitry Andric Value *buildAtomicRMWValue(AtomicRMWInst::BinOp Op, IRBuilderBase &Builder,
34*bdd1243dSDimitry Andric                            Value *Loaded, Value *Val);
3581ad6265SDimitry Andric }
3681ad6265SDimitry Andric 
37fcaf7f86SDimitry Andric #endif // LLVM_TRANSFORMS_UTILS_LOWERATOMIC_H
38