LLVM  14.0.0git
BitWriter.cpp
Go to the documentation of this file.
1 //===-- BitWriter.cpp -----------------------------------------------------===//
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 #include "llvm-c/BitWriter.h"
11 #include "llvm/IR/Module.h"
15 using namespace llvm;
16 
17 
18 /*===-- Operations on modules ---------------------------------------------===*/
19 
20 int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path) {
21  std::error_code EC;
22  raw_fd_ostream OS(Path, EC, sys::fs::OF_None);
23 
24  if (EC)
25  return -1;
26 
28  return 0;
29 }
30 
31 int LLVMWriteBitcodeToFD(LLVMModuleRef M, int FD, int ShouldClose,
32  int Unbuffered) {
33  raw_fd_ostream OS(FD, ShouldClose, Unbuffered);
34 
36  return 0;
37 }
38 
40  return LLVMWriteBitcodeToFD(M, FileHandle, true, false);
41 }
42 
44  std::string Data;
46 
48  return wrap(MemoryBuffer::getMemBufferCopy(OS.str()).release());
49 }
MemoryBuffer.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
FileSystem.h
llvm::sys::fs::OF_None
@ OF_None
Definition: FileSystem.h:757
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:625
Module.h
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
BitWriter.h
LLVMWriteBitcodeToMemoryBuffer
LLVMMemoryBufferRef LLVMWriteBitcodeToMemoryBuffer(LLVMModuleRef M)
Writes a module to a new memory buffer and returns it.
Definition: BitWriter.cpp:43
BitcodeWriter.h
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:256
LLVMWriteBitcodeToFile
int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path)
Writes a module to the specified path.
Definition: BitWriter.cpp:20
LLVMWriteBitcodeToFD
int LLVMWriteBitcodeToFD(LLVMModuleRef M, int FD, int ShouldClose, int Unbuffered)
Writes a module to an open file descriptor.
Definition: BitWriter.cpp:31
llvm::WriteBitcodeToFile
void WriteBitcodeToFile(const Module &M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the specified raw output stream.
Definition: BitcodeWriter.cpp:4639
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:251
llvm::raw_fd_ostream
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:443
LLVMMemoryBufferRef
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
Definition: Types.h:48
raw_ostream.h
llvm::MemoryBuffer::getMemBufferCopy
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.
Definition: MemoryBuffer.cpp:136
LLVMWriteBitcodeToFileHandle
int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int FileHandle)
Deprecated for LLVMWriteBitcodeToFD.
Definition: BitWriter.cpp:39
llvm::raw_string_ostream::str
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
Definition: raw_ostream.h:643
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61