Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ RUN(NAME test_types_01 LABELS cpython llvm llvm_jit c)
RUN(NAME test_types_02 LABELS cpython llvm llvm_jit c wasm)
# RUN(NAME test_str_01 LABELS cpython llvm llvm_jit c)
RUN(NAME test_str_02 LABELS cpython llvm llvm_jit) # renable c
RUN(NAME test_str_03 LABELS cpython llvm llvm_jit) # renable c # post sync
# RUN(NAME test_str_03 LABELS cpython llvm llvm_jit) # renable c # str negative indexing
RUN(NAME test_str_04 LABELS cpython llvm llvm_jit) # renable c, wasm
RUN(NAME test_str_05 LABELS cpython llvm llvm_jit) # renable c
# RUN(NAME test_str_06 LABELS cpython llvm llvm_jit c)
Expand All @@ -542,7 +542,7 @@ RUN(NAME test_list_04 LABELS cpython llvm llvm_jit NOFAST) # renable c
RUN(NAME test_list_06 LABELS cpython llvm llvm_jit c)
RUN(NAME test_list_07 LABELS cpython llvm llvm_jit c NOFAST)
RUN(NAME test_list_08 LABELS cpython llvm llvm_jit c NOFAST)
# RUN(NAME test_list_09 LABELS cpython llvm llvm_jit c NOFAST)
RUN(NAME test_list_09 LABELS cpython llvm llvm_jit NOFAST) # renable c
# RUN(NAME test_list_10 LABELS cpython llvm llvm_jit c NOFAST)
# RUN(NAME test_list_11 LABELS cpython llvm llvm_jit c)
# RUN(NAME test_list_section LABELS cpython llvm llvm_jit c NOFAST)
Expand Down Expand Up @@ -761,8 +761,8 @@ RUN(NAME structs_35 LABELS cpython llvm llvm_jit)
# RUN(NAME enum_02 LABELS cpython llvm llvm_jit NOFAST)
RUN(NAME enum_03 LABELS cpython llvm llvm_jit c NOFAST)
# RUN(NAME enum_04 LABELS cpython llvm llvm_jit c NOFAST)
RUN(NAME enum_05 LABELS llvm c
EXTRAFILES enum_05b.c NOFAST)
# RUN(NAME enum_05 LABELS llvm c
# EXTRAFILES enum_05b.c NOFAST)
# RUN(NAME enum_06 LABELS cpython llvm llvm_jit c)
RUN(NAME enum_07 IMPORT_PATH ..
LABELS cpython llvm llvm_jit c NOFAST)
Expand Down
23 changes: 13 additions & 10 deletions integration_tests/test_list_09.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from lpython import i32


def test_list_concat():
x: list[i32] = []
y: list[i32] = []
Expand All @@ -10,39 +11,41 @@ def test_list_concat():
x = [1, 2, 3]
z = x + y
for i in range(1, 4):
assert z[i-1] == i
assert z[i - 1] == i

x.clear()
y = [6, 7, 8]
z = x + y
for i in range(1, 4):
assert z[i-1] == i + 5
assert z[i - 1] == i + 5

x = [1, 2, 3, 4, 5]
z = x + y
for i in range(1, 9):
assert z[i-1] == i
assert z[i - 1] == i

x.clear(); y.clear()
x.clear()
y.clear()
for i in range(9, 51):
x.append(i)
for i in range(51, 101):
y.append(i)

z = z + x + y
x[0] = 0; x[1] = 0
x[0] = 0
x[1] = 0
y.clear()
for i in range(1, 100):
assert z[i-1] == i
assert z[i - 1] == i

c: list[str]
d: list[str]
c = ['a', 'b']
d = ['c', 'd', 'e']
c = ["a", "b"]
d = ["c", "d", "e"]
c += d
assert len(c) == 5
for i in range(5):
assert ord(c[i]) - ord('a') == i
assert ord(c[i]) - ord("a") == i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these changes are needed, right?



test_list_concat()
2 changes: 1 addition & 1 deletion libasr
Submodule libasr updated 1735 files
11 changes: 8 additions & 3 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ int emit_llvm(const std::string &infile,
// ASR -> LLVM
LCompilers::PythonCompiler fe(compiler_options);
LCompilers::Result<std::unique_ptr<LCompilers::LLVMModule>>
res = fe.get_llvm3(*asr, pass_manager, diagnostics, infile);
res = fe.get_llvm3(*asr, pass_manager, diagnostics, lm, infile);
std::cerr << diagnostics.render(lm, compiler_options);
if (!res.ok) {
LCOMPILERS_ASSERT(diagnostics.has_error())
Expand Down Expand Up @@ -1118,7 +1118,7 @@ int compile_python_using_llvm(
LCompilers::LLVMEvaluator e(compiler_options.target);
auto asr_to_llvm_start = std::chrono::high_resolution_clock::now();
LCompilers::Result<std::unique_ptr<LCompilers::LLVMModule>>
res = fe.get_llvm3(*asr, pass_manager, diagnostics, infile);
res = fe.get_llvm3(*asr, pass_manager, diagnostics, lm, infile);
auto asr_to_llvm_end = std::chrono::high_resolution_clock::now();
times.push_back(std::make_pair("ASR to LLVM", std::chrono::duration<double, std::milli>(asr_to_llvm_end - asr_to_llvm_start).count()));

Expand Down Expand Up @@ -1844,6 +1844,7 @@ int main(int argc, char *argv[])
bool separate_compilation = false;
bool to_jit = false;
bool disable_warnings = false;
bool hide_error_banner = false;

std::string arg_fmt_file;
// int arg_fmt_indent = 4;
Expand Down Expand Up @@ -1911,7 +1912,7 @@ int main(int argc, char *argv[])
app.add_flag("--time-report", time_report, "Show compilation time report");
app.add_flag("--static", static_link, "Create a static executable");
app.add_flag("--no-warnings", disable_warnings, "Turn off all warnings");
app.add_flag("--no-error-banner", compiler_options.no_error_banner, "Turn off error banner");
app.add_flag("--no-error-banner", hide_error_banner, "Turn off error banner");
app.add_option("--backend", arg_backend, "Select a backend (llvm, cpp, x86, wasm, wasm_x86, wasm_x64)")->capture_default_str();
app.add_flag("--enable-bounds-checking", compiler_options.bounds_checking, "Turn on index bounds checking");
app.add_flag("--openmp", compiler_options.openmp, "Enable openmp");
Expand Down Expand Up @@ -1993,6 +1994,10 @@ int main(int argc, char *argv[])
compiler_options.show_warnings = false;
}

if (hide_error_banner) {
compiler_options.show_error_banner = false;
}

if (arg_version) {
std::string version = LFORTRAN_VERSION;
std::cout << "LPython version: " << version << std::endl;
Expand Down
10 changes: 5 additions & 5 deletions src/lpython/python_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Result<PythonCompiler::EvalResult> PythonCompiler::evaluate(
run_fn = module_name + "global_stmts_" + std::to_string(eval_count) + "__";

Result<std::unique_ptr<LLVMModule>> res3 = get_llvm3(*asr,
pass_manager, diagnostics, lm.files.back().in_filename);
pass_manager, diagnostics, lm, lm.files.back().in_filename);
std::unique_ptr<LCompilers::LLVMModule> m;
if (res3.ok) {
m = std::move(res3.result);
Expand Down Expand Up @@ -419,7 +419,7 @@ Result<std::unique_ptr<LLVMModule>> PythonCompiler::get_llvm2(
return asr.error;
}
Result<std::unique_ptr<LLVMModule>> res = get_llvm3(*asr.result, pass_manager,
diagnostics, lm.files.back().in_filename);
diagnostics, lm, lm.files.back().in_filename);
if (res.ok) {
#ifdef HAVE_LFORTRAN_LLVM
std::unique_ptr<LLVMModule> m = std::move(res.result);
Expand All @@ -437,10 +437,10 @@ Result<std::unique_ptr<LLVMModule>> PythonCompiler::get_llvm2(
Result<std::unique_ptr<LLVMModule>> PythonCompiler::get_llvm3(
#ifdef HAVE_LFORTRAN_LLVM
ASR::TranslationUnit_t &asr, LCompilers::PassManager& lpm,
diag::Diagnostics &diagnostics, const std::string &infile
diag::Diagnostics &diagnostics, LCompilers::LocationManager &lm, const std::string &infile
#else
ASR::TranslationUnit_t &/*asr*/, LCompilers::PassManager&/*lpm*/,
diag::Diagnostics &/*diagnostics*/,const std::string &/*infile*/
diag::Diagnostics &/*diagnostics*/, LCompilers::LocationManager & /*lm*/, const std::string &/*infile*/
#endif
)
{
Expand All @@ -463,7 +463,7 @@ Result<std::unique_ptr<LLVMModule>> PythonCompiler::get_llvm3(
Result<std::unique_ptr<LCompilers::LLVMModule>> res
= asr_to_llvm(asr, diagnostics,
e->get_context(), al, lpm, compiler_options,
run_fn, global_underscore_name, infile);
run_fn, global_underscore_name, infile, lm);
if (res.ok) {
m = std::move(res.result);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/lpython/python_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PythonCompiler
diag::Diagnostics &diagnostics);

Result<std::unique_ptr<LLVMModule>> get_llvm3(ASR::TranslationUnit_t &asr,
LCompilers::PassManager& lpm, diag::Diagnostics &diagnostics,
LCompilers::PassManager& lpm, diag::Diagnostics &diagnostics, LCompilers::LocationManager& lm,
const std::string &infile);

Result<std::string> get_asm(const std::string &code,
Expand Down
41 changes: 21 additions & 20 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
ASR::symbol_t* variable_sym = ASR::down_cast<ASR::symbol_t>(variable_asr);
current_scope->add_symbol(dummy_ret_name, variable_sym);
ASR::expr_t* variable_var = ASRUtils::EXPR(ASR::make_Var_t(al, expr->base.loc, variable_sym));
return ASR::make_Assignment_t(al, expr->base.loc, variable_var, expr, nullptr, false);
return ASRUtils::make_Assignment_t_util(al, expr->base.loc, variable_var, expr, nullptr, false, false);
}

// Function to create appropriate call based on symbol type. If it is external
Expand Down Expand Up @@ -2609,8 +2609,8 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
is_runtime_expression) && !is_variable_const) {
ASR::expr_t* v_expr = ASRUtils::EXPR(ASR::make_Var_t(al, loc, v_sym));
cast_helper(v_expr, init_expr, true);
ASR::asr_t* assign = ASR::make_Assignment_t(al, loc, v_expr,
init_expr, nullptr, false);
ASR::asr_t* assign = ASRUtils::make_Assignment_t_util(al, loc, v_expr,
init_expr, nullptr, false, false);
if (current_body) {
current_body->push_back(al, ASRUtils::STMT(assign));
} else if (ASR::is_a<ASR::List_t>(*type) || is_runtime_expression) {
Expand Down Expand Up @@ -2705,7 +2705,7 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
dims.push_back(al, dim);
ASR::ttype_t* type = ASRUtils::make_Array_t_util(al, loc,
ASRUtils::expr_type(lbs[0]), dims.p, dims.size(), ASR::abiType::Source,
false, ASR::array_physical_typeType::PointerToDataArray, true);
false, ASR::array_physical_typeType::PointerArray, true);
return ASRUtils::EXPR(ASRUtils::make_ArrayConstructor_t_util(al,
loc, lbs.p, lbs.size(), type,
ASR::arraystorageType::RowMajor));
Expand Down Expand Up @@ -5324,7 +5324,7 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
ASR::symbol_t* call_sym = get_struct_member(parent_sym,call_name,loc);
super_call_stmt = ASRUtils::STMT(
ASR::make_SubroutineCall_t(al, loc, call_sym, call_sym, args_w_first.p,
args_w_first.size(), nullptr));
args_w_first.size(), nullptr, true));
}
} else {
body.push_back(al, x.m_body[i]);
Expand Down Expand Up @@ -5706,8 +5706,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
x.base.base.loc);
}
tmp = nullptr;
tmp_vec.push_back(ASR::make_Assignment_t(al, x.base.base.loc, target,
tmp_value, nullptr, false));
tmp_vec.push_back(ASRUtils::make_Assignment_t_util(al, x.base.base.loc, target,
tmp_value, nullptr, false, false));
continue;
}
if( ASRUtils::is_const(target) ) {
Expand Down Expand Up @@ -5748,8 +5748,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
throw SemanticError("Only Class constructor is allowed in the object assignment for now", target->base.loc);
}
}
tmp_vec.push_back(ASR::make_Assignment_t(al, x.base.base.loc, target, tmp_value,
overloaded, false));
tmp_vec.push_back(ASRUtils::make_Assignment_t_util(al, x.base.base.loc, target, tmp_value,
overloaded, false, false));
if ( target->type == ASR::exprType::Var &&
tmp_value->type == ASR::exprType::StructConstructor ) {
AST::Call_t* call = AST::down_cast<AST::Call_t>(x.m_value);
Expand Down Expand Up @@ -6042,9 +6042,9 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
current_scope->add_symbol(tmp_assign_name, tmp_assign_variable_sym);

// Assign the Subscript expr to temporary variable
ASR::asr_t* assign = ASR::make_Assignment_t(al, x.base.base.loc,
ASR::asr_t* assign = ASRUtils::make_Assignment_t_util(al, x.base.base.loc,
ASRUtils::EXPR(ASR::make_Var_t(al, x.base.base.loc, tmp_assign_variable_sym)),
target, nullptr, false);
target, nullptr, false, false);
if (current_body != nullptr) {
current_body->push_back(al, ASRUtils::STMT(assign));
} else {
Expand Down Expand Up @@ -6080,9 +6080,9 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
current_scope->add_symbol(tmp_assign_name, tmp_assign_variable_sym);

// Assign the List expr to temporary variable
ASR::asr_t* assign = ASR::make_Assignment_t(al, x.base.base.loc,
ASR::asr_t* assign = ASRUtils::make_Assignment_t_util(al, x.base.base.loc,
ASRUtils::EXPR(ASR::make_Var_t(al, x.base.base.loc, tmp_assign_variable_sym)),
target, nullptr, false);
target, nullptr, false, false);
if (current_body != nullptr) {
current_body->push_back(al, ASRUtils::STMT(assign));
} else {
Expand Down Expand Up @@ -6135,7 +6135,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
al, x.base.base.loc, loop_src_var,
ASRUtils::EXPR(explicit_iter_var), ASRUtils::get_contained_type(loop_src_var_ttype), nullptr);
}
auto loop_target_assignment = ASR::make_Assignment_t(al, x.base.base.loc, target, ASRUtils::EXPR(loop_src_var_element), nullptr, false);
auto loop_target_assignment = ASRUtils::make_Assignment_t_util(al, x.base.base.loc, target,
ASRUtils::EXPR(loop_src_var_element), nullptr, false, false);
body.push_back(al, ASRUtils::STMT(loop_target_assignment));

head.m_v = ASRUtils::EXPR(explicit_iter_var);
Expand Down Expand Up @@ -6260,7 +6261,7 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {

ASR::stmt_t* a_overloaded = nullptr;
ASR::expr_t *tmp2 = ASR::down_cast<ASR::expr_t>(tmp);
tmp = ASR::make_Assignment_t(al, x.base.base.loc, left, tmp2, a_overloaded, false);
tmp = ASRUtils::make_Assignment_t_util(al, x.base.base.loc, left, tmp2, a_overloaded, false, false);

}

Expand Down Expand Up @@ -7244,8 +7245,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
}
cast_helper(target, value, true);
ASR::stmt_t *overloaded=nullptr;
tmp = ASR::make_Assignment_t(al, x.base.base.loc, target, value,
overloaded, false);
tmp = ASRUtils::make_Assignment_t_util(al, x.base.base.loc, target, value,
overloaded, false, false);
// if( ASR::is_a<ASR::Const_t>(*ASRUtils::symbol_type(return_var)) ) {
// ASR::Variable_t* return_variable = ASR::down_cast<ASR::Variable_t>(return_var);
// return_variable->m_symbolic_value = value;
Expand Down Expand Up @@ -7346,8 +7347,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
ASR::expr_t* cptr = ASRUtils::EXPR(tmp);
ASR::asr_t* pp = ASR::make_PointerToCPtr_t(al, x.base.base.loc, pptr,
ASRUtils::expr_type(cptr), nullptr);
return ASR::make_Assignment_t(al, x.base.base.loc,
cptr, ASR::down_cast<ASR::expr_t>(pp), nullptr, false);
return ASRUtils::make_Assignment_t_util(al, x.base.base.loc,
cptr, ASR::down_cast<ASR::expr_t>(pp), nullptr, false, false);
}

void handle_string_attributes(ASR::expr_t *s_var,
Expand Down Expand Up @@ -8896,7 +8897,7 @@ we will have to use something else.
make_Integer_t, 0, 4, dim.loc);
dims.push_back(al, dim);
type = ASRUtils::make_Array_t_util(al, x.base.base.loc, type, dims.p, dims.size(),
ASR::abiType::Source, false, ASR::array_physical_typeType::PointerToDataArray, true);
ASR::abiType::Source, false, ASR::array_physical_typeType::PointerArray, true);
for( size_t i = 0; i < n_args; i++ ) {
m_args[i] = CastingUtil::perform_casting(m_args[i], ASRUtils::type_get_past_array(type),
al, x.base.base.loc);
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-array_01_decl-39cf894.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-array_01_decl-39cf894.stdout",
"stdout_hash": "195a4d1ca41ba5c8ed64f7af675a59ef0100f236e0f63fcbb6c771aa",
"stdout_hash": "5bc6bef74c19e3ab954672c7b77c461beab78c936732fed4116ab0f3",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
Loading
Loading