[LANGUAGE] Added cos/sin (#132)

This commit is contained in:
Philippe Tillet
2021-07-14 17:16:48 -07:00
committed by Philippe Tillet
parent 3169e4355c
commit 2824345065
13 changed files with 135 additions and 2 deletions

View File

@@ -337,6 +337,14 @@ value *builder::create_exp(value *arg){
return insert(exp_inst::create(arg));
}
value *builder::create_cos(value *arg){
return insert(cos_inst::create(arg));
}
value *builder::create_sin(value *arg){
return insert(sin_inst::create(arg));
}
value *builder::create_log(value *arg){
return insert(log_inst::create(arg));
}

View File

@@ -688,6 +688,14 @@ ir::value *dispatch::log(ir::value *x, ir::builder *builder) {
return builder->create_log(x);
}
ir::value *dispatch::cos(ir::value *x, ir::builder *builder) {
return builder->create_cos(x);
}
ir::value *dispatch::sin(ir::value *x, ir::builder *builder) {
return builder->create_sin(x);
}
ir::value *dispatch::sqrt(ir::value *x, ir::builder *builder) {
return builder->create_sqrt(x);
}

View File

@@ -781,6 +781,27 @@ instruction* exp_inst::create(value *val, const std::string& name, instruction *
return new exp_inst(val, name, next);
}
// cos
cos_inst::cos_inst(value *val, const std::string &name, instruction *next)
: builtin_inst(val->get_type(), INST_COS, 1, name, next) {
set_operand(0, val);
}
instruction* cos_inst::create(value *val, const std::string& name, instruction *next) {
return new cos_inst(val, name, next);
}
// sin
sin_inst::sin_inst(value *val, const std::string &name, instruction *next)
: builtin_inst(val->get_type(), INST_SIN, 1, name, next) {
set_operand(0, val);
}
instruction* sin_inst::create(value *val, const std::string& name, instruction *next) {
return new sin_inst(val, name, next);
}
// log
log_inst::log_inst(value *val, const std::string &name, instruction *next)