Add support for inserting inline asm to ocaml.
authorErick Tryzelaar <idadesub@users.sourceforge.net>
Sun, 28 Feb 2010 20:44:53 +0000 (20:44 +0000)
committerErick Tryzelaar <idadesub@users.sourceforge.net>
Sun, 28 Feb 2010 20:44:53 +0000 (20:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97412 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/ocaml/llvm/llvm.ml
bindings/ocaml/llvm/llvm.mli
bindings/ocaml/llvm/llvm_ocaml.c
test/Bindings/Ocaml/vmcore.ml

index 7c72a61abc4d6bb81a72d2f8ec8387388e45ecc6..92bfef51d0318d6b15aa7a426aef81ab4a0cf98e 100644 (file)
@@ -356,6 +356,9 @@ external const_extractvalue : llvalue -> int array -> llvalue
                             = "llvm_const_extractvalue"
 external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
                            = "llvm_const_insertvalue"
+external const_inline_asm : lltype -> string -> string -> bool -> bool ->
+                            llvalue
+                          = "llvm_const_inline_asm"
 external block_address : llvalue -> llbasicblock -> llvalue = "LLVMBlockAddress"
 
 (*--... Operations on global variables, functions, and aliases (globals) ...--*)
index 9f919809433c56a321cf0ecd5f585eec5684c0ad..c8c48f3c5376dfc42d984babc6eaf938b527ff7d 100644 (file)
@@ -964,6 +964,12 @@ external const_extractvalue : llvalue -> int array -> llvalue
 external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
                            = "llvm_const_insertvalue"
 
+(** [const_inline_asm ty asm con side align] inserts a inline assembly string.
+    See the method [llvm::InlineAsm::get]. *)
+external const_inline_asm : lltype -> string -> string -> bool -> bool ->
+                            llvalue
+                          = "llvm_const_inline_asm"
+
 (** [block_address f bb] returns the address of the basic block [bb] in the
     function [f]. See the method [llvm::BasicBlock::get]. *)
 external block_address : llvalue -> llbasicblock -> llvalue = "LLVMBlockAddress"
index b06f6889043c862e9665449db0d4d93f43160ba7..000db05449485295e6aa7a63d7fecdba19e6d815 100644 (file)
@@ -641,6 +641,14 @@ CAMLprim LLVMValueRef llvm_const_insertvalue(LLVMValueRef Aggregate,
   CAMLreturnT(LLVMValueRef, result);
 }
 
+/* lltype -> string -> string -> bool -> bool -> llvalue */
+CAMLprim LLVMValueRef llvm_const_inline_asm(LLVMTypeRef Ty, value Asm,
+                                     value Constraints, value HasSideEffects,
+                                     value IsAlignStack) {
+  return LLVMConstInlineAsm(Ty, String_val(Asm), String_val(Constraints),
+                            Bool_val(HasSideEffects), Bool_val(IsAlignStack));
+}
+
 /*--... Operations on global variables, functions, and aliases (globals) ...--*/
 
 /* llvalue -> bool */
index 44cdd84ac186e30c1fd37a48df11b4ed6ac4e292..40747f36111788d8b2d2287065fd2840c4bcc8f2 100644 (file)
@@ -456,7 +456,17 @@ let test_constants () =
   ignore (define_global "const_shufflevector" (const_shufflevector
     (const_vector [| zero; one |])
     (const_vector [| one; zero |])
-    (const_bitcast foldbomb (vector_type i32_type 2))) m)
+    (const_bitcast foldbomb (vector_type i32_type 2))) m);
+
+  group "asm"; begin
+    let ft = function_type void_type [| i32_type; i32_type; i32_type |] in
+    ignore (const_inline_asm
+      ft
+      ""
+      "{cx},{ax},{di},~{dirflag},~{fpsr},~{flags},~{edi},~{ecx}"
+      true
+      false)
+  end
 
 
 (*===-- Global Values -----------------------------------------------------===*)