[OCaml] Add missing TypeKinds, Opcode, and AtomicRMWBinOps

There are several enum values that have been added to LLVM-C that are
missing from the OCaml bindings. The types defined in
bindings/ocaml/llvm/llvm.ml should be in sync with the corresponding
enum definitions in include/llvm-c/Core.h. The enum values are passed
from C to OCaml unmodified, and clients of the OCaml bindings
interpret them as tags of the corresponding OCaml types. So the only
changes needed are to add the missing constructors to the type
definitions, and to change the name of the maximum opcode in an
assertion.

Differential Revision: https://reviews.llvm.org/D98578
This commit is contained in:
Josh Berdine 2021-03-12 22:50:21 +00:00
parent ff2dd8a212
commit ece6d8e72e
3 changed files with 13 additions and 1 deletions

View File

@ -42,6 +42,9 @@ module TypeKind = struct
| Metadata | Metadata
| X86_mmx | X86_mmx
| Token | Token
| ScalableVector
| BFloat
| X86_amx
end end
module Linkage = struct module Linkage = struct
@ -246,6 +249,7 @@ module Opcode = struct
| CatchSwitch | CatchSwitch
| FNeg | FNeg
| CallBr | CallBr
| Freeze
end end
module LandingPadClauseTy = struct module LandingPadClauseTy = struct
@ -288,6 +292,8 @@ module AtomicRMWBinOp = struct
| Min | Min
| UMax | UMax
| UMin | UMin
| FAdd
| FSub
end end
module ValueKind = struct module ValueKind = struct

View File

@ -77,6 +77,9 @@ module TypeKind : sig
| Metadata | Metadata
| X86_mmx | X86_mmx
| Token | Token
| ScalableVector
| BFloat
| X86_amx
end end
(** The linkage of a global value, accessed with {!linkage} and (** The linkage of a global value, accessed with {!linkage} and
@ -268,6 +271,7 @@ module Opcode : sig
| CatchSwitch | CatchSwitch
| FNeg | FNeg
| CallBr | CallBr
| Freeze
end end
(** The type of a clause of a [landingpad] instruction. (** The type of a clause of a [landingpad] instruction.
@ -319,6 +323,8 @@ module AtomicRMWBinOp : sig
| Min | Min
| UMax | UMax
| UMin | UMin
| FAdd
| FSub
end end
(** The kind of an [llvalue], the result of [classify_value v]. (** The kind of an [llvalue], the result of [classify_value v].

View File

@ -1541,7 +1541,7 @@ CAMLprim value llvm_instr_get_opcode(LLVMValueRef Inst) {
if (!LLVMIsAInstruction(Inst)) if (!LLVMIsAInstruction(Inst))
failwith("Not an instruction"); failwith("Not an instruction");
o = LLVMGetInstructionOpcode(Inst); o = LLVMGetInstructionOpcode(Inst);
assert (o <= LLVMCallBr); assert(o <= LLVMFreeze);
return Val_int(o); return Val_int(o);
} }