LLVM 22.0.0git
LowerMemIntrinsics.h
Go to the documentation of this file.
1//===- llvm/Transforms/Utils/LowerMemIntrinsics.h ---------------*- 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//
9// Lower memset, memcpy, memmov intrinsics to loops (e.g. for targets without
10// library support).
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TRANSFORMS_UTILS_LOWERMEMINTRINSICS_H
15#define LLVM_TRANSFORMS_UTILS_LOWERMEMINTRINSICS_H
16
18#include <cstdint>
19#include <optional>
20
21namespace llvm {
22
23class AnyMemCpyInst;
24class ConstantInt;
25class Instruction;
26class MemCpyInst;
27class MemMoveInst;
28class MemSetInst;
29class MemSetPatternInst;
30class ScalarEvolution;
31class TargetTransformInfo;
32class Value;
33struct Align;
34
35/// Emit a loop implementing the semantics of llvm.memcpy where the size is not
36/// a compile-time constant. Loop will be inserted at \p InsertBefore.
38 Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, Value *CopyLen,
39 Align SrcAlign, Align DestAlign, bool SrcIsVolatile, bool DstIsVolatile,
40 bool CanOverlap, const TargetTransformInfo &TTI,
41 std::optional<unsigned> AtomicSize = std::nullopt);
42
43/// Emit a loop implementing the semantics of an llvm.memcpy whose size is a
44/// compile time constant. Loop is inserted at \p InsertBefore.
46 Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr,
47 ConstantInt *CopyLen, Align SrcAlign, Align DestAlign, bool SrcIsVolatile,
48 bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI,
49 std::optional<uint32_t> AtomicCpySize = std::nullopt);
50
51/// Expand \p MemCpy as a loop. \p MemCpy is not deleted.
54 ScalarEvolution *SE = nullptr);
55
56/// Expand \p MemMove as a loop. \p MemMove is not deleted. Returns true if the
57/// memmove was lowered.
60
61/// Expand \p MemSet as a loop. \p MemSet is not deleted.
63
64/// Expand \p MemSetPattern as a loop. \p MemSet is not deleted.
66
67/// Expand \p AtomicMemCpy as a loop. \p AtomicMemCpy is not deleted.
70 ScalarEvolution *SE);
71
72} // namespace llvm
73
74#endif
#define LLVM_ABI
Definition: Compiler.h:213
uint64_t Align
This class represents any memcpy intrinsic i.e.
This is the shared class of boolean and integer constants.
Definition: Constants.h:87
This class wraps the llvm.memcpy intrinsic.
This class wraps the llvm.memmove intrinsic.
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
This class wraps the llvm.experimental.memset.pattern intrinsic.
The main scalar evolution driver.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
LLVM Value Representation.
Definition: Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
LLVM_ABI void createMemCpyLoopKnownSize(Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, ConstantInt *CopyLen, Align SrcAlign, Align DestAlign, bool SrcIsVolatile, bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI, std::optional< uint32_t > AtomicCpySize=std::nullopt)
Emit a loop implementing the semantics of an llvm.memcpy whose size is a compile time constant.
LLVM_ABI void expandMemSetPatternAsLoop(MemSetPatternInst *MemSet)
Expand MemSetPattern as a loop. MemSet is not deleted.
LLVM_ABI bool expandMemMoveAsLoop(MemMoveInst *MemMove, const TargetTransformInfo &TTI)
Expand MemMove as a loop.
LLVM_ABI void createMemCpyLoopUnknownSize(Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, Value *CopyLen, Align SrcAlign, Align DestAlign, bool SrcIsVolatile, bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI, std::optional< unsigned > AtomicSize=std::nullopt)
Emit a loop implementing the semantics of llvm.memcpy where the size is not a compile-time constant.
LLVM_ABI void expandAtomicMemCpyAsLoop(AnyMemCpyInst *AtomicMemCpy, const TargetTransformInfo &TTI, ScalarEvolution *SE)
Expand AtomicMemCpy as a loop. AtomicMemCpy is not deleted.
LLVM_ABI void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI, ScalarEvolution *SE=nullptr)
Expand MemCpy as a loop. MemCpy is not deleted.
LLVM_ABI void expandMemSetAsLoop(MemSetInst *MemSet)
Expand MemSet as a loop. MemSet is not deleted.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39