Skip to content

Commit

Permalink
Update CodeGen_LLVM.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-johnson committed Oct 18, 2024
1 parent 56d6817 commit fa8b92e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,11 @@ void CodeGen_LLVM::visit(const Call *op) {
internal_assert(op->args.size() == 1);
std::vector<llvm::Type *> arg_type(1);
arg_type[0] = llvm_type_of(op->args[0].type());
#if LLVM_VERSION >= 200
llvm::Function *fn = llvm::Intrinsic::getOrInsertDeclaration(module.get(), llvm::Intrinsic::ctpop, arg_type);
#else
llvm::Function *fn = llvm::Intrinsic::getDeclaration(module.get(), llvm::Intrinsic::ctpop, arg_type);
#endif
Value *a = codegen(op->args[0]);
CallInst *call = builder->CreateCall(fn, a);
value = call;
Expand All @@ -2787,9 +2791,15 @@ void CodeGen_LLVM::visit(const Call *op) {
internal_assert(op->args.size() == 1);
std::vector<llvm::Type *> arg_type(1);
arg_type[0] = llvm_type_of(op->args[0].type());
#if LLVM_VERSION >= 200
llvm::Function *fn = llvm::Intrinsic::getOrInsertDeclaration(module.get(),
(op->is_intrinsic(Call::count_leading_zeros)) ? llvm::Intrinsic::ctlz : llvm::Intrinsic::cttz,
arg_type);
#else
llvm::Function *fn = llvm::Intrinsic::getDeclaration(module.get(),
(op->is_intrinsic(Call::count_leading_zeros)) ? llvm::Intrinsic::ctlz : llvm::Intrinsic::cttz,
arg_type);
#endif
llvm::Value *is_const_zero_poison = llvm::ConstantInt::getFalse(*context);
llvm::Value *args[2] = {codegen(op->args[0]), is_const_zero_poison};
CallInst *call = builder->CreateCall(fn, args);
Expand Down

0 comments on commit fa8b92e

Please sign in to comment.