lto.h revision e8a665f696b60834a3087e3d5bccf8cacf3ca39d
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 16674be02d525d4e24bc6943ed9274958c580bcfbcJakub Staszak#ifndef LLVM_C_LTO_H 17674be02d525d4e24bc6943ed9274958c580bcfbcJakub Staszak#define LLVM_C_LTO_H 1877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 19aca74f0e0d221a0dfe355adcdf0592bb64461df7Peter Collingbourne#ifndef __cplusplus 2077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#include <stdbool.h> 21aca74f0e0d221a0dfe355adcdf0592bb64461df7Peter Collingbourne#endif 2277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#include <stddef.h> 23e8a665f696b60834a3087e3d5bccf8cacf3ca39dPeter Collingbourne#include <sys/types.h> 2477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 256244b518880842f2c15200ee041e06799e4cc779Gregory Szorc/** 266244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @defgroup LLVMCLTO LTO 276244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @ingroup LLVMC 286244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * 296244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @{ 306244b518880842f2c15200ee041e06799e4cc779Gregory Szorc */ 316244b518880842f2c15200ee041e06799e4cc779Gregory Szorc 3200c198042e22d781e46180a2aec2332945712552Shuxin Yang#define LTO_API_VERSION 4 33cbad58624090933cb8fb85587e03be613a481309Nick Kledzik 3477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef enum { 357afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */ 36168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_PERMISSIONS_MASK = 0x000000E0, 37168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_PERMISSIONS_CODE = 0x000000A0, 38168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_PERMISSIONS_DATA = 0x000000C0, 39168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_PERMISSIONS_RODATA = 0x00000080, 40168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_DEFINITION_MASK = 0x00000700, 41168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_DEFINITION_REGULAR = 0x00000100, 42168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200, 43168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_DEFINITION_WEAK = 0x00000300, 44168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400, 457afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_DEFINITION_WEAKUNDEF = 0x00000500, 46168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_SCOPE_MASK = 0x00003800, 47168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800, 48168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000, 49168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling LTO_SYMBOL_SCOPE_PROTECTED = 0x00002000, 507afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_SCOPE_DEFAULT = 0x00001800, 517afea0cfc4abebaf4cadcc37acd30fb251a5faf3Bill Wendling LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800 5277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik} lto_symbol_attributes; 5377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 5477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef enum { 5577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_DEBUG_MODEL_NONE = 0, 5677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_DEBUG_MODEL_DWARF = 1 5777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik} lto_debug_model; 5877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 5977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef enum { 6077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_CODEGEN_PIC_MODEL_STATIC = 0, 6177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1, 6277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2 6377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik} lto_codegen_model; 6477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 6577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 6677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** opaque reference to a loaded object module */ 6777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef struct LTOModule* lto_module_t; 6877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 6977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** opaque reference to a code generator */ 7077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziktypedef struct LTOCodeGenerator* lto_code_gen_t; 7177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 7277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#ifdef __cplusplus 7377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern "C" { 7477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#endif 7577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 7677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 7777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns a printable string. 7877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 7977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern const char* 8016c1f44d91211a225497062ea508d58fd25085a9Gordon Henriksenlto_get_version(void); 8177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 8277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 8377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 847a2bdde0a0eebcd2125055e0eacaca040f0b766cChris Lattner * Returns the last error string or NULL if last operation was successful. 8577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 8677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern const char* 8716c1f44d91211a225497062ea508d58fd25085a9Gordon Henriksenlto_get_error_message(void); 8877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 8977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 9077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Checks if a file is a loadable object file. 9177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 9277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 9377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_is_object_file(const char* path); 9477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 9577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 9677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 9777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Checks if a file is a loadable object compiled for requested target. 9877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 9977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 100168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendlinglto_module_is_object_file_for_target(const char* path, 101b454eabe7ff0824356ccdb75459a0312f43254c1Nick Lewycky const char* target_triple_prefix); 10277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 10377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 10477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 10577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Checks if a buffer is a loadable object file. 10677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 10777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 10877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_is_object_file_in_memory(const void* mem, size_t length); 10977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 11077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 11177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 11277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Checks if a buffer is a loadable object compiled for requested target. 11377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 11477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 115168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendlinglto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, 116ca3ca138d88139e24a8e60fef982436575a19f38Eric Christopher const char* target_triple_prefix); 11777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 11877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 11977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 12077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Loads an object file from disk. 12177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns NULL on error (check lto_get_error_message() for details). 12277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 12377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern lto_module_t 1240e7a54672cf346ee7c4aae10822c74f7c74f3fedOwen Andersonlto_module_create(const char* path); 12577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 12677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 12777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 12877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Loads an object file from memory. 12977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns NULL on error (check lto_get_error_message() for details). 13077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 13177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern lto_module_t 1320e7a54672cf346ee7c4aae10822c74f7c74f3fedOwen Andersonlto_module_create_from_memory(const void* mem, size_t length); 13377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 134b4cc031a3e1306fea74c9211d50c5cde6d9a8cd5Rafael Espindola/** 135b4cc031a3e1306fea74c9211d50c5cde6d9a8cd5Rafael Espindola * Loads an object file from disk. The seek point of fd is not preserved. 136b4cc031a3e1306fea74c9211d50c5cde6d9a8cd5Rafael Espindola * Returns NULL on error (check lto_get_error_message() for details). 137b4cc031a3e1306fea74c9211d50c5cde6d9a8cd5Rafael Espindola */ 138b4cc031a3e1306fea74c9211d50c5cde6d9a8cd5Rafael Espindolaextern lto_module_t 139f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindolalto_module_create_from_fd(int fd, const char *path, size_t file_size); 140f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindola 141f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindola/** 142f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindola * Loads an object file from disk. The seek point of fd is not preserved. 143f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindola * Returns NULL on error (check lto_get_error_message() for details). 144f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindola */ 145f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindolaextern lto_module_t 146f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindolalto_module_create_from_fd_at_offset(int fd, const char *path, size_t file_size, 147f21b1058a194f411000bdd8000a8b675a7874056Rafael Espindola size_t map_size, off_t offset); 148b4cc031a3e1306fea74c9211d50c5cde6d9a8cd5Rafael Espindola 14977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 15077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 15177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Frees all memory internally allocated by the module. 15277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Upon return the lto_module_t is no longer valid. 15377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 15477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern void 15577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_dispose(lto_module_t mod); 15677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 15777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 15877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 15977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns triple string which the object module was compiled under. 16077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 16177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern const char* 16277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_get_target_triple(lto_module_t mod); 16377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 164cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindola/** 165cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindola * Sets triple string with which the object will be codegened. 166cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindola */ 167cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindolaextern void 168cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindolalto_module_set_target_triple(lto_module_t mod, const char *triple); 169cbb170d057aa6692b19f577b1e09a6c1c7a26969Rafael Espindola 17077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 17177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 17277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns the number of symbols in the object module. 17377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 1746a6623c596fc12f64c813ea14a006ac6da3e33feDevang Patelextern unsigned int 17577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_module_get_num_symbols(lto_module_t mod); 17677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 17777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 17877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 17977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns the name of the ith symbol in the object module. 18077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 18177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern const char* 1826a6623c596fc12f64c813ea14a006ac6da3e33feDevang Patellto_module_get_symbol_name(lto_module_t mod, unsigned int index); 18377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 18477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 18577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 18677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns the attributes of the ith symbol in the object module. 18777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 18877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern lto_symbol_attributes 1896a6623c596fc12f64c813ea14a006ac6da3e33feDevang Patellto_module_get_symbol_attribute(lto_module_t mod, unsigned int index); 19077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 19177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 19277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 19377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Instantiates a code generator. 19477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns NULL on error (check lto_get_error_message() for details). 19577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 19677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern lto_code_gen_t 1970e7a54672cf346ee7c4aae10822c74f7c74f3fedOwen Andersonlto_codegen_create(void); 19877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 19977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 20077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 20177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Frees all code generator and all memory it internally allocated. 20277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Upon return the lto_code_gen_t is no longer valid. 20377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 20477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern void 20577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_dispose(lto_code_gen_t); 20677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 20777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 20877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 20977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 21077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Add an object module to the set of modules for which code will be generated. 21177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns true on error (check lto_get_error_message() for details). 21277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 21377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 21477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); 21577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 21677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 21777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 21877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 21977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Sets if debug info should be generated. 22077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns true on error (check lto_get_error_message() for details). 22177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 22277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 22377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); 22477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 22577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 22677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 22777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Sets which PIC code model to generated. 22877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns true on error (check lto_get_error_message() for details). 22977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 23077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 23177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); 23277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 23377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 23477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 2352d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola * Sets the cpu to generate code for. 2362d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola */ 2372d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindolaextern void 2382d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindolalto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu); 2392d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola 2402d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola 2412d643ef32891859ec73b6eea2959748f5ebc3af7Rafael Espindola/** 242cbad58624090933cb8fb85587e03be613a481309Nick Kledzik * Sets the location of the assembler tool to run. If not set, libLTO 243cbad58624090933cb8fb85587e03be613a481309Nick Kledzik * will use gcc to invoke the assembler. 244cbad58624090933cb8fb85587e03be613a481309Nick Kledzik */ 245cbad58624090933cb8fb85587e03be613a481309Nick Kledzikextern void 246cbad58624090933cb8fb85587e03be613a481309Nick Kledziklto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path); 247cbad58624090933cb8fb85587e03be613a481309Nick Kledzik 24898197e55c10176c3ef9100f7d852abbd2347225fRafael Espindola/** 24998197e55c10176c3ef9100f7d852abbd2347225fRafael Espindola * Sets extra arguments that libLTO should pass to the assembler. 25098197e55c10176c3ef9100f7d852abbd2347225fRafael Espindola */ 25198197e55c10176c3ef9100f7d852abbd2347225fRafael Espindolaextern void 25298197e55c10176c3ef9100f7d852abbd2347225fRafael Espindolalto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, 25398197e55c10176c3ef9100f7d852abbd2347225fRafael Espindola int nargs); 254cbad58624090933cb8fb85587e03be613a481309Nick Kledzik 255cbad58624090933cb8fb85587e03be613a481309Nick Kledzik/** 25677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Adds to a list of all global symbols that must exist in the final 25777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * generated code. If a function is not listed, it might be 25877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * inlined into every usage and optimized away. 25977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 26077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern void 26177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol); 26277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 26377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 26477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Writes a new object file at the specified path that contains the 26577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * merged contents of all modules added so far. 26677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Returns true on error (check lto_get_error_message() for details). 26777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 26877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzikextern bool 26977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path); 27077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 27177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik/** 27277595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * Generates code for all added modules into one native object file. 2737a2bdde0a0eebcd2125055e0eacaca040f0b766cChris Lattner * On success returns a pointer to a generated mach-o/ELF buffer and 274168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling * length set to the buffer size. The buffer is owned by the 275ef194ed74033eba099f4f391ffdfc176f9aa6f26Nick Kledzik * lto_code_gen_t and will be freed when lto_codegen_dispose() 276ef194ed74033eba099f4f391ffdfc176f9aa6f26Nick Kledzik * is called, or lto_codegen_compile() is called again. 27777595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik * On failure, returns NULL (check lto_get_error_message() for details). 27877595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik */ 279ef194ed74033eba099f4f391ffdfc176f9aa6f26Nick Kledzikextern const void* 28077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledziklto_codegen_compile(lto_code_gen_t cg, size_t* length); 28177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 2826421a8815e14189121a5e20731fd005ea08793e1Rafael Espindola/** 2836421a8815e14189121a5e20731fd005ea08793e1Rafael Espindola * Generates code for all added modules into one native object file. 2846421a8815e14189121a5e20731fd005ea08793e1Rafael Espindola * The name of the file is written to name. Returns true on error. 2856421a8815e14189121a5e20731fd005ea08793e1Rafael Espindola */ 2866421a8815e14189121a5e20731fd005ea08793e1Rafael Espindolaextern bool 2876421a8815e14189121a5e20731fd005ea08793e1Rafael Espindolalto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); 2886421a8815e14189121a5e20731fd005ea08793e1Rafael Espindola 28977595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 290a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patel/** 291a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patel * Sets options to help debug codegen bugs. 292a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patel */ 293a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patelextern void 294a93ae711a91dd151ca4d28e4172e0de89d1594f3Devang Patellto_codegen_debug_options(lto_code_gen_t cg, const char *); 295168f1428346f3d51304db0be64e1d5e4a09ca4c2Bill Wendling 2968a2ce5d32987f99185f40eb3085a8972291f8d5cBenjamin Kramer/** 2978a2ce5d32987f99185f40eb3085a8972291f8d5cBenjamin Kramer * Initializes LLVM disassemblers. 2988a2ce5d32987f99185f40eb3085a8972291f8d5cBenjamin Kramer * FIXME: This doesn't really belong here. 2998a2ce5d32987f99185f40eb3085a8972291f8d5cBenjamin Kramer */ 3008a2ce5d32987f99185f40eb3085a8972291f8d5cBenjamin Kramerextern void 3018a2ce5d32987f99185f40eb3085a8972291f8d5cBenjamin Kramerlto_initialize_disassembler(void); 3028a2ce5d32987f99185f40eb3085a8972291f8d5cBenjamin Kramer 30377595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#ifdef __cplusplus 30477595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik} 30577595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#endif 30677595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 3076244b518880842f2c15200ee041e06799e4cc779Gregory Szorc/** 3086244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @} 3096244b518880842f2c15200ee041e06799e4cc779Gregory Szorc */ 31077595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik 31177595fc35642f990bfc5ad05b8e68d4056695ecaNick Kledzik#endif 312