<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">More stylistic nitpicking for consistency sakes...<div><br class="webkit-block-placeholder"></div><div>1. __LTO__ -> LLVM_C_LTO</div><div>2. Do we need those #include's?</div><div>3. Rather than using underscore in function names, e.g. lt_foo_bar, use capital letters and also start with prefix LLVM. e.g. LLVMLTOFooBar.</div><div>4. <span class="Apple-style-span" style="font-family: Monaco; font-size: 9px; ">lto_codegen_release -> lto_codegen_release_memory to be clearer and more consistent.</span></div><div>5. Use C comments /* ... */?</div><div>6. Please start comments with capital letters and end sentences with periods! Or perhaps not since it'll drive Chris nuts. :-)</div><div><br class="webkit-block-placeholder"></div><div>Evan</div><div><br><div><div>On Feb 22, 2008, at 10:34 PM, Nick Kledzik wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "> <div>Hello. I work at Apple on our linker. We are working to improve support for llvm </div><div>in our tools. A while back Devang created <llvm/LinkTimeOptimizer.h> a C++ </div><div>interface which allows the linker to process llvm bitcode files along with native</div><div>mach-o object files. </div><div><br class="webkit-block-placeholder"></div><div>For the next step we'd like our other tools like nm, ar, and lipo to be able to </div><div>transparently process bitcode files too. But those tools are all written in C. So, I've </div><div>reworked the LTO interface as a C interfaces and broke out the steps so that it </div><div>could be used by other (non-linker) tools. </div><div><br class="webkit-block-placeholder"></div><div>Below is the proposed interface. The project (llvm/tools/lto2 for now) will build</div><div>a shared object that can be used by other tools. </div><div><div><br class="webkit-block-placeholder"></div><div>I'd be interested to know if any one else has use for this. </div><div><br class="webkit-block-placeholder"></div><div>One area we know we need to augment the API is to allow various optimizations </div><div>to be selected on the linker command line.</div><div><br class="webkit-block-placeholder"></div><div>-Nick</div><div><br></div><div><br class="webkit-block-placeholder"></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//===-- llvm-c/lto.h - LTO Public C Interface -------------------*- C++ -*-===//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// The LLVM Compiler Infrastructure</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// This file is distributed under the University of Illinois Open Source</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// License. See LICENSE.TXT for details.</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//===----------------------------------------------------------------------===//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// This header provides public interface to an abstract link time optimization</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// library. LLVM provides an implementation of this interface for use with</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// llvm bitcode files. </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//===----------------------------------------------------------------------===//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#ifndef __LTO__H__</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#define __LTO__H__</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#include <stdint.h></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#include <stdbool.h></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#include <stddef.h></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">typedef enum {</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_PERMISSIONS_MASK = 0x000000E0, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_PERMISSIONS_CODE = 0x000000A0, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_PERMISSIONS_DATA = 0x000000C0, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_PERMISSIONS_RODATA = 0x00000080, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_DEFINITION_MASK = 0x00000700, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_DEFINITION_REGULAR = 0x00000100, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_DEFINITION_WEAK = 0x00000300, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_SCOPE_MASK = 0x00001800, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_SYMBOL_SCOPE_DEFAULT = 0x00001800 </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">} lto_symbol_attributes;</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">typedef enum {</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_DEBUG_MODEL_NONE = 0,</span></font></div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 9px; "> LTO_DEBUG_MODEL_DWARF = 1</span></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">} lto_debug_model;</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">typedef enum {</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_CODEGEN_PIC_MODEL_STATIC = 0,</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1,</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">} lto_codegen_model;</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// opaque reference to a loaded object module</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">typedef struct LTOModule* lto_module_t;</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// opaque reference to a code generator</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">typedef struct LTOCodeGenerator* lto_code_gen_t;</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#ifdef __cplusplus</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern "C" {</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#endif</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns a printable string</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern const char*</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_get_version();</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns the last error string or NULL if last operation was sucessful</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern const char*</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_get_error_message();</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// validates if a file is a loadable object file</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern bool</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_is_object_file(const char* path);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// validates if a file is a loadable object file compilable for requested target</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern bool</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_is_object_file_for_target(const char* path, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> const char* target_triplet_prefix);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// validates if a buffer is a loadable object file</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern bool</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_is_object_file_in_memory(const uint8_t* mem, size_t length);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// validates if a buffer is a loadable object file compilable for requested target</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern bool</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_is_object_file_in_memory_for_target(const uint8_t* mem, size_t length, </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"> const char* target_triplet_prefix);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// loads an object file from disk </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns NULL on error (check lto_get_error_message() for details)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern lto_module_t</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_create(const char* path);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// loads an object file from memory </span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns NULL on error (check lto_get_error_message() for details)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern lto_module_t</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_create_from_memory(const uint8_t* mem, size_t length);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// frees all memory for a module</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// upon return the lto_module_t is no longer valid</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern void</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_release(lto_module_t mod);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns triplet string which the object module was compiled under</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern const char*</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_get_target_triplet(lto_module_t mod);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns the number of symbols in the object module</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern uint32_t</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_get_num_symbols(lto_module_t mod);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns the name of the ith symbol in the object module</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern const char*</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_get_symbol_name(lto_module_t mod, uint32_t index);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns the attributes of the ith symbol in the object module</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern lto_symbol_attributes</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_module_get_symbol_attribute(lto_module_t mod, uint32_t index);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// instantiates a code generator</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns NULL if there is an error</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern lto_code_gen_t</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_codegen_create();</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// frees all memory for a code generator</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// upon return the lto_code_gen_t is no longer valid</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern void</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_codegen_release(lto_code_gen_t);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// add an object module to the set of modules for which code will be generated</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns true on error (check lto_get_error_message() for details)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern bool</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// sets what if any format of debug info should be generated</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns true on error (check lto_get_error_message() for details)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern bool</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// sets what code model to generated</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns true on error (check lto_get_error_message() for details)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern bool</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// adds to a list of all global symbols that must exist in the final</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// generated code. If a function is not listed there, it might be</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// inlined into every usage and optimized away.</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern void</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// writes a new file at the specified path that contains the</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// merged contents of all modules added so far.</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// returns true on error (check lto_get_error_message() for details)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern bool</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// generates code for all added modules into one object file</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// On sucess returns a pointer to a generated mach-o buffer and</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// length set to the buffer size. Client must free() the buffer</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// when done.</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">// On failure, returns NULL (check lto_get_error_message() for details)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">//</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">extern const uint8_t*</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">lto_codegen_compile(lto_code_gen_t cg, size_t* length);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#ifdef __cplusplus</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">}</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#endif</span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="1"><span class="Apple-style-span" style="font-size: 9px;">#endif</span></font></div><div><br class="webkit-block-placeholder"></div></div></div>_______________________________________________<br>LLVM Developers mailing list<br>LLVMdev@cs.uiuc.edu <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></body></html>