Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] LLVM support for Relationals #1282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions symengine/llvm_double.cpp
Expand Up @@ -384,6 +384,54 @@ void LLVMDoubleVisitor::bvisit(const Log &x)
result_ = r;
}

void LLVMDoubleVisitor::bvisit(const Equality &x)
{
std::vector<llvm::Value *> args;
llvm::Function *fun;
args.push_back(apply(*x.get_arg1()));
args.push_back(apply(*x.get_arg2()));
fun = get_double_intrinsic(llvm::Intrinsic::equal_to, 2, mod);
auto r = builder->CreateCall(fun, args);
r->setTailCall(true);
result_ = r;
}

void LLVMDoubleVisitor::bvisit(const Unequality &x)
{
std::vector<llvm::Value *> args;
llvm::Function *fun;
args.push_back(apply(*x.get_arg1()));
args.push_back(apply(*x.get_arg2()));
fun = get_double_intrinsic(llvm::Intrinsic::not_equal_to, 2, mod);
auto r = builder->CreateCall(fun, args);
r->setTailCall(true);
result_ = r;
}

void LLVMDoubleVisitor::bvisit(const LessThan &x)
{
std::vector<llvm::Value *> args;
llvm::Function *fun;
args.push_back(apply(*x.get_arg1()));
args.push_back(apply(*x.get_arg2()));
fun = get_double_intrinsic(llvm::Intrinsic::less_equal, 2, mod);
auto r = builder->CreateCall(fun, args);
r->setTailCall(true);
result_ = r;
}

void LLVMDoubleVisitor::bvisit(const StrictLessThan &x)
{
std::vector<llvm::Value *> args;
llvm::Function *fun;
args.push_back(apply(*x.get_arg1()));
args.push_back(apply(*x.get_arg2()));
fun = get_double_intrinsic(llvm::Intrinsic::less, 2, mod);
auto r = builder->CreateCall(fun, args);
r->setTailCall(true);
result_ = r;
}

#define ONE_ARG_EXTERNAL_FUNCTION(Class, ext) \
void LLVMDoubleVisitor::bvisit(const Class &x) \
{ \
Expand Down
4 changes: 4 additions & 0 deletions symengine/llvm_double.h
Expand Up @@ -72,6 +72,10 @@ class LLVMDoubleVisitor : public BaseVisitor<LLVMDoubleVisitor>
void bvisit(const ATanh &x);
void bvisit(const Gamma &x);
void bvisit(const LogGamma &x);
void bvisit(const Equality &x);
void bvisit(const Unequality &x);
void bvisit(const LessThan &x);
void bvisit(const StrictLessThan &x);
void bvisit(const Erf &x);
void bvisit(const Erfc &x);
};
Expand Down