LowerMemIntrinsics.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Transforms/Utils/LowerMemIntrinsics.h ---------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // Lower memset, memcpy, memmov intrinsics to loops (e.g. for targets without
  15. // library support).
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TRANSFORMS_UTILS_LOWERMEMINTRINSICS_H
  19. #define LLVM_TRANSFORMS_UTILS_LOWERMEMINTRINSICS_H
  20. #include <cstdint>
  21. #include <optional>
  22. namespace llvm {
  23. class AtomicMemCpyInst;
  24. class ConstantInt;
  25. class Instruction;
  26. class MemCpyInst;
  27. class MemMoveInst;
  28. class MemSetInst;
  29. class ScalarEvolution;
  30. class TargetTransformInfo;
  31. class Value;
  32. struct Align;
  33. /// Emit a loop implementing the semantics of llvm.memcpy where the size is not
  34. /// a compile-time constant. Loop will be insterted at \p InsertBefore.
  35. void createMemCpyLoopUnknownSize(
  36. Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, Value *CopyLen,
  37. Align SrcAlign, Align DestAlign, bool SrcIsVolatile, bool DstIsVolatile,
  38. bool CanOverlap, const TargetTransformInfo &TTI,
  39. std::optional<unsigned> AtomicSize = std::nullopt);
  40. /// Emit a loop implementing the semantics of an llvm.memcpy whose size is a
  41. /// compile time constant. Loop is inserted at \p InsertBefore.
  42. void createMemCpyLoopKnownSize(
  43. Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr,
  44. ConstantInt *CopyLen, Align SrcAlign, Align DestAlign, bool SrcIsVolatile,
  45. bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI,
  46. std::optional<uint32_t> AtomicCpySize = std::nullopt);
  47. /// Expand \p MemCpy as a loop. \p MemCpy is not deleted.
  48. void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI,
  49. ScalarEvolution *SE = nullptr);
  50. /// Expand \p MemMove as a loop. \p MemMove is not deleted.
  51. void expandMemMoveAsLoop(MemMoveInst *MemMove);
  52. /// Expand \p MemSet as a loop. \p MemSet is not deleted.
  53. void expandMemSetAsLoop(MemSetInst *MemSet);
  54. /// Expand \p AtomicMemCpy as a loop. \p AtomicMemCpy is not deleted.
  55. void expandAtomicMemCpyAsLoop(AtomicMemCpyInst *AtomicMemCpy,
  56. const TargetTransformInfo &TTI,
  57. ScalarEvolution *SE);
  58. } // End llvm namespace
  59. #endif
  60. #ifdef __GNUC__
  61. #pragma GCC diagnostic pop
  62. #endif