Skip to content

Commit

Permalink
DEV: Sync libasr with LFortran
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Mar 26, 2024
1 parent bf16a3d commit 0df9c2c
Show file tree
Hide file tree
Showing 65 changed files with 19,963 additions and 5,987 deletions.
367 changes: 47 additions & 320 deletions src/libasr/ASR.asdl

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/libasr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(SRC

pass/nested_vars.cpp
pass/where.cpp
pass/function_call_in_declaration.cpp
pass/param_to_const.cpp
pass/do_loops.cpp
pass/for_all.cpp
Expand All @@ -53,6 +54,7 @@ set(SRC
pass/div_to_mul.cpp
pass/replace_symbolic.cpp
pass/intrinsic_function.cpp
pass/intrinsic_subroutine.cpp
pass/fma.cpp
pass/loop_vectorise.cpp
pass/sign_from_value.cpp
Expand All @@ -66,6 +68,7 @@ set(SRC
pass/pass_compare.cpp
pass/unique_symbols.cpp
pass/insert_deallocate.cpp
pass/promote_allocatable_to_nonallocatable.cpp

asr_verify.cpp
asr_utils.cpp
Expand Down Expand Up @@ -113,3 +116,10 @@ endif()
if (WITH_LLVM)
target_link_libraries(asr p::llvm)
endif()

# Install the dwarf_convert.py and dat_convert.py
install(
FILES dwarf_convert.py dat_convert.py
PERMISSIONS OWNER_EXECUTE OWNER_READ
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/lfortran
)
27 changes: 8 additions & 19 deletions src/libasr/asdl_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def make_visitor(self, name, fields):
symtab_field_name = field.name
if is_stmt_present and is_symtab_present:
break
if is_stmt_present and name not in ("Assignment", "ForAllSingle"):
if is_stmt_present and name not in ("Assignment", "ForAllSingle", "FileRead", "FileWrite"):
self.emit(" %s_t& xx = const_cast<%s_t&>(x);" % (name, name), 1)
self.used = False

Expand Down Expand Up @@ -562,7 +562,7 @@ def make_visitor(self, name, fields):
symtab_field_name = field.name
if is_stmt_present and is_symtab_present:
break
if is_stmt_present and name not in ("Assignment", "ForAllSingle"):
if is_stmt_present and name not in ("Assignment", "ForAllSingle", "FileRead", "FileWrite"):
self.emit(" %s_t& xx = const_cast<%s_t&>(x);" % (name, name), 1)
self.used = False

Expand Down Expand Up @@ -1029,17 +1029,13 @@ def visitConstructor(self, cons, _):
def make_visitor(self, name, fields):
self.emit("")
self.emit("ASR::asr_t* duplicate_%s(%s_t* x) {" % (name, name), 1)
self.used = False
arguments = []
arguments = ["al", "x->base.base.loc"]
for field in fields:
ret_value = self.visitField(field)
for node_arg in ret_value:
arguments.append(node_arg)
if not self.used:
self.emit("return (asr_t*)x;", 2)
else:
node_arg_str = ', '.join(arguments)
self.emit("return make_%s_t(al, x->base.base.loc, %s);" %(name, node_arg_str), 2)
node_arg_str = ', '.join(arguments)
self.emit("return make_%s_t(%s);" %(name, node_arg_str), 2)
if self.is_stmt:
self.duplicate_stmt.append((" case ASR::stmtType::%s: {" % name, 2))
if name == "SubroutineCall":
Expand Down Expand Up @@ -1088,7 +1084,6 @@ def visitField(self, field):
field.type == "dimension"):
level = 2
if field.seq:
self.used = True
pointer_char = ''
if (field.type != "call_arg" and
field.type != "array_index" and
Expand Down Expand Up @@ -1141,7 +1136,6 @@ def visitField(self, field):
self.emit("}", level)
arguments = ("m_" + field.name + ".p", "x->n_" + field.name)
else:
self.used = True
if field.type == "symbol":
self.emit("%s_t* m_%s = x->m_%s;" % (field.type, field.name, field.name), level)
elif field.type == "do_loop_head":
Expand Down Expand Up @@ -1461,12 +1455,6 @@ def visitConstructor(self, cons, _):
def make_visitor(self, name, fields, cons):
self.emit("void visit_%s(const %s_t &x) {" % (name, name), 1)
self.emit( 's.append("(");', 2)
subs = {
"Assignment": "=",
"Associate": "=>",
}
if name in subs:
name = subs[name]

# For ASR
symbol = [
Expand Down Expand Up @@ -1680,7 +1668,7 @@ def visitField(self, field, cons):
self.emit( 's.append("()");', 3)
self.emit("}", 2)
else:
if field.name == "intrinsic_id":
if field.name == "intrinsic_id" or field.name == "inquiry_id":
self.emit('s.append(self().convert_intrinsic_id(x.m_%s));' % field.name, 2)
elif field.name == "impure_intrinsic_id":
self.emit('s.append(self().convert_impure_intrinsic_id(x.m_%s));' % field.name, 2)
Expand Down Expand Up @@ -2593,7 +2581,8 @@ def make_visitor(self, name, fields):
LCOMPILERS_ASSERT(!ASR::is_a<ASR::ExternalSymbol_t>(*e->m_external));
s = e->m_external;
}
if( ASR::down_cast<ASR::Variable_t>(s)->m_storage !=
if( ASR::is_a<ASR::Function_t>(*s) ||
ASR::down_cast<ASR::Variable_t>(s)->m_storage !=
ASR::storage_typeType::Parameter ) {
return nullptr;
}
Expand Down
Loading

0 comments on commit 0df9c2c

Please sign in to comment.