Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lang::Sema Struct Reference

#include <sema.h>

Collaboration diagram for lang::Sema:

Public Member Functions

TreeRef typeOfExpr (TreeRef ref)
 
TreeRef withType (TreeRef expr, TreeRef type)
 
TensorType expectTensorType (TreeRef loc, TreeRef typ)
 
TreeRef matchAllTypes (TreeRef list, TreeRef matched_type=nullptr)
 
TreeRef expectIntegral (TreeRef e)
 
void expectBool (TreeRef anchor, int token)
 
TreeRef expectBool (TreeRef exp)
 
TreeRef lookupVarOrCreateIndex (Ident ident)
 
TreeRef checkExp (TreeRef exp, bool allow_access)
 
TreeRef checkFunction (TreeRef func_)
 
TreeRef indexType (TreeRef anchor)
 
TreeRef dimType (TreeRef anchor)
 
TreeRef floatType (TreeRef anchor)
 
TreeRef boolType (TreeRef anchor)
 
void checkDim (Ident dim)
 
TreeRef checkTensorType (TreeRef type)
 
TreeRef checkParam (TreeRef param)
 
TreeRef checkReturn (TreeRef ret)
 
TreeRef checkList (TreeRef list, std::function< TreeRef(TreeRef)> fn)
 
TreeRef checkRangeConstraint (RangeConstraint rc)
 
TreeRef checkLet (Let l)
 
TreeRef checkWhereClause (TreeRef ref)
 
TreeRef checkStmt (TreeRef stmt_)
 
bool isNotInplace (TreeRef assignment)
 
std::string dumpEnv ()
 

Public Attributes

std::unordered_map< TreeRef,
TreeRef
expr_to_type
 

Private Types

using Env = std::unordered_map< std::string, TreeRef >
 

Private Member Functions

void insert (Env &the_env, Ident ident, TreeRef value, bool must_be_undefined)
 
TreeRef lookup (Ident ident, bool required)
 
TreeRef lookup (Env &the_env, Ident ident, bool required)
 
TreeRef c (int kind, const SourceRange &range, TreeList &&trees)
 
TreeRef s (const std::string &s)
 

Private Attributes

std::vector< TreeRefreduction_variables
 
Env index_env
 
Env let_env
 
Env env
 
Env annotated_output_types
 
std::unordered_set< std::string > live_input_names
 
std::unordered_set< std::string > nonTemporaries
 

Detailed Description

Semantic analysis transforms the raw AST into a typed and semantically correct tree. Currently it:

  • replaces TK_APPLY with TK_ACCESS nodes for tensor reads
  • replace TK_APPLY with TK_BUILT_IN for built in functions
  • checks that all variables are defined, and creates index/reduction variable objects.

Member Typedef Documentation

using lang::Sema::Env = std::unordered_map<std::string, TreeRef>
private

Member Function Documentation

TreeRef lang::Sema::boolType ( TreeRef  anchor)
inline
TreeRef lang::Sema::c ( int  kind,
const SourceRange range,
TreeList &&  trees 
)
inlineprivate
void lang::Sema::checkDim ( Ident  dim)
inline
TreeRef lang::Sema::checkExp ( TreeRef  exp,
bool  allow_access 
)
inline
TreeRef lang::Sema::checkFunction ( TreeRef  func_)
inline
TreeRef lang::Sema::checkLet ( Let  l)
inline
TreeRef lang::Sema::checkList ( TreeRef  list,
std::function< TreeRef(TreeRef)>  fn 
)
inline
TreeRef lang::Sema::checkParam ( TreeRef  param)
inline
TreeRef lang::Sema::checkRangeConstraint ( RangeConstraint  rc)
inline
TreeRef lang::Sema::checkReturn ( TreeRef  ret)
inline
TreeRef lang::Sema::checkStmt ( TreeRef  stmt_)
inline
TreeRef lang::Sema::checkTensorType ( TreeRef  type)
inline
TreeRef lang::Sema::checkWhereClause ( TreeRef  ref)
inline
TreeRef lang::Sema::dimType ( TreeRef  anchor)
inline
std::string lang::Sema::dumpEnv ( )
inline
void lang::Sema::expectBool ( TreeRef  anchor,
int  token 
)
inline
TreeRef lang::Sema::expectBool ( TreeRef  exp)
inline
TreeRef lang::Sema::expectIntegral ( TreeRef  e)
inline
TensorType lang::Sema::expectTensorType ( TreeRef  loc,
TreeRef  typ 
)
inline
TreeRef lang::Sema::floatType ( TreeRef  anchor)
inline
TreeRef lang::Sema::indexType ( TreeRef  anchor)
inline
void lang::Sema::insert ( Env the_env,
Ident  ident,
TreeRef  value,
bool  must_be_undefined 
)
inlineprivate
bool lang::Sema::isNotInplace ( TreeRef  assignment)
inline
TreeRef lang::Sema::lookup ( Ident  ident,
bool  required 
)
inlineprivate
TreeRef lang::Sema::lookup ( Env the_env,
Ident  ident,
bool  required 
)
inlineprivate
TreeRef lang::Sema::lookupVarOrCreateIndex ( Ident  ident)
inline
TreeRef lang::Sema::matchAllTypes ( TreeRef  list,
TreeRef  matched_type = nullptr 
)
inline
TreeRef lang::Sema::s ( const std::string &  s)
inlineprivate
TreeRef lang::Sema::typeOfExpr ( TreeRef  ref)
inline
TreeRef lang::Sema::withType ( TreeRef  expr,
TreeRef  type 
)
inline

Member Data Documentation

Env lang::Sema::annotated_output_types
private
Env lang::Sema::env
private
std::unordered_map<TreeRef, TreeRef> lang::Sema::expr_to_type
Env lang::Sema::index_env
private
Env lang::Sema::let_env
private
std::unordered_set<std::string> lang::Sema::live_input_names
private
std::unordered_set<std::string> lang::Sema::nonTemporaries
private
std::vector<TreeRef> lang::Sema::reduction_variables
private

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