summaryrefslogtreecommitdiff
path: root/bindings/ocaml/llvm/llvm_ocaml.c
diff options
context:
space:
mode:
authorTorok Edwin <edwintorok@gmail.com>2011-10-14 20:38:24 +0000
committerTorok Edwin <edwintorok@gmail.com>2011-10-14 20:38:24 +0000
commit0be167bab219cb178f7a6e91186c700ad48aa047 (patch)
tree2c8b51e25e2c3c9b5931d245629d758885bef574 /bindings/ocaml/llvm/llvm_ocaml.c
parent8da43bf60e8c27fe69033d73d440ea147d72b06d (diff)
downloadllvm-0be167bab219cb178f7a6e91186c700ad48aa047.tar.gz
llvm-0be167bab219cb178f7a6e91186c700ad48aa047.tar.bz2
llvm-0be167bab219cb178f7a6e91186c700ad48aa047.tar.xz
OCaml bindings: fix attributes to use all 32 bits
OCaml's int is limited to 31 bits on 32-bit architectures, so use Int32 explicitly. Also add an unpack_attr, and {function,param,instr}_attr functions to read the attributes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141996 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/ocaml/llvm/llvm_ocaml.c')
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index be6e808d73..5090bf83d1 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -1034,15 +1034,22 @@ CAMLprim value llvm_set_gc(value GC, LLVMValueRef Fn) {
return Val_unit;
}
-/* llvalue -> Attribute.t -> unit */
+/* llvalue -> int32 -> unit */
CAMLprim value llvm_add_function_attr(LLVMValueRef Arg, value PA) {
- LLVMAddFunctionAttr(Arg, Int_val(PA));
+ LLVMAddFunctionAttr(Arg, Int32_val(PA));
return Val_unit;
}
-/* llvalue -> Attribute.t -> unit */
+/* llvalue -> int32 */
+CAMLprim value llvm_function_attr(LLVMValueRef Fn)
+{
+ CAMLparam0();
+ CAMLreturn(caml_copy_int32(LLVMGetFunctionAttr(Fn)));
+}
+
+/* llvalue -> int32 -> unit */
CAMLprim value llvm_remove_function_attr(LLVMValueRef Arg, value PA) {
- LLVMRemoveFunctionAttr(Arg, Int_val(PA));
+ LLVMRemoveFunctionAttr(Arg, Int32_val(PA));
return Val_unit;
}
/*--... Operations on parameters ...........................................--*/
@@ -1054,6 +1061,13 @@ CAMLprim LLVMValueRef llvm_param(LLVMValueRef Fn, value Index) {
return LLVMGetParam(Fn, Int_val(Index));
}
+/* llvalue -> int */
+CAMLprim value llvm_param_attr(LLVMValueRef Param)
+{
+ CAMLparam0();
+ CAMLreturn(caml_copy_int32(LLVMGetAttribute(Param)));
+}
+
/* llvalue -> llvalue */
CAMLprim value llvm_params(LLVMValueRef Fn) {
value Params = alloc(LLVMCountParams(Fn), 0);
@@ -1061,15 +1075,15 @@ CAMLprim value llvm_params(LLVMValueRef Fn) {
return Params;
}
-/* llvalue -> Attribute.t -> unit */
+/* llvalue -> int32 -> unit */
CAMLprim value llvm_add_param_attr(LLVMValueRef Arg, value PA) {
- LLVMAddAttribute(Arg, Int_val(PA));
+ LLVMAddAttribute(Arg, Int32_val(PA));
return Val_unit;
}
-/* llvalue -> Attribute.t -> unit */
+/* llvalue -> int32 -> unit */
CAMLprim value llvm_remove_param_attr(LLVMValueRef Arg, value PA) {
- LLVMRemoveAttribute(Arg, Int_val(PA));
+ LLVMRemoveAttribute(Arg, Int32_val(PA));
return Val_unit;
}
@@ -1155,19 +1169,19 @@ CAMLprim value llvm_set_instruction_call_conv(value CC, LLVMValueRef Inst) {
return Val_unit;
}
-/* llvalue -> int -> Attribute.t -> unit */
+/* llvalue -> int -> int32 -> unit */
CAMLprim value llvm_add_instruction_param_attr(LLVMValueRef Instr,
value index,
value PA) {
- LLVMAddInstrAttribute(Instr, Int_val(index), Int_val(PA));
+ LLVMAddInstrAttribute(Instr, Int_val(index), Int32_val(PA));
return Val_unit;
}
-/* llvalue -> int -> Attribute.t -> unit */
+/* llvalue -> int -> int32 -> unit */
CAMLprim value llvm_remove_instruction_param_attr(LLVMValueRef Instr,
value index,
value PA) {
- LLVMRemoveInstrAttribute(Instr, Int_val(index), Int_val(PA));
+ LLVMRemoveInstrAttribute(Instr, Int_val(index), Int32_val(PA));
return Val_unit;
}