mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-30 16:17:05 +00:00 
			
		
		
		
	Adding an uninitialized builder constructor to the Ocaml bindings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45362 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -327,6 +327,8 @@ external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming" | |||||||
|  |  | ||||||
|  |  | ||||||
| (*===-- Instruction builders ----------------------------------------------===*) | (*===-- Instruction builders ----------------------------------------------===*) | ||||||
|  | external builder: unit-> llbuilder | ||||||
|  |                 = "llvm_builder" | ||||||
| external builder_before : llvalue -> llbuilder = "llvm_builder_before" | external builder_before : llvalue -> llbuilder = "llvm_builder_before" | ||||||
| external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end" | external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end" | ||||||
| external position_before : llvalue -> llbuilder -> unit = "llvm_position_before" | external position_before : llvalue -> llbuilder -> unit = "llvm_position_before" | ||||||
|   | |||||||
| @@ -847,6 +847,12 @@ external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming" | |||||||
|  |  | ||||||
| (*===-- Instruction builders ----------------------------------------------===*) | (*===-- Instruction builders ----------------------------------------------===*) | ||||||
|  |  | ||||||
|  | (** [builder] creates an instruction builder with no position. It is invalid to | ||||||
|  |     use this builder until its position is set with [position_before] or | ||||||
|  |     [position_at_end]. See the constructor for [llvm::LLVMBuilder]. **) | ||||||
|  | external builder: unit-> llbuilder | ||||||
|  |                 = "llvm_builder" | ||||||
|  |  | ||||||
| (** [builder_before ins] creates an instruction builder positioned before the | (** [builder_before ins] creates an instruction builder positioned before the | ||||||
|     instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **) |     instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **) | ||||||
| external builder_before : llvalue -> llbuilder = "llvm_builder_before" | external builder_before : llvalue -> llbuilder = "llvm_builder_before" | ||||||
|   | |||||||
| @@ -668,7 +668,7 @@ CAMLprim value llvm_incoming(LLVMValueRef PhiNode) { | |||||||
|  |  | ||||||
| #define Builder_val(v)  (*(LLVMBuilderRef *)(Data_custom_val(v))) | #define Builder_val(v)  (*(LLVMBuilderRef *)(Data_custom_val(v))) | ||||||
|  |  | ||||||
| void llvm_finalize_builder(value B) { | static void llvm_finalize_builder(value B) { | ||||||
|   LLVMDisposeBuilder(Builder_val(B)); |   LLVMDisposeBuilder(Builder_val(B)); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -681,24 +681,29 @@ static struct custom_operations builder_ops = { | |||||||
|   custom_deserialize_default |   custom_deserialize_default | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* llvalue -> llbuilder */ | static value alloc_builder(LLVMBuilderRef B) { | ||||||
| CAMLprim value llvm_builder_before(LLVMValueRef Inst) { |   value V = alloc_custom(&builder_ops, sizeof(LLVMBuilderRef), 0, 1); | ||||||
|   value V; |  | ||||||
|   LLVMBuilderRef B = LLVMCreateBuilder(); |  | ||||||
|   LLVMPositionBuilderBefore(B, Inst); |  | ||||||
|   V = alloc_custom(&builder_ops, sizeof(LLVMBuilderRef), 0, 1); |  | ||||||
|   Builder_val(V) = B; |   Builder_val(V) = B; | ||||||
|   return V; |   return V; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* unit-> llbuilder */ | ||||||
|  | CAMLprim value llvm_builder(value Unit) { | ||||||
|  |   return alloc_builder(LLVMCreateBuilder()); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* llvalue -> llbuilder */ | ||||||
|  | CAMLprim value llvm_builder_before(LLVMValueRef Inst) { | ||||||
|  |   LLVMBuilderRef B = LLVMCreateBuilder(); | ||||||
|  |   LLVMPositionBuilderBefore(B, Inst); | ||||||
|  |   return alloc_builder(B); | ||||||
|  | } | ||||||
|  |  | ||||||
| /* llbasicblock -> llbuilder */ | /* llbasicblock -> llbuilder */ | ||||||
| CAMLprim value llvm_builder_at_end(LLVMBasicBlockRef BB) { | CAMLprim value llvm_builder_at_end(LLVMBasicBlockRef BB) { | ||||||
|   value V; |  | ||||||
|   LLVMBuilderRef B = LLVMCreateBuilder(); |   LLVMBuilderRef B = LLVMCreateBuilder(); | ||||||
|   LLVMPositionBuilderAtEnd(B, BB); |   LLVMPositionBuilderAtEnd(B, BB); | ||||||
|   V = alloc_custom(&builder_ops, sizeof(LLVMBuilderRef), 0, 1); |   return alloc_builder(B); | ||||||
|   Builder_val(V) = B; |  | ||||||
|   return V; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| /* llvalue -> llbuilder -> unit */ | /* llvalue -> llbuilder -> unit */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user