ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnc::ArtifactFactory Class Reference

Factory for some kinds of frequently used artifact DOM objects. More...

#include <ArtifactModel.h>

Static Public Member Functions

static std::shared_ptr< ArtifactIdid (const std::string &name)
 
static std::shared_ptr< ArtifactLiterallit (const std::string &name)
 
static std::shared_ptr< ArtifactVariablevar (const std::string &type_name, const std::string &var_name, const std::list< std::shared_ptr< ArtifactExpr > > &dimensions={}, const std::list< std::shared_ptr< ArtifactExpr > > &initializers={})
 Creates a new variable and place it to the block.
 
static std::shared_ptr< ArtifactRefref (std::shared_ptr< ArtifactExpr > ref)
 Creates a 'reference' (like C/C++ '&' address operator do) to the expression.
 
static std::shared_ptr< ArtifactDerefderef (std::shared_ptr< ArtifactExpr > ref)
 Creates a 'dereference' (like C/C++ '*' dereference operator do) of the expression.
 
static std::shared_ptr< ArtifactFunctionCallcall (const std::string &func_name, const std::list< std::shared_ptr< ArtifactExpr > > &param_list, std::shared_ptr< ArtifactExpr > on=nullptr, ArtifactCallType call_type=ArtifactCallType::obj)
 Creates a function call.
 
static std::shared_ptr< ArtifactUnaryExprun (ArtifactUnOp op, std::shared_ptr< ArtifactExpr > expr)
 Creates an unary operation expression.
 
static std::shared_ptr< ArtifactBinaryExprbin (ArtifactBinOp op, std::shared_ptr< ArtifactExpr > left, std::shared_ptr< ArtifactExpr > right)
 Creates a binary operation expression.
 
static std::shared_ptr< ArtifactIndexind (std::shared_ptr< ArtifactExpr > expr, std::shared_ptr< ArtifactExpr > ind)
 Creates an array element accessor expression (like C/C++ array[i]).
 
static std::shared_ptr< ArtifactUnaryExprheapNew (std::shared_ptr< ArtifactExpr > expr)
 Creates a heap new operation expression.
 
static std::shared_ptr< ArtifactUnaryExprheapFree (std::shared_ptr< ArtifactExpr > expr)
 Creates a heap free operation expression.
 

Detailed Description

Factory for some kinds of frequently used artifact DOM objects.

Definition at line 734 of file ArtifactModel.h.

Member Function Documentation

◆ bin()

static std::shared_ptr< ArtifactBinaryExpr > nnc::ArtifactFactory::bin ( ArtifactBinOp  op,
std::shared_ptr< ArtifactExpr left,
std::shared_ptr< ArtifactExpr right 
)
inlinestatic

Creates a binary operation expression.

Parameters
op
left
right
Returns

Definition at line 819 of file ArtifactModel.h.

820 {
821 return std::make_shared<ArtifactBinaryExpr>(op, left, right);
822 }

Referenced by TEST(), and TEST().

◆ call()

static std::shared_ptr< ArtifactFunctionCall > nnc::ArtifactFactory::call ( const std::string &  func_name,
const std::list< std::shared_ptr< ArtifactExpr > > &  param_list,
std::shared_ptr< ArtifactExpr on = nullptr,
ArtifactCallType  call_type = ArtifactCallType::obj 
)
inlinestatic

Creates a function call.

Parameters
func_name- the function name.
param_list- the parameters which are used for the call.
call_on- optional object on which the function is called (if it is a member function).
call_type- (for member functions only) call through: '.', '->', or '::'.
Returns

Definition at line 793 of file ArtifactModel.h.

796 {
797 return std::make_shared<ArtifactFunctionCall>(func_name, param_list, on, call_type);
798 }

Referenced by nnc::AclCppOpGenerator::generate(), and TEST().

◆ deref()

static std::shared_ptr< ArtifactDeref > nnc::ArtifactFactory::deref ( std::shared_ptr< ArtifactExpr ref)
inlinestatic

Creates a 'dereference' (like C/C++ '*' dereference operator do) of the expression.

Parameters
ref
Returns

Definition at line 779 of file ArtifactModel.h.

780 {
781 return std::make_shared<ArtifactDeref>(ref);
782 }

References nnc::ref.

Referenced by TEST().

◆ heapFree()

static std::shared_ptr< ArtifactUnaryExpr > nnc::ArtifactFactory::heapFree ( std::shared_ptr< ArtifactExpr expr)
inlinestatic

Creates a heap free operation expression.

Parameters
expr
Returns

Definition at line 851 of file ArtifactModel.h.

852 {
853 return std::make_shared<ArtifactUnaryExpr>(ArtifactUnOp::heapFree, expr);
854 }

References nnc::heapFree.

◆ heapNew()

static std::shared_ptr< ArtifactUnaryExpr > nnc::ArtifactFactory::heapNew ( std::shared_ptr< ArtifactExpr expr)
inlinestatic

Creates a heap new operation expression.

Parameters
expr
Returns

Definition at line 841 of file ArtifactModel.h.

842 {
843 return std::make_shared<ArtifactUnaryExpr>(ArtifactUnOp::heapNew, expr);
844 }

References nnc::heapNew.

◆ id()

static std::shared_ptr< ArtifactId > nnc::ArtifactFactory::id ( const std::string &  name)
inlinestatic

Definition at line 737 of file ArtifactModel.h.

738 {
739 return std::make_shared<ArtifactId>(name);
740 }

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and nnc::AclCppOpGenerator::visit().

◆ ind()

static std::shared_ptr< ArtifactIndex > nnc::ArtifactFactory::ind ( std::shared_ptr< ArtifactExpr expr,
std::shared_ptr< ArtifactExpr ind 
)
inlinestatic

Creates an array element accessor expression (like C/C++ array[i]).

Parameters
expr
ind
Returns

Definition at line 830 of file ArtifactModel.h.

832 {
833 return std::make_shared<ArtifactIndex>(expr, ind);
834 }
static std::shared_ptr< ArtifactIndex > ind(std::shared_ptr< ArtifactExpr > expr, std::shared_ptr< ArtifactExpr > ind)
Creates an array element accessor expression (like C/C++ array[i]).

References ind().

Referenced by ind(), and TEST().

◆ lit()

static std::shared_ptr< ArtifactLiteral > nnc::ArtifactFactory::lit ( const std::string &  name)
inlinestatic

Definition at line 742 of file ArtifactModel.h.

743 {
744 return std::make_shared<ArtifactLiteral>(name);
745 }

Referenced by nnc::AclCppOpGenerator::generate(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ ref()

static std::shared_ptr< ArtifactRef > nnc::ArtifactFactory::ref ( std::shared_ptr< ArtifactExpr ref)
inlinestatic

Creates a 'reference' (like C/C++ '&' address operator do) to the expression.

Parameters
ref
Returns

Definition at line 769 of file ArtifactModel.h.

770 {
771 return std::make_shared<ArtifactRef>(ref);
772 }

References nnc::ref.

Referenced by TEST(), and nnc::AclCppOpGenerator::visit().

◆ un()

static std::shared_ptr< ArtifactUnaryExpr > nnc::ArtifactFactory::un ( ArtifactUnOp  op,
std::shared_ptr< ArtifactExpr expr 
)
inlinestatic

Creates an unary operation expression.

Parameters
op
expr
Returns

Definition at line 806 of file ArtifactModel.h.

807 {
808 return std::make_shared<ArtifactUnaryExpr>(op, expr);
809 }

◆ var()

static std::shared_ptr< ArtifactVariable > nnc::ArtifactFactory::var ( const std::string &  type_name,
const std::string &  var_name,
const std::list< std::shared_ptr< ArtifactExpr > > &  dimensions = {},
const std::list< std::shared_ptr< ArtifactExpr > > &  initializers = {} 
)
inlinestatic

Creates a new variable and place it to the block.

Parameters
type_name- the variable type name.
var_name- the varibale name.
dimensions- optional dimensions, if the declared variable is an array.
initializer- optional variable initializer.
constructors- optional arguments of the object constructor, if instantiating a class.
Returns
- the newly created variable.

Definition at line 757 of file ArtifactModel.h.

758 {},
759 const std::list<std::shared_ptr<ArtifactExpr>> &initializers = {})
760 {
761 return std::make_shared<ArtifactVariable>(type_name, var_name, dimensions, initializers);
762 }

Referenced by TEST(), TEST(), TEST(), and TEST().


The documentation for this class was generated from the following file: