LLVM 20.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
17#include <cstdint>
18#include <optional>
19
20namespace llvm {
21
22class AtomicMemCpyInst;
23class ConstantInt;
24class Instruction;
25class MemCpyInst;
26class MemMoveInst;
27class MemSetInst;
28class MemSetPatternInst;
29class ScalarEvolution;
30class TargetTransformInfo;
31class Value;
32struct Align;
33
34/// Emit a loop implementing the semantics of llvm.memcpy where the size is not
35/// a compile-time constant. Loop will be insterted at \p InsertBefore.
37 Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, Value *CopyLen,
38 Align SrcAlign, Align DestAlign, bool SrcIsVolatile, bool DstIsVolatile,
39 bool CanOverlap, const TargetTransformInfo &TTI,
40 std::optional<unsigned> AtomicSize = std::nullopt);
41
42/// Emit a loop implementing the semantics of an llvm.memcpy whose size is a
43/// compile time constant. Loop is inserted at \p InsertBefore.
45 Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr,
46 ConstantInt *CopyLen, Align SrcAlign, Align DestAlign, bool SrcIsVolatile,
47 bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI,
48 std::optional<uint32_t> AtomicCpySize = std::nullopt);
49
50/// Expand \p MemCpy as a loop. \p MemCpy is not deleted.
52 ScalarEvolution *SE = nullptr);
53
54/// Expand \p MemMove as a loop. \p MemMove is not deleted. Returns true if the
55/// memmove was lowered.
57
58/// Expand \p MemSet as a loop. \p MemSet is not deleted.
59void expandMemSetAsLoop(MemSetInst *MemSet);
60
61/// Expand \p MemSetPattern as a loop. \p MemSet is not deleted.
63
64/// Expand \p AtomicMemCpy as a loop. \p AtomicMemCpy is not deleted.
67 ScalarEvolution *SE);
68
69} // End llvm namespace
70
71#endif
uint64_t Align
This class represents the atomic memcpy intrinsic i.e.
This is the shared class of boolean and integer constants.
Definition: Constants.h:83
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:74
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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.
void expandMemSetPatternAsLoop(MemSetPatternInst *MemSet)
Expand MemSetPattern as a loop. MemSet is not deleted.
bool expandMemMoveAsLoop(MemMoveInst *MemMove, const TargetTransformInfo &TTI)
Expand MemMove as a loop.
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.
void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI, ScalarEvolution *SE=nullptr)
Expand MemCpy as a loop. MemCpy is not deleted.
void expandAtomicMemCpyAsLoop(AtomicMemCpyInst *AtomicMemCpy, const TargetTransformInfo &TTI, ScalarEvolution *SE)
Expand AtomicMemCpy as a loop. AtomicMemCpy is not deleted.
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