summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGordon Henriksen <gordonhenriksen@mac.com>2007-12-29 20:45:00 +0000
committerGordon Henriksen <gordonhenriksen@mac.com>2007-12-29 20:45:00 +0000
commit1158c533f761e5780dfd40acd0b2a2c1b033e723 (patch)
treefc6473bdb2610ba88f725e47f03e9ea53204de58
parent345353d6b46de21075e682d4c380195e6e660abb (diff)
downloadbcm5719-llvm-1158c533f761e5780dfd40acd0b2a2c1b033e723.tar.gz
bcm5719-llvm-1158c533f761e5780dfd40acd0b2a2c1b033e723.zip
Bindings for instruction calling conventions.
llvm-svn: 45422
-rw-r--r--llvm/bindings/ocaml/llvm/llvm.ml6
-rw-r--r--llvm/bindings/ocaml/llvm/llvm.mli14
-rw-r--r--llvm/bindings/ocaml/llvm/llvm_ocaml.c13
-rw-r--r--llvm/include/llvm-c/Core.h4
-rw-r--r--llvm/test/Bindings/Ocaml/vmcore.ml9
5 files changed, 44 insertions, 2 deletions
diff --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml
index 457677b493a..fa4db0e8114 100644
--- a/llvm/bindings/ocaml/llvm/llvm.ml
+++ b/llvm/bindings/ocaml/llvm/llvm.ml
@@ -328,6 +328,12 @@ external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
external value_is_block : llvalue -> bool = "llvm_value_is_block"
external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
+(*--... Operations on call sites ...........................................--*)
+external instruction_call_conv: llvalue -> int
+ = "llvm_instruction_call_conv"
+external set_instruction_call_conv: int -> llvalue -> unit
+ = "llvm_set_instruction_call_conv"
+
(*--... Operations on phi nodes ............................................--*)
external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
= "llvm_add_incoming"
diff --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli
index 8f2c9219e36..6d980a14709 100644
--- a/llvm/bindings/ocaml/llvm/llvm.mli
+++ b/llvm/bindings/ocaml/llvm/llvm.mli
@@ -854,6 +854,20 @@ external value_is_block : llvalue -> bool = "llvm_value_is_block"
(** [block_of_value v] losslessly casts [v] to an [llbasicblock]. **)
external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
+(*--... Operations on call sites ...........................................--*)
+
+(** [inst_call_conv ci] is the calling convention for the call or invoke
+ instruction [ci], which may be one of the values from the module [CallConv].
+ See the method [CallSite:: **)
+external instruction_call_conv: llvalue -> int
+ = "llvm_instruction_call_conv"
+
+(** [set_inst_call_conv cc ci] sets the calling convention for the call or
+ invoke instruction [ci] to the integer [cc], which can be one of the values
+ from the module [CallConv]. See the method [CallSite::]. **)
+external set_instruction_call_conv: int -> llvalue -> unit
+ = "llvm_set_instruction_call_conv"
+
(*--... Operations on phi nodes ............................................--*)
(** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
index d0955509622..35c2c8da4be 100644
--- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -652,6 +652,19 @@ CAMLprim value llvm_value_is_block(LLVMValueRef Val) {
return Val_bool(LLVMValueIsBasicBlock(Val));
}
+/*--... Operations on call sites ...........................................--*/
+
+/* llvalue -> int */
+CAMLprim value llvm_instruction_call_conv(LLVMValueRef Inst) {
+ return Val_int(LLVMGetInstructionCallConv(Inst));
+}
+
+/* int -> llvalue -> unit */
+CAMLprim value llvm_set_instruction_call_conv(value CC, LLVMValueRef Inst) {
+ LLVMSetInstructionCallConv(Inst, Int_val(CC));
+ return Val_unit;
+}
+
/*--... Operations on phi nodes ............................................--*/
/* (llvalue * llbasicblock) -> llvalue -> unit */
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 21c319c6ec3..b286e6fca28 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -378,6 +378,10 @@ LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
const char *Name);
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
+/* Operations on call sites */
+void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
+unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
+
/* Operations on phi nodes */
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
diff --git a/llvm/test/Bindings/Ocaml/vmcore.ml b/llvm/test/Bindings/Ocaml/vmcore.ml
index 6b103cb8fc9..457e7664efa 100644
--- a/llvm/test/Bindings/Ocaml/vmcore.ml
+++ b/llvm/test/Bindings/Ocaml/vmcore.ml
@@ -768,14 +768,19 @@ let test_builder () =
end;
group "miscellaneous"; begin
- (* RUN: grep {Inst45.*call.*P2.*P1} < %t.ll
+ (* RUN: grep {CallInst.*call.*P2.*P1} < %t.ll
+ * RUN: grep {CallInst.*cc63} < %t.ll
* RUN: grep {Inst47.*select.*Inst46.*P1.*P2} < %t.ll
* RUN: grep {Inst48.*va_arg.*null.*i32} < %t.ll
* RUN: grep {Inst49.*extractelement.*Vec1.*P2} < %t.ll
* RUN: grep {Inst50.*insertelement.*Vec1.*P1.*P2} < %t.ll
* RUN: grep {Inst51.*shufflevector.*Vec1.*Vec2.*1.*1.*0.*0} < %t.ll
*)
- ignore (build_call fn [| p2; p1 |] "Inst45" atentry);
+ let ci = build_call fn [| p2; p1 |] "CallInst" atentry in
+ insist (CallConv.c = instruction_call_conv ci);
+ set_instruction_call_conv 63 ci;
+ insist (63 = instruction_call_conv ci);
+
let inst46 = build_icmp Icmp.Eq p1 p2 "Inst46" atentry in
ignore (build_select inst46 p1 p2 "Inst47" atentry);
ignore (build_va_arg
OpenPOWER on IntegriCloud