lto.h revision 7afea0cfc4abebaf4cadcc37acd30fb251a5faf3
177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/*===-- llvm-c/lto.h - LTO Public C Interface ---------------------*- C -*-===*\ 277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* *| 377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* The LLVM Compiler Infrastructure *| 477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* *| 577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* This file is distributed under the University of Illinois Open Source *| 677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* License. See LICENSE.TXT for details. *| 777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* *| 877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|*===----------------------------------------------------------------------===*| 977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* *| 1077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* This header provides public interface to an abstract link time optimization*| 1177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* library. LLVM provides an implementation of this interface for use with *| 1277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* llvm bitcode files. *| 1377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik|* *| 1477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik\*===----------------------------------------------------------------------===*/ 1577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 1677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#ifndef LTO_H 1777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#define LTO_H 1 1877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 1977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#include <stdbool.h> 2077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#include <stddef.h> 21767b5b6227a49cac98c275ab05f1560da0fe90beDevang Patel#include "llvm/System/DataTypes.h" 2277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 237afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling#define LTO_API_VERSION 4 24cbad58624090933cb8fb85587e03be613a481309Nick Kledzik 2577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef enum { 267afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */ 277afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_PERMISSIONS_MASK = 0x000000E0, 287afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_PERMISSIONS_CODE = 0x000000A0, 297afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_PERMISSIONS_DATA = 0x000000C0, 307afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_PERMISSIONS_RODATA = 0x00000080, 317afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_DEFINITION_MASK = 0x00000700, 327afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_DEFINITION_REGULAR = 0x00000100, 337afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200, 347afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_DEFINITION_WEAK = 0x00000300, 357afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400, 367afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_DEFINITION_WEAKUNDEF = 0x00000500, 377afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_SCOPE_MASK = 0x00003800, 387afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800, 397afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000, 407afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_SCOPE_PROTECTED = 0x00002000, 417afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_SCOPE_DEFAULT = 0x00001800, 427afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800 4377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik} lto_symbol_attributes; 4477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 4577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef enum { 4677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_DEBUG_MODEL_NONE = 0, 4777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_DEBUG_MODEL_DWARF = 1 4877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik} lto_debug_model; 4977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 5077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef enum { 5177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_CODEGEN_PIC_MODEL_STATIC = 0, 5277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1, 5377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2 5477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik} lto_codegen_model; 5577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 5677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 5777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** opaque reference to a loaded object module */ 5877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef struct LTOModule* lto_module_t; 5977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 6077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** opaque reference to a code generator */ 6177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef struct LTOCodeGenerator* lto_code_gen_t; 6277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 6377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#ifdef __cplusplus 6477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern "C" { 6577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#endif 6677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 6777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 6877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns a printable string. 6977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 7077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern const char* 7116c1f44d91211a225497062ea508d58fd25085a9Gordon Henriksenlto_get_version(void); 7277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 7377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 7477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 7577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns the last error string or NULL if last operation was sucessful. 7677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 7777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern const char* 7816c1f44d91211a225497062ea508d58fd25085a9Gordon Henriksenlto_get_error_message(void); 7977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 8077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 8177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Checks if a file is a loadable object file. 8277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 8377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 8477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_is_object_file(const char* path); 8577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 8677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 8777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 8877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Checks if a file is a loadable object compiled for requested target. 8977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 9077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 9177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_is_object_file_for_target(const char* path, 92b454eabe7ff0824356ccdb75459a0312f43254c1Nick Lewycky const char* target_triple_prefix); 9377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 9477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 9577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 9677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Checks if a buffer is a loadable object file. 9777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 9877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 9977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_is_object_file_in_memory(const void* mem, size_t length); 10077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 10177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 10277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 10377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Checks if a buffer is a loadable object compiled for requested target. 10477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 10577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 10677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, 107ca3ca138d88139e24a8e60fef982436575a19f38Eric Christopher const char* target_triple_prefix); 10877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 10977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 11077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 11177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Loads an object file from disk. 11277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns NULL on error (check lto_get_error_message() for details). 11377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 11477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern lto_module_t 1150e7a54672cf346ee7c4aae10822c74f7c74f3fedOwen Andersonlto_module_create(const char* path); 11677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 11777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 11877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 11977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Loads an object file from memory. 12077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns NULL on error (check lto_get_error_message() for details). 12177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 12277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern lto_module_t 1230e7a54672cf346ee7c4aae10822c74f7c74f3fedOwen Andersonlto_module_create_from_memory(const void* mem, size_t length); 12477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 12577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 12677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 12777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Frees all memory internally allocated by the module. 12877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Upon return the lto_module_t is no longer valid. 12977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 13077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern void 13177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_dispose(lto_module_t mod); 13277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 13377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 13477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 13577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns triple string which the object module was compiled under. 13677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 13777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern const char* 13877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_get_target_triple(lto_module_t mod); 13977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 140cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindola/** 141cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindola * Sets triple string with which the object will be codegened. 142cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindola */ 143cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindolaextern void 144cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindolalto_module_set_target_triple(lto_module_t mod, const char *triple); 145cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindola 14677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 14777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 14877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns the number of symbols in the object module. 14977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 150767b5b6227a49cac98c275ab05f1560da0fe90beDevang Patelextern uint32_t 15177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_get_num_symbols(lto_module_t mod); 15277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 15377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 15477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 15577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns the name of the ith symbol in the object module. 15677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 15777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern const char* 158767b5b6227a49cac98c275ab05f1560da0fe90beDevang Patellto_module_get_symbol_name(lto_module_t mod, uint32_t index); 15977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 16077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 16177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 16277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns the attributes of the ith symbol in the object module. 16377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 16477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern lto_symbol_attributes 165767b5b6227a49cac98c275ab05f1560da0fe90beDevang Patellto_module_get_symbol_attribute(lto_module_t mod, uint32_t index); 16677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 16777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 16877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 16977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Instantiates a code generator. 17077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns NULL on error (check lto_get_error_message() for details). 17177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 17277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern lto_code_gen_t 1730e7a54672cf346ee7c4aae10822c74f7c74f3fedOwen Andersonlto_codegen_create(void); 17477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 17577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 17677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 17777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Frees all code generator and all memory it internally allocated. 17877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Upon return the lto_code_gen_t is no longer valid. 17977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 18077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern void 18177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_dispose(lto_code_gen_t); 18277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 18377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 18477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 18577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 18677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Add an object module to the set of modules for which code will be generated. 18777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns true on error (check lto_get_error_message() for details). 18877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 18977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 19077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); 19177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 19277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 19377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 19477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 19577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Sets if debug info should be generated. 19677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns true on error (check lto_get_error_message() for details). 19777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 19877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 19977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); 20077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 20177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 20277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 20377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Sets which PIC code model to generated. 20477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns true on error (check lto_get_error_message() for details). 20577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 20677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 20777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); 20877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 20977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 21077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 2112d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola * Sets the cpu to generate code for. 2122d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola */ 2132d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindolaextern void 2142d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindolalto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu); 2152d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola 2162d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola 2172d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola/** 218cbad58624090933cb8fb85587e03be613a481309Nick Kledzik * Sets the location of the assembler tool to run. If not set, libLTO 219cbad58624090933cb8fb85587e03be613a481309Nick Kledzik * will use gcc to invoke the assembler. 220cbad58624090933cb8fb85587e03be613a481309Nick Kledzik */ 221cbad58624090933cb8fb85587e03be613a481309Nick Kledzikextern void 222cbad58624090933cb8fb85587e03be613a481309Nick Kledziklto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path); 223cbad58624090933cb8fb85587e03be613a481309Nick Kledzik 22498197e55c10176c3ef9100f7d852abbd2347225fRafael Espindola/** 22598197e55c10176c3ef9100f7d852abbd2347225fRafael Espindola * Sets extra arguments that libLTO should pass to the assembler. 22698197e55c10176c3ef9100f7d852abbd2347225fRafael Espindola */ 22798197e55c10176c3ef9100f7d852abbd2347225fRafael Espindolaextern void 22898197e55c10176c3ef9100f7d852abbd2347225fRafael Espindolalto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, 22998197e55c10176c3ef9100f7d852abbd2347225fRafael Espindola int nargs); 230cbad58624090933cb8fb85587e03be613a481309Nick Kledzik 231cbad58624090933cb8fb85587e03be613a481309Nick Kledzik/** 23277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Adds to a list of all global symbols that must exist in the final 23377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * generated code. If a function is not listed, it might be 23477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * inlined into every usage and optimized away. 23577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 23677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern void 23777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol); 23877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 23977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 24077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 24177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Writes a new object file at the specified path that contains the 24277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * merged contents of all modules added so far. 24377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns true on error (check lto_get_error_message() for details). 24477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 24577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 24677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path); 24777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 24877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 24977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 25077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Generates code for all added modules into one native object file. 25177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * On sucess returns a pointer to a generated mach-o/ELF buffer and 252ef194ed74033eba099f4f391ffdfc176f9aa6f26Nick Kledzik * length set to the buffer size. The buffer is owned by the 253ef194ed74033eba099f4f391ffdfc176f9aa6f26Nick Kledzik * lto_code_gen_t and will be freed when lto_codegen_dispose() 254ef194ed74033eba099f4f391ffdfc176f9aa6f26Nick Kledzik * is called, or lto_codegen_compile() is called again. 25577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * On failure, returns NULL (check lto_get_error_message() for details). 25677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 257ef194ed74033eba099f4f391ffdfc176f9aa6f26Nick Kledzikextern const void* 25877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_compile(lto_code_gen_t cg, size_t* length); 25977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 26077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 261a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patel/** 262a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patel * Sets options to help debug codegen bugs. 263a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patel */ 264a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patelextern void 265a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patellto_codegen_debug_options(lto_code_gen_t cg, const char *); 26677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#ifdef __cplusplus 26777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik} 26877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#endif 26977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 27077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 27177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#endif 272