[llvm-commits] [llvm] r97413 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c test/Bindings/Ocaml/vmcore.ml
Erick Tryzelaar
idadesub at users.sourceforge.net
Sun Feb 28 12:44:58 PST 2010
Author: erickt
Date: Sun Feb 28 14:44:58 2010
New Revision: 97413
URL: http://llvm.org/viewvc/llvm-project?rev=97413&view=rev
Log:
Add support for global aliases to ocaml.
Modified:
llvm/trunk/bindings/ocaml/llvm/llvm.ml
llvm/trunk/bindings/ocaml/llvm/llvm.mli
llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
llvm/trunk/test/Bindings/Ocaml/vmcore.ml
Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=97413&r1=97412&r2=97413&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Sun Feb 28 14:44:58 2010
@@ -444,6 +444,10 @@
let fold_right_globals f m init =
fold_right_global_range f (global_end m) (At_start m) init
+(*--... Operations on aliases ..............................................--*)
+external add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
+ = "llvm_add_alias"
+
(*--... Operations on functions ............................................--*)
external declare_function : string -> lltype -> llmodule -> llvalue
= "llvm_declare_function"
Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=97413&r1=97412&r2=97413&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Sun Feb 28 14:44:58 2010
@@ -1140,6 +1140,15 @@
external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
+(** {7 Operations on aliases} *)
+
+(** [add_alias m t a n] inserts an alias in the module [m] with the type [t] and
+ the aliasee [a] with the name [n].
+ See the constructor for [llvm::GlobalAlias]. *)
+external add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
+ = "llvm_add_alias"
+
+
(** {7 Operations on functions} *)
(** [declare_function name ty m] returns a new function of type [ty] and
Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=97413&r1=97412&r2=97413&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Sun Feb 28 14:44:58 2010
@@ -807,6 +807,13 @@
return Val_unit;
}
+/*--... Operations on aliases ..............................................--*/
+
+CAMLprim LLVMValueRef llvm_add_alias(LLVMModuleRef M, LLVMTypeRef Ty,
+ LLVMValueRef Aliasee, value Name) {
+ return LLVMAddAlias(M, Ty, Aliasee, String_val(Name));
+}
+
/*--... Operations on functions ............................................--*/
DEFINE_ITERATORS(function, Function, LLVMModuleRef, LLVMValueRef,
Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=97413&r1=97412&r2=97413&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original)
+++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Sun Feb 28 14:44:58 2010
@@ -606,6 +606,14 @@
dispose_module m
end
+(*===-- Aliases -----------------------------------------------------------===*)
+
+let test_aliases () =
+ (* RUN: grep {@alias = alias i32\\* @aliasee} < %t.ll
+ *)
+ let v = declare_global i32_type "aliasee" m in
+ ignore (add_alias m (pointer_type i32_type) v "alias")
+
(*===-- Functions ---------------------------------------------------------===*)
@@ -1265,6 +1273,7 @@
suite "constants" test_constants;
suite "global values" test_global_values;
suite "global variables" test_global_variables;
+ suite "aliases" test_aliases;
suite "functions" test_functions;
suite "params" test_params;
suite "basic blocks" test_basic_blocks;
More information about the llvm-commits
mailing list