[OCaml] Fix bindings after br -> uncondbr+condbr split (#186176)

Update opcode lists after
https://github.com/llvm/llvm-project/pull/184027.
This commit is contained in:
Nikita Popov 2026-03-13 12:11:07 +01:00 committed by GitHub
parent 8d61e15675
commit 48c7004986
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View File

@ -180,7 +180,7 @@ module Opcode = struct
| Invalid (* not an instruction *)
(* Terminator Instructions *)
| Ret
| Br
| Invalid3
| Switch
| IndirectBr
| Invoke
@ -252,6 +252,9 @@ module Opcode = struct
| FNeg
| CallBr
| Freeze
| PtrToAddr
| UncondBr
| CondBr
end
module LandingPadClauseTy = struct
@ -1089,7 +1092,7 @@ let is_terminator llv =
let open ValueKind in
let open Opcode in
match classify_value llv with
| Instruction (Br | IndirectBr | Invoke | Resume | Ret | Switch | Unreachable)
| Instruction (UncondBr | CondBr | IndirectBr | Invoke | Resume | Ret | Switch | Unreachable)
-> true
| _ -> false
@ -1133,12 +1136,13 @@ external set_condition : llvalue -> llvalue -> unit
external is_conditional : llvalue -> bool = "llvm_is_conditional"
let get_branch llv =
if classify_value llv <> ValueKind.Instruction Opcode.Br then
None
else if is_conditional llv then
let kind = classify_value llv in
if kind = ValueKind.Instruction Opcode.UncondBr then
Some (`Unconditional (successor llv 0))
else if kind = ValueKind.Instruction Opcode.CondBr then
Some (`Conditional (condition llv, successor llv 0, successor llv 1))
else
Some (`Unconditional (successor llv 0))
None
(*--... Operations on phi nodes ............................................--*)
external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit

View File

@ -206,7 +206,7 @@ module Opcode : sig
| Invalid (** Not an instruction *)
| Ret (** Terminator Instructions *)
| Br
| Invalid3
| Switch
| IndirectBr
| Invoke
@ -278,6 +278,9 @@ module Opcode : sig
| FNeg
| CallBr
| Freeze
| PtrToAddr
| UncondBr
| CondBr
end
(** The type of a clause of a [landingpad] instruction.