Skip to content

Commit 5d8a6c0

Browse files
committed
[OCaml] Add missing bindings for x86_amx, token, and metadata types
1 parent db09014 commit 5d8a6c0

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

llvm/bindings/ocaml/llvm/llvm.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,9 @@ external vector_size : lltype -> int = "llvm_vector_size"
525525
(*--... Operations on other types ..........................................--*)
526526
external void_type : llcontext -> lltype = "llvm_void_type"
527527
external label_type : llcontext -> lltype = "llvm_label_type"
528+
external x86_amx_type : llcontext -> lltype = "llvm_x86_amx_type"
529+
external token_type : llcontext -> lltype = "llvm_token_type"
530+
external metadata_type : llcontext -> lltype = "llvm_metadata_type"
528531
external type_by_name : llmodule -> string -> lltype option = "llvm_type_by_name"
529532

530533
external classify_value : llvalue -> ValueKind.t = "llvm_classify_value"

llvm/bindings/ocaml/llvm/llvm.mli

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,18 @@ val void_type : llcontext -> lltype
766766
[llvm::Type::LabelTy]. *)
767767
val label_type : llcontext -> lltype
768768

769+
(** [x86_amx_type c] creates an X86 AMX type in the context [c]. See
770+
[llvm::Type::getX86_AMXTy]. *)
771+
val x86_amx_type : llcontext -> lltype
772+
773+
(** [token_type c] creates a token type in the context [c]. See
774+
[llvm::Type::getTokenTy]. *)
775+
val token_type : llcontext -> lltype
776+
777+
(** [metadata_type c] creates a metadata type in the context [c]. See
778+
[llvm::Type::getMetadataTy]. *)
779+
val metadata_type : llcontext -> lltype
780+
769781
(** [type_by_name m name] returns the specified type from the current module
770782
if it exists.
771783
See the method [llvm::Module::getTypeByName] *)

llvm/bindings/ocaml/llvm/llvm_ocaml.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,21 @@ value llvm_label_type(value Context) {
686686
return to_val(LLVMLabelTypeInContext(Context_val(Context)));
687687
}
688688

689+
/* llcontext -> lltype */
690+
value llvm_x86_amx_type(value Context) {
691+
return to_val(LLVMX86AMXTypeInContext(Context_val(Context)));
692+
}
693+
694+
/* llcontext -> lltype */
695+
value llvm_token_type(value Context) {
696+
return to_val(LLVMTokenTypeInContext(Context_val(Context)));
697+
}
698+
699+
/* llcontext -> lltype */
700+
value llvm_metadata_type(value Context) {
701+
return to_val(LLVMMetadataTypeInContext(Context_val(Context)));
702+
}
703+
689704
/* llmodule -> string -> lltype option */
690705
value llvm_type_by_name(value M, value Name) {
691706
return ptr_to_option(LLVMGetTypeByName(Module_val(M), String_val(Name)));

llvm/test/Bindings/OCaml/core.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ let test_pointer_types () =
5353
insist (0 = address_space (qualified_pointer_type context 0));
5454
insist (1 = address_space (qualified_pointer_type context 1))
5555

56+
(*===-- Other types ------------------------------------------------------===*)
57+
let test_other_types () =
58+
insist (TypeKind.Void = classify_type void_type);
59+
insist (TypeKind.Label = classify_type (label_type context));
60+
insist (TypeKind.X86_amx = classify_type (x86_amx_type context));
61+
insist (TypeKind.Token = classify_type (token_type context));
62+
insist (TypeKind.Metadata = classify_type (metadata_type context))
63+
5664
(*===-- Conversion --------------------------------------------------------===*)
5765

5866
let test_conversion () =
@@ -1461,6 +1469,7 @@ let _ =
14611469
suite "modules" test_modules;
14621470
suite "contained types" test_contained_types;
14631471
suite "pointer types" test_pointer_types;
1472+
suite "other types" test_other_types;
14641473
suite "conversion" test_conversion;
14651474
suite "target" test_target;
14661475
suite "constants" test_constants;

0 commit comments

Comments
 (0)