mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Introduce llvm-c function LLVMPrintModuleToFile.
This lets you save the textual representation of the LLVM IR to a file. Before this patch it could only be printed to STDERR from llvm-c. Patch by Carlo Kok! llvm-svn: 156479
This commit is contained in:
parent
e8880a9916
commit
879332e389
@ -477,6 +477,15 @@ void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
|
|||||||
*/
|
*/
|
||||||
void LLVMDumpModule(LLVMModuleRef M);
|
void LLVMDumpModule(LLVMModuleRef M);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a representation of a module to a file. The ErrorMessage needs to be
|
||||||
|
* disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
|
||||||
|
*
|
||||||
|
* @see Module::print()
|
||||||
|
*/
|
||||||
|
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
|
||||||
|
char **ErrorMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set inline assembly for a module.
|
* Set inline assembly for a module.
|
||||||
*
|
*
|
||||||
|
@ -115,6 +115,25 @@ void LLVMDumpModule(LLVMModuleRef M) {
|
|||||||
unwrap(M)->dump();
|
unwrap(M)->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
|
||||||
|
char **ErrorMessage) {
|
||||||
|
std::string error;
|
||||||
|
raw_fd_ostream dest(Filename, error);
|
||||||
|
if (!error.empty()) {
|
||||||
|
*ErrorMessage = strdup(error.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unwrap(M)->print(dest, NULL);
|
||||||
|
|
||||||
|
if (!error.empty()) {
|
||||||
|
*ErrorMessage = strdup(error.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
dest.flush();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*--.. Operations on inline assembler ......................................--*/
|
/*--.. Operations on inline assembler ......................................--*/
|
||||||
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm) {
|
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm) {
|
||||||
unwrap(M)->setModuleInlineAsm(StringRef(Asm));
|
unwrap(M)->setModuleInlineAsm(StringRef(Asm));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user