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 "llvm/ADT/Optional.h" 18 19 namespace llvm { 20 21 class AtomicMemCpyInst; 22 class ConstantInt; 23 class Instruction; 24 class MemCpyInst; 25 class MemMoveInst; 26 class MemSetInst; 27 class ScalarEvolution; 28 class TargetTransformInfo; 29 class Value; 30 struct Align; 31 32 /// Emit a loop implementing the semantics of llvm.memcpy where the size is not 33 /// a compile-time constant. Loop will be insterted at \p InsertBefore. 34 void createMemCpyLoopUnknownSize(Instruction *InsertBefore, Value *SrcAddr, 35 Value *DstAddr, Value *CopyLen, Align SrcAlign, 36 Align DestAlign, bool SrcIsVolatile, 37 bool DstIsVolatile, bool CanOverlap, 38 const TargetTransformInfo &TTI, 39 Optional<unsigned> AtomicSize = None); 40 41 /// Emit a loop implementing the semantics of an llvm.memcpy whose size is a 42 /// compile time constant. Loop is inserted at \p InsertBefore. 43 void createMemCpyLoopKnownSize(Instruction *InsertBefore, Value *SrcAddr, 44 Value *DstAddr, ConstantInt *CopyLen, 45 Align SrcAlign, Align DestAlign, 46 bool SrcIsVolatile, bool DstIsVolatile, 47 bool CanOverlap, const TargetTransformInfo &TTI, 48 Optional<uint32_t> AtomicCpySize = None); 49 50 /// Expand \p MemCpy as a loop. \p MemCpy is not deleted. 51 void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI, 52 ScalarEvolution *SE = nullptr); 53 54 /// Expand \p MemMove as a loop. \p MemMove is not deleted. 55 void expandMemMoveAsLoop(MemMoveInst *MemMove); 56 57 /// Expand \p MemSet as a loop. \p MemSet is not deleted. 58 void expandMemSetAsLoop(MemSetInst *MemSet); 59 60 /// Expand \p AtomicMemCpy as a loop. \p AtomicMemCpy is not deleted. 61 void expandAtomicMemCpyAsLoop(AtomicMemCpyInst *AtomicMemCpy, 62 const TargetTransformInfo &TTI, 63 ScalarEvolution *SE); 64 65 } // End llvm namespace 66 67 #endif 68