Skip to content

Commit 121a4eb

Browse files
authored
Simplify and test instruction predicate getter. (#473)
1 parent 8e5ea03 commit 121a4eb

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/core/instructions.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export Instruction, remove!, erase!, parent,
2-
opcode,
3-
predicate_int, predicate_real
2+
opcode
43

54
# forward definition of Instruction in src/core/value/constant.jl
65
register(Instruction, API.LLVMInstructionValueKind)
@@ -76,9 +75,11 @@ end
7675

7776
## comparisons
7877

79-
predicate_int(inst::ICmpInst) = API.LLVMGetICmpPredicate(inst)
78+
export predicate
8079

81-
predicate_real(inst::FCmpInst) = API.LLVMGetFCmpPredicate(inst)
80+
predicate(inst::ICmpInst) = API.LLVMGetICmpPredicate(inst)
81+
82+
predicate(inst::FCmpInst) = API.LLVMGetFCmpPredicate(inst)
8283

8384

8485
## atomics

src/deprecated.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Base.@deprecate_binding ValueMetadataDict LLVM.InstructionMetadataDict
3636
@deprecate unsafe_delete!(::Function, bb::BasicBlock) erase!(bb)
3737
@deprecate unsafe_delete!(::BasicBlock, inst::Instruction) erase!(inst)
3838

39+
@deprecate predicate_int(inst) predicate(inst)
40+
@deprecate predicate_real(inst) predicate(inst)
41+
3942
@deprecate Base.string(md::MDString) convert(String, md) false
4043
function Base.show(io::IO, ::MIME"text/plain", md::MDString)
4144
str = @invoke string(md::Metadata)

test/instructions_tests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,11 @@
351351

352352
icmpinst = icmp!(builder, LLVM.API.LLVMIntEQ, int1, int2)
353353
@check_ir icmpinst "icmp eq i32 %0, %1"
354+
@test predicate(icmpinst) == LLVM.API.LLVMIntEQ
354355

355356
fcmpinst = fcmp!(builder, LLVM.API.LLVMRealOEQ, float1, float2)
356357
@check_ir fcmpinst "fcmp oeq float %2, %3"
358+
@test predicate(fcmpinst) == LLVM.API.LLVMRealOEQ
357359

358360
phiinst = phi!(builder, LLVM.Int32Type())
359361
@check_ir phiinst "phi i32 "

0 commit comments

Comments
 (0)