llvm.org GIT mirror llvm / 6ba5c56
Add support for global aliases to ocaml. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97413 91177308-0d34-0410-b5e6-96231b3b80d8 Erick Tryzelaar 10 years ago
4 changed file(s) with 29 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
443443 let fold_right_globals f m init =
444444 fold_right_global_range f (global_end m) (At_start m) init
445445
446 (*--... Operations on aliases ..............................................--*)
447 external add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
448 = "llvm_add_alias"
449
446450 (*--... Operations on functions ............................................--*)
447451 external declare_function : string -> lltype -> llmodule -> llvalue
448452 = "llvm_declare_function"
11371137 [c] is [true] and not otherwise.
11381138 See the method [llvm::GlobalVariable::setThreadLocal]. *)
11391139 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
1140
1141
1142 (** {7 Operations on aliases} *)
1143
1144 (** [add_alias m t a n] inserts an alias in the module [m] with the type [t] and
1145 the aliasee [a] with the name [n].
1146 See the constructor for [llvm::GlobalAlias]. *)
1147 external add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
1148 = "llvm_add_alias"
11401149
11411150
11421151 (** {7 Operations on functions} *)
806806 return Val_unit;
807807 }
808808
809 /*--... Operations on aliases ..............................................--*/
810
811 CAMLprim LLVMValueRef llvm_add_alias(LLVMModuleRef M, LLVMTypeRef Ty,
812 LLVMValueRef Aliasee, value Name) {
813 return LLVMAddAlias(M, Ty, Aliasee, String_val(Name));
814 }
815
809816 /*--... Operations on functions ............................................--*/
810817
811818 DEFINE_ITERATORS(function, Function, LLVMModuleRef, LLVMValueRef,
605605 dispose_module m
606606 end
607607
608 (*===-- Aliases -----------------------------------------------------------===*)
609
610 let test_aliases () =
611 (* RUN: grep {@alias = alias i32\\* @aliasee} < %t.ll
612 *)
613 let v = declare_global i32_type "aliasee" m in
614 ignore (add_alias m (pointer_type i32_type) v "alias")
615
608616
609617 (*===-- Functions ---------------------------------------------------------===*)
610618
12641272 suite "constants" test_constants;
12651273 suite "global values" test_global_values;
12661274 suite "global variables" test_global_variables;
1275 suite "aliases" test_aliases;
12671276 suite "functions" test_functions;
12681277 suite "params" test_params;
12691278 suite "basic blocks" test_basic_blocks;