[FRONTEND] Added support for element-wise function defined in external LLVM bitcode (e.g., libdevice) (#562)
This commit is contained in:
@@ -379,6 +379,19 @@ value *builder::create_globaltimer() {
|
||||
return insert(globaltimer_inst::create(ctx_));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// externs
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
value *builder::create_extern_elementwise(const std::string &lib_name,
|
||||
const std::string &lib_path,
|
||||
const std::string &symbol_name,
|
||||
const std::vector<value *> &args,
|
||||
type *ret_ty) {
|
||||
return insert(extern_elementwise_inst::create(ctx_, args, ret_ty, lib_name,
|
||||
lib_path, symbol_name));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// built-in instructions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@@ -988,6 +988,28 @@ globaltimer_inst* globaltimer_inst::create(context &ctx, const std::string &name
|
||||
return new globaltimer_inst(ctx, name, next);
|
||||
}
|
||||
|
||||
// extern elementwise
|
||||
extern_elementwise_inst::extern_elementwise_inst(
|
||||
context &ctx, const std::vector<value *> &args, type *ret_ty,
|
||||
const std::string &lib_name, const std::string &lib_path,
|
||||
const std::string &symbol_name, instruction *next)
|
||||
: instruction(ret_ty, INST_EXTERN_ELEMENTWISE, args.size(), symbol_name,
|
||||
next),
|
||||
lib_name_(lib_name),
|
||||
lib_path_(lib_path) {
|
||||
for (size_t i = 0; i < args.size(); i++) {
|
||||
set_operand(i, args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
extern_elementwise_inst *extern_elementwise_inst::create(
|
||||
context &ctx, const std::vector<value *> &args, type *ret_ty,
|
||||
const std::string &lib_name, const std::string &lib_path,
|
||||
const std::string &symbol_name, instruction *next) {
|
||||
return new extern_elementwise_inst(ctx, args, ret_ty, lib_name, lib_path,
|
||||
symbol_name, next);
|
||||
}
|
||||
|
||||
// clock
|
||||
clock_inst::clock_inst(context &ctx, const std::string &name, instruction *next)
|
||||
: instruction(type::get_int64_ty(ctx), INST_CLOCK, 0, name, next) { }
|
||||
|
Reference in New Issue
Block a user