Skip to content

Commit d4f0198

Browse files
committed
done
1 parent 8b52363 commit d4f0198

File tree

77 files changed

+22058
-7344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+22058
-7344
lines changed

build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -ex
55
python src/libasr/asdl_cpp.py src/lc/LC.asdl src/lc/ast.h
66
python src/libasr/asdl_cpp.py src/libasr/ASR.asdl src/libasr/asr.h
77
python src/libasr/wasm_instructions_visitor.py
8+
python src/libasr/intrinsic_func_registry_util_gen.py
89

910
(cd src/lc/parser && re2c -W -b tokenizer.re -o tokenizer.cpp)
1011
(cd src/lc/parser && bison -Wall -d -r all parser.yy)

run_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def single_test(test, verbose, no_llvm, skip_run_with_dbg, skip_cpptranslate, update_reference,
13-
no_color, specific_backends=None, excluded_backends=None):
13+
verify_hash, no_color, specific_backends=None, excluded_backends=None):
1414
filename = test["filename"]
1515
def is_included(backend):
1616
return test.get(backend, False) \

src/lc/clang_ast_to_asr.cpp

+25-25
Original file line numberDiff line numberDiff line change
@@ -1229,8 +1229,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
12291229
index.m_step = range_step.get();
12301230
array_section_indices.push_back(al, index);
12311231
} else if( is_all_called ) {
1232-
index.m_left = ASRUtils::get_bound<SemanticError>(array, i + 1, "lbound", al);
1233-
index.m_right = ASRUtils::get_bound<SemanticError>(array, i + 1, "ubound", al);
1232+
index.m_left = PassUtils::get_bound(array, i + 1, "lbound", al);
1233+
index.m_right = PassUtils::get_bound(array, i + 1, "ubound", al);
12341234
index.m_step = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, index.loc, 1,
12351235
ASRUtils::TYPE(ASR::make_Integer_t(al, index.loc, 4))));
12361236
array_section_indices.push_back(al, index);
@@ -1252,8 +1252,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
12521252
for( ; i < rank; i++ ) {
12531253
ASR::array_index_t index;
12541254
index.loc = array->base.loc;
1255-
index.m_left = ASRUtils::get_bound<SemanticError>(array, i + 1, "lbound", al);
1256-
index.m_right = ASRUtils::get_bound<SemanticError>(array, i + 1, "ubound", al);
1255+
index.m_left = PassUtils::get_bound(array, i + 1, "lbound", al);
1256+
index.m_right = PassUtils::get_bound(array, i + 1, "ubound", al);
12571257
index.m_step = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, index.loc, 1,
12581258
ASRUtils::TYPE(ASR::make_Integer_t(al, index.loc, 4))));
12591259
array_section_indices.push_back(al, index);
@@ -1432,8 +1432,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
14321432
args.p, args.size(), 0, ASRUtils::TYPE(ASR::make_Logical_t(
14331433
al, Lloc(x), 4)), nullptr);
14341434
} else if( sf == SpecialFunc::Exp ) {
1435-
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
1436-
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Exp),
1435+
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
1436+
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Exp),
14371437
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
14381438
} else if( sf == SpecialFunc::Pow ) {
14391439
if( args.size() != 2 ) {
@@ -1442,20 +1442,20 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
14421442

14431443
CreateBinOp(args.p[0], args.p[1], ASR::binopType::Pow, Lloc(x));
14441444
} else if( sf == SpecialFunc::Sqrt ) {
1445-
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
1446-
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Sqrt),
1445+
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
1446+
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Sqrt),
14471447
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
14481448
} else if( sf == SpecialFunc::Abs ) {
1449-
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
1450-
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Abs),
1449+
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
1450+
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Abs),
14511451
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
14521452
} else if( sf == SpecialFunc::Sin ) {
1453-
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
1454-
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Sin),
1453+
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
1454+
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Sin),
14551455
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
14561456
} else if( sf == SpecialFunc::Cos ) {
1457-
tmp = ASRUtils::make_IntrinsicScalarFunction_t_util(al, Lloc(x),
1458-
static_cast<int64_t>(ASRUtils::IntrinsicScalarFunctions::Cos),
1457+
tmp = ASRUtils::make_IntrinsicElementalFunction_t_util(al, Lloc(x),
1458+
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::Cos),
14591459
args.p, args.size(), 0, ASRUtils::expr_type(args.p[0]), nullptr);
14601460
} else if( sf == SpecialFunc::AMax ) {
14611461
if( args.size() > 1 && args.p[1] != nullptr ) {
@@ -1636,7 +1636,9 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
16361636
throw std::runtime_error("std::vector::reserve should be called with only one argument.");
16371637
}
16381638

1639-
tmp = ASR::make_ListReserve_t(al, Lloc(x), callee, args[0]);
1639+
tmp = ASR::make_Expr_t(al, Lloc(x), ASRUtils::EXPR(ASR::make_IntrinsicElementalFunction_t(al, Lloc(x),
1640+
static_cast<int64_t>(ASRUtils::IntrinsicElementalFunctions::ListReserve), args.p, args.size(), 0,
1641+
nullptr, nullptr)));
16401642
is_stmt_created = true;
16411643
} else {
16421644
throw std::runtime_error("Only printf and exit special functions supported");
@@ -1676,7 +1678,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
16761678
if( return_type == nullptr ) {
16771679
tmp = ASRUtils::make_SubroutineCall_t_util(al, Lloc(x), callee_sym,
16781680
callee_sym, call_args.p, call_args.size(), nullptr,
1679-
nullptr, false);
1681+
nullptr, false, false);
16801682
is_stmt_created = true;
16811683
} else {
16821684
tmp = ASRUtils::make_FunctionCall_t_util(al, Lloc(x), callee_sym,
@@ -2741,8 +2743,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
27412743
int lkind = ASRUtils::extract_kind_from_ttype_t(left_type);
27422744
int rkind = ASRUtils::extract_kind_from_ttype_t(right_type);
27432745
if( left_type->type != right_type->type || lkind != rkind ) {
2744-
throw SemanticError("Casting for mismatching pointer types not supported yet.",
2745-
right_type->base.loc);
2746+
throw std::runtime_error("Casting for mismatching pointer types not supported yet.");
27462747
}
27472748
}
27482749

@@ -2765,8 +2766,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
27652766
dest_type_right = ASRUtils::make_Array_t_util(al, dest_type->base.loc,
27662767
dest_type, m_dims, n_dims);
27672768
}
2768-
left = CastingUtil::perform_casting(left, left_type, dest_type_left, al, left->base.loc);
2769-
right = CastingUtil::perform_casting(right, right_type, dest_type_right, al, right->base.loc);
2769+
left = CastingUtil::perform_casting(left, dest_type_left, al, left->base.loc);
2770+
right = CastingUtil::perform_casting(right, dest_type_right, al, right->base.loc);
27702771
return ;
27712772
}
27722773

@@ -2779,8 +2780,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
27792780
return ;
27802781
}
27812782
src_expr = CastingUtil::perform_casting(
2782-
src_expr, src_type, dest_type, al,
2783-
src_expr->base.loc);
2783+
src_expr, dest_type, al, src_expr->base.loc);
27842784
if( casted_expression_signal == 0 ) {
27852785
left = src_expr;
27862786
right = dest_expr;
@@ -3070,7 +3070,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
30703070
TraverseStmt(loop_body);
30713071
current_body = current_body_copy;
30723072

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

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

0 commit comments

Comments
 (0)