Add basic test exposing many bugs.
[oota-llvm.git] / include / llvm-c / lto.h
index 5d92fc5af013594f2d51dcb648eac4bd583ae462..8dccc7864076b5b8ae597556628a91280cc80092 100644 (file)
 
 #include <stdbool.h>
 #include <stddef.h>
+#include "llvm/Support/DataTypes.h"
 
-#define LTO_API_VERSION 3
+#define LTO_API_VERSION 4
 
 typedef enum {
-    LTO_SYMBOL_ALIGNMENT_MASK         = 0x0000001F,    /* log2 of alignment */
-    LTO_SYMBOL_PERMISSIONS_MASK       = 0x000000E0,    
-    LTO_SYMBOL_PERMISSIONS_CODE       = 0x000000A0,    
-    LTO_SYMBOL_PERMISSIONS_DATA       = 0x000000C0,    
-    LTO_SYMBOL_PERMISSIONS_RODATA     = 0x00000080,    
-    LTO_SYMBOL_DEFINITION_MASK        = 0x00000700,    
-    LTO_SYMBOL_DEFINITION_REGULAR     = 0x00000100,    
-    LTO_SYMBOL_DEFINITION_TENTATIVE   = 0x00000200,    
-    LTO_SYMBOL_DEFINITION_WEAK        = 0x00000300,    
-    LTO_SYMBOL_DEFINITION_UNDEFINED   = 0x00000400,    
-    LTO_SYMBOL_DEFINITION_WEAKUNDEF   = 0x00000500,
-    LTO_SYMBOL_SCOPE_MASK             = 0x00003800,    
-    LTO_SYMBOL_SCOPE_INTERNAL         = 0x00000800,    
-    LTO_SYMBOL_SCOPE_HIDDEN           = 0x00001000,    
-    LTO_SYMBOL_SCOPE_PROTECTED        = 0x00002000,    
-    LTO_SYMBOL_SCOPE_DEFAULT          = 0x00001800    
+    LTO_SYMBOL_ALIGNMENT_MASK              = 0x0000001F, /* log2 of alignment */
+    LTO_SYMBOL_PERMISSIONS_MASK            = 0x000000E0,    
+    LTO_SYMBOL_PERMISSIONS_CODE            = 0x000000A0,    
+    LTO_SYMBOL_PERMISSIONS_DATA            = 0x000000C0,    
+    LTO_SYMBOL_PERMISSIONS_RODATA          = 0x00000080,    
+    LTO_SYMBOL_DEFINITION_MASK             = 0x00000700,    
+    LTO_SYMBOL_DEFINITION_REGULAR          = 0x00000100,    
+    LTO_SYMBOL_DEFINITION_TENTATIVE        = 0x00000200,    
+    LTO_SYMBOL_DEFINITION_WEAK             = 0x00000300,    
+    LTO_SYMBOL_DEFINITION_UNDEFINED        = 0x00000400,    
+    LTO_SYMBOL_DEFINITION_WEAKUNDEF        = 0x00000500,
+    LTO_SYMBOL_SCOPE_MASK                  = 0x00003800,    
+    LTO_SYMBOL_SCOPE_INTERNAL              = 0x00000800,    
+    LTO_SYMBOL_SCOPE_HIDDEN                = 0x00001000,    
+    LTO_SYMBOL_SCOPE_PROTECTED             = 0x00002000,    
+    LTO_SYMBOL_SCOPE_DEFAULT               = 0x00001800,
+    LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800
 } lto_symbol_attributes;
 
 typedef enum {
@@ -58,7 +60,6 @@ typedef struct LTOModule*         lto_module_t;
 /** opaque reference to a code generator */
 typedef struct LTOCodeGenerator*  lto_code_gen_t;
 
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -76,7 +77,6 @@ lto_get_version(void);
 extern const char*
 lto_get_error_message(void);
 
-
 /**
  * Checks if a file is a loadable object file.
  */
@@ -104,7 +104,7 @@ lto_module_is_object_file_in_memory(const void* mem, size_t length);
  */
 extern bool
 lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, 
-                                               const char* target_triple_prefix);
+                                              const char* target_triple_prefix);
 
 
 /**
@@ -137,11 +137,17 @@ lto_module_dispose(lto_module_t mod);
 extern const char*
 lto_module_get_target_triple(lto_module_t mod);
 
+/**
+ * Sets triple string with which the object will be codegened.
+ */
+extern void
+lto_module_set_target_triple(lto_module_t mod, const char *triple);
+
 
 /**
  * Returns the number of symbols in the object module.
  */
-extern unsigned int
+extern uint32_t
 lto_module_get_num_symbols(lto_module_t mod);
 
 
@@ -149,14 +155,14 @@ lto_module_get_num_symbols(lto_module_t mod);
  * Returns the name of the ith symbol in the object module.
  */
 extern const char*
-lto_module_get_symbol_name(lto_module_t mod, unsigned int index);
+lto_module_get_symbol_name(lto_module_t mod, uint32_t index);
 
 
 /**
  * Returns the attributes of the ith symbol in the object module.
  */
 extern lto_symbol_attributes
-lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index);
+lto_module_get_symbol_attribute(lto_module_t mod, uint32_t index);
 
 
 /**
@@ -202,11 +208,10 @@ lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model);
 
 
 /**
- * Sets the location of the "gcc" to run. If not set, libLTO will search for
- * "gcc" on the path.
+ * Sets the cpu to generate code for.
  */
 extern void
-lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path);
+lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu);
 
 
 /**
@@ -216,6 +221,12 @@ lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path);
 extern void
 lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path);
 
+/**
+ * Sets extra arguments that libLTO should pass to the assembler.
+ */
+extern void
+lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
+                               int nargs);
 
 /**
  * Adds to a list of all global symbols that must exist in the final