Skip to content

Commit 4c11f27

Browse files
committed
Removal of const mul
1 parent 0ec4619 commit 4c11f27

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

src/core/value/constant.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ register(ConstantVector, API.LLVMConstantVectorValueKind)
526526
export ConstantExpr,
527527

528528
const_neg, const_nswneg, const_nuwneg, const_not, const_add,
529-
const_nswadd, const_nuwadd, const_sub, const_nswsub, const_nuwsub, const_mul,
530-
const_nswmul, const_nuwmul, const_xor,
529+
const_nswadd, const_nuwadd, const_sub, const_nswsub, const_nuwsub, const_xor,
531530
const_gep, const_inbounds_gep, const_trunc,
532531
const_ptrtoint, const_inttoptr, const_bitcast,
533532
const_addrspacecast, const_truncorbitcast,
@@ -578,15 +577,6 @@ const_nswsub(lhs::Constant, rhs::Constant) =
578577
const_nuwsub(lhs::Constant, rhs::Constant) =
579578
Value(API.LLVMConstNUWSub(lhs, rhs))
580579

581-
const_mul(lhs::Constant, rhs::Constant) =
582-
Value(API.LLVMConstMul(lhs, rhs))
583-
584-
const_nswmul(lhs::Constant, rhs::Constant) =
585-
Value(API.LLVMConstNSWMul(lhs, rhs))
586-
587-
const_nuwmul(lhs::Constant, rhs::Constant) =
588-
Value(API.LLVMConstNUWMul(lhs, rhs))
589-
590580
const_xor(lhs::Constant, rhs::Constant) =
591581
Value(API.LLVMConstXor(lhs, rhs))
592582

@@ -709,6 +699,21 @@ const_shl(lhs::Constant, rhs::Constant) =
709699

710700
end
711701

702+
if version() < v"21"
703+
704+
export const_mul, const_nswmul, const_nuwmul
705+
706+
const_mul(lhs::Constant, rhs::Constant) =
707+
Value(API.LLVMConstMul(lhs, rhs))
708+
709+
const_nswmul(lhs::Constant, rhs::Constant) =
710+
Value(API.LLVMConstNSWMul(lhs, rhs))
711+
712+
const_nuwmul(lhs::Constant, rhs::Constant) =
713+
Value(API.LLVMConstNUWMul(lhs, rhs))
714+
715+
end
716+
712717
# TODO: alignof, sizeof, block_address
713718

714719

test/core.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,11 @@ end
607607
@check_ir ce "i32 40"
608608
end
609609

610-
for f in [const_mul, const_nswmul, const_nuwmul]
611-
ce = f(val, other_val)::LLVM.Constant
612-
@check_ir ce "i32 84"
610+
if LLVM.version() < v"21"
611+
for f in [const_mul, const_nswmul, const_nuwmul]
612+
ce = f(val, other_val)::LLVM.Constant
613+
@check_ir ce "i32 84"
614+
end
613615
end
614616

615617
ce = const_xor(val, other_val)::LLVM.Constant

test/instructions.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@
147147
ptr = parameters(fn)[6]
148148

149149
array_mallocinst = array_malloc!(builder, LLVM.Int8Type(), ConstantInt(Int32(42)))
150-
if supports_typed_pointers(ctx)
150+
if LLVM.version() >= v"21"
151+
@check_ir array_mallocinst r"call ptr @malloc\(.+\)"
152+
elseif supports_typed_pointers(ctx)
151153
@check_ir array_mallocinst r"call i8\* @malloc\(.+, i32 42\)"
152154
else
153155
@check_ir array_mallocinst r"call ptr @malloc\(.+, i32 42\)"

0 commit comments

Comments
 (0)