Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Mar 26, 2024
1 parent 8b52363 commit d4f0198
Show file tree
Hide file tree
Showing 77 changed files with 22,058 additions and 7,344 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -ex
python src/libasr/asdl_cpp.py src/lc/LC.asdl src/lc/ast.h
python src/libasr/asdl_cpp.py src/libasr/ASR.asdl src/libasr/asr.h
python src/libasr/wasm_instructions_visitor.py
python src/libasr/intrinsic_func_registry_util_gen.py

(cd src/lc/parser && re2c -W -b tokenizer.re -o tokenizer.cpp)
(cd src/lc/parser && bison -Wall -d -r all parser.yy)
Expand Down
2 changes: 1 addition & 1 deletion run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def single_test(test, verbose, no_llvm, skip_run_with_dbg, skip_cpptranslate, update_reference,
no_color, specific_backends=None, excluded_backends=None):
verify_hash, no_color, specific_backends=None, excluded_backends=None):
filename = test["filename"]
def is_included(backend):
return test.get(backend, False) \
Expand Down
50 changes: 25 additions & 25 deletions src/lc/clang_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
index.m_step = range_step.get();
array_section_indices.push_back(al, index);
} else if( is_all_called ) {
index.m_left = ASRUtils::get_bound<SemanticError>(array, i + 1, "lbound", al);
index.m_right = ASRUtils::get_bound<SemanticError>(array, i + 1, "ubound", al);
index.m_left = PassUtils::get_bound(array, i + 1, "lbound", al);
index.m_right = PassUtils::get_bound(array, i + 1, "ubound", al);
index.m_step = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, index.loc, 1,
ASRUtils::TYPE(ASR::make_Integer_t(al, index.loc, 4))));
array_section_indices.push_back(al, index);
Expand All @@ -1252,8 +1252,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
for( ; i < rank; i++ ) {
ASR::array_index_t index;
index.loc = array->base.loc;
index.m_left = ASRUtils::get_bound<SemanticError>(array, i + 1, "lbound", al);
index.m_right = ASRUtils::get_bound<SemanticError>(array, i + 1, "ubound", al);
index.m_left = PassUtils::get_bound(array, i + 1, "lbound", al);
index.m_right = PassUtils::get_bound(array, i + 1, "ubound", al);
index.m_step = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, index.loc, 1,
ASRUtils::TYPE(ASR::make_Integer_t(al, index.loc, 4))));
array_section_indices.push_back(al, index);
Expand Down Expand Up @@ -1432,8 +1432,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
args.p, args.size(), 0, ASRUtils::TYPE(ASR::make_Logical_t(
al, Lloc(x), 4)), nullptr);
} else if( sf == SpecialFunc::Exp ) {
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Exp),
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Exp),
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
} else if( sf == SpecialFunc::Pow ) {
if( args.size() != 2 ) {
Expand All @@ -1442,20 +1442,20 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit

CreateBinOp(args.p[0], args.p[1], ASR::binopType::Pow, Lloc(x));
} else if( sf == SpecialFunc::Sqrt ) {
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Sqrt),
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Sqrt),
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
} else if( sf == SpecialFunc::Abs ) {
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Abs),
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Abs),
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
} else if( sf == SpecialFunc::Sin ) {
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Sin),
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Sin),
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
} else if( sf == SpecialFunc::Cos ) {
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Cos),
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Cos),
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
} else if( sf == SpecialFunc::AMax ) {
if( args.size() > 1 && args.p[1] != nullptr ) {
Expand Down Expand Up @@ -1636,7 +1636,9 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
throw std::runtime_error("std::vector::reserve should be called with only one argument.");
}

tmp = ASR::make_ListReserve_t(al, Lloc(x), callee, args[0]);
tmp = ASR::make_Expr_t(al, Lloc(x), ASRUtils::EXPR(ASR::make_IntrinsicElementalFunction_t(al, Lloc(x),
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::ListReserve), args.p, args.size(), 0,
nullptr, nullptr)));
is_stmt_created = true;
} else {
throw std::runtime_error("Only printf and exit special functions supported");
Expand Down Expand Up @@ -1676,7 +1678,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
if( return_type == nullptr ) {
tmp = ASRUtils::make_SubroutineCall_t_util(al, Lloc(x), callee_sym,
callee_sym, call_args.p, call_args.size(), nullptr,
nullptr, false);
nullptr, false, false);
is_stmt_created = true;
} else {
tmp = ASRUtils::make_FunctionCall_t_util(al, Lloc(x), callee_sym,
Expand Down Expand Up @@ -2741,8 +2743,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
int lkind = ASRUtils::extract_kind_from_ttype_t(left_type);
int rkind = ASRUtils::extract_kind_from_ttype_t(right_type);
if( left_type->type != right_type->type || lkind != rkind ) {
throw SemanticError("Casting for mismatching pointer types not supported yet.",
right_type->base.loc);
throw std::runtime_error("Casting for mismatching pointer types not supported yet.");
}
}

Expand All @@ -2765,8 +2766,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
dest_type_right = ASRUtils::make_Array_t_util(al, dest_type->base.loc,
dest_type, m_dims, n_dims);
}
left = CastingUtil::perform_casting(left, left_type, dest_type_left, al, left->base.loc);
right = CastingUtil::perform_casting(right, right_type, dest_type_right, al, right->base.loc);
left = CastingUtil::perform_casting(left, dest_type_left, al, left->base.loc);
right = CastingUtil::perform_casting(right, dest_type_right, al, right->base.loc);
return ;
}

Expand All @@ -2779,8 +2780,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
return ;
}
src_expr = CastingUtil::perform_casting(
src_expr, src_type, dest_type, al,
src_expr->base.loc);
src_expr, dest_type, al, src_expr->base.loc);
if( casted_expression_signal == 0 ) {
left = src_expr;
right = dest_expr;
Expand Down Expand Up @@ -3070,7 +3070,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
TraverseStmt(loop_body);
current_body = current_body_copy;

tmp = ASR::make_WhileLoop_t(al, Lloc(x), nullptr, test, body.p, body.size());
tmp = ASR::make_WhileLoop_t(al, Lloc(x), nullptr, test, body.p, body.size(), nullptr, 0);
is_stmt_created = true;
scopes.pop_back();
inside_loop = inside_loop_copy;
Expand Down Expand Up @@ -3104,7 +3104,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
body.push_back(al, ASRUtils::STMT(tmp.get()));
current_body = current_body_copy;

tmp = ASR::make_WhileLoop_t(al, Lloc(x), nullptr, test, body.p, body.size());
tmp = ASR::make_WhileLoop_t(al, Lloc(x), nullptr, test, body.p, body.size(), nullptr, 0);
is_stmt_created = true;
scopes.pop_back();
for_loop = for_loop_copy;
Expand All @@ -3120,7 +3120,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
TraverseStmt(if_cond);
ASR::expr_t* test = ASRUtils::EXPR(tmp.get());
if( !ASRUtils::is_logical(*ASRUtils::expr_type(test)) ) {
test = CastingUtil::perform_casting(test, ASRUtils::expr_type(test),
test = CastingUtil::perform_casting(test,
ASRUtils::TYPE(ASR::make_Logical_t(al, Lloc(x), 1)), al, Lloc(x));
}

Expand Down
Loading

0 comments on commit d4f0198

Please sign in to comment.