Go to the documentation of this file.
13 #ifndef LLVM_SUPPORT_MEMORYBUFFER_H
14 #define LLVM_SUPPORT_MEMORYBUFFER_H
52 const char *BufferStart;
53 const char *BufferEnd;
58 void init(
const char *BufStart,
const char *BufEnd,
59 bool RequiresNullTerminator);
99 bool RequiresNullTerminator =
true,
bool IsVolatile =
false,
100 std::optional<Align> Alignment = std::nullopt);
113 int64_t
Offset,
bool IsVolatile =
false,
114 std::optional<Align> Alignment = std::nullopt);
127 bool RequiresNullTerminator =
true,
bool IsVolatile =
false,
128 std::optional<Align> Alignment = std::nullopt);
132 static std::unique_ptr<MemoryBuffer>
134 bool RequiresNullTerminator =
true);
136 static std::unique_ptr<MemoryBuffer>
141 static std::unique_ptr<MemoryBuffer>
151 bool RequiresNullTerminator =
true,
152 std::optional<Align> Alignment = std::nullopt);
157 bool IsVolatile =
false,
158 std::optional<Align> Alignment = std::nullopt);
204 std::optional<Align> Alignment = std::nullopt);
209 bool IsVolatile =
false,
210 std::optional<Align> Alignment = std::nullopt);
218 static std::unique_ptr<WritableMemoryBuffer>
220 std::optional<Align> Alignment = std::nullopt);
225 static std::unique_ptr<WritableMemoryBuffer>
291 #endif // LLVM_SUPPORT_MEMORYBUFFER_H
This is an optimization pass for GlobalISel generic memory operations.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
static ErrorOr< std::unique_ptr< MemoryBuffer > > getSTDIN()
Read all of stdin into a file buffer, and return it.
This class is an extension of MemoryBuffer, which allows write access to the underlying contents and ...
static std::unique_ptr< WritableMemoryBuffer > getNewUninitMemBuffer(size_t Size, const Twine &BufferName="", std::optional< Align > Alignment=std::nullopt)
Allocate a new MemoryBuffer of the specified size that is not initialized.
virtual void dontNeedIfMmap()
For read-only MemoryBuffer_MMap, mark the buffer as unused in the near future and the kernel can free...
This interface provides simple read-only access to a block of memory, and provides simple methods for...
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileAsStream(const Twine &Filename)
Read all of the specified file into a MemoryBuffer as a stream (i.e.
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
void init(const char *BufStart, const char *BufEnd, bool RequiresNullTerminator)
init - Initialize this MemoryBuffer as a reference to externally allocated memory,...
const char * getBufferEnd() const
size_t getBufferSize() const
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
static std::unique_ptr< WritableMemoryBuffer > getNewMemBuffer(size_t Size, const Twine &BufferName="")
Allocate a new zero-initialized MemoryBuffer of the specified size.
StringRef getBuffer() const
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFileSlice(sys::fs::file_t FD, const Twine &Filename, uint64_t MapSize, int64_t Offset, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Given an already-open file descriptor, map some slice of it into a MemoryBuffer.
MemoryBuffer & operator=(const MemoryBuffer &)=delete
MemoryBufferRef getMemBufferRef() const
BufferKind
The kind of memory backing used to support the MemoryBuffer.
WriteThroughMemoryBuffer()=default
MutableArrayRef< char > getBuffer()
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
StringRef - Represent a constant reference to a string, i.e.
WritableMemoryBuffer()=default
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const char * getBufferStart() const
static ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Map a subrange of the specified file as a WritableMemoryBuffer.
static ErrorOr< std::unique_ptr< WriteThroughMemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset)
Map a subrange of the specified file as a ReadWriteMemoryBuffer.
Represents either an error or a value T.
MutableArrayRef< char > getBuffer()
static ErrorOr< std::unique_ptr< WriteThroughMemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1)
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
This class is an extension of MemoryBuffer, which allows copy-on-write access to the underlying conte...
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
static ErrorOr< std::unique_ptr< WritableMemoryBuffer > > getFile(const Twine &Filename, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Map a subrange of the specified file as a MemoryBuffer.
virtual BufferKind getBufferKind() const =0
Return information on the memory mechanism used to support the MemoryBuffer.