Skip to content

Commit 0df9c2c

Browse files
committed
DEV: Sync libasr with LFortran
1 parent bf16a3d commit 0df9c2c

Some content is hidden

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

65 files changed

+19963
-5987
lines changed

src/libasr/ASR.asdl

Lines changed: 47 additions & 320 deletions
Large diffs are not rendered by default.

src/libasr/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ set(SRC
3131

3232
pass/nested_vars.cpp
3333
pass/where.cpp
34+
pass/function_call_in_declaration.cpp
3435
pass/param_to_const.cpp
3536
pass/do_loops.cpp
3637
pass/for_all.cpp
@@ -53,6 +54,7 @@ set(SRC
5354
pass/div_to_mul.cpp
5455
pass/replace_symbolic.cpp
5556
pass/intrinsic_function.cpp
57+
pass/intrinsic_subroutine.cpp
5658
pass/fma.cpp
5759
pass/loop_vectorise.cpp
5860
pass/sign_from_value.cpp
@@ -66,6 +68,7 @@ set(SRC
6668
pass/pass_compare.cpp
6769
pass/unique_symbols.cpp
6870
pass/insert_deallocate.cpp
71+
pass/promote_allocatable_to_nonallocatable.cpp
6972

7073
asr_verify.cpp
7174
asr_utils.cpp
@@ -113,3 +116,10 @@ endif()
113116
if (WITH_LLVM)
114117
target_link_libraries(asr p::llvm)
115118
endif()
119+
120+
# Install the dwarf_convert.py and dat_convert.py
121+
install(
122+
FILES dwarf_convert.py dat_convert.py
123+
PERMISSIONS OWNER_EXECUTE OWNER_READ
124+
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/lfortran
125+
)

src/libasr/asdl_cpp.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def make_visitor(self, name, fields):
450450
symtab_field_name = field.name
451451
if is_stmt_present and is_symtab_present:
452452
break
453-
if is_stmt_present and name not in ("Assignment", "ForAllSingle"):
453+
if is_stmt_present and name not in ("Assignment", "ForAllSingle", "FileRead", "FileWrite"):
454454
self.emit(" %s_t& xx = const_cast<%s_t&>(x);" % (name, name), 1)
455455
self.used = False
456456

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

@@ -1029,17 +1029,13 @@ def visitConstructor(self, cons, _):
10291029
def make_visitor(self, name, fields):
10301030
self.emit("")
10311031
self.emit("ASR::asr_t* duplicate_%s(%s_t* x) {" % (name, name), 1)
1032-
self.used = False
1033-
arguments = []
1032+
arguments = ["al", "x->base.base.loc"]
10341033
for field in fields:
10351034
ret_value = self.visitField(field)
10361035
for node_arg in ret_value:
10371036
arguments.append(node_arg)
1038-
if not self.used:
1039-
self.emit("return (asr_t*)x;", 2)
1040-
else:
1041-
node_arg_str = ', '.join(arguments)
1042-
self.emit("return make_%s_t(al, x->base.base.loc, %s);" %(name, node_arg_str), 2)
1037+
node_arg_str = ', '.join(arguments)
1038+
self.emit("return make_%s_t(%s);" %(name, node_arg_str), 2)
10431039
if self.is_stmt:
10441040
self.duplicate_stmt.append((" case ASR::stmtType::%s: {" % name, 2))
10451041
if name == "SubroutineCall":
@@ -1088,7 +1084,6 @@ def visitField(self, field):
10881084
field.type == "dimension"):
10891085
level = 2
10901086
if field.seq:
1091-
self.used = True
10921087
pointer_char = ''
10931088
if (field.type != "call_arg" and
10941089
field.type != "array_index" and
@@ -1141,7 +1136,6 @@ def visitField(self, field):
11411136
self.emit("}", level)
11421137
arguments = ("m_" + field.name + ".p", "x->n_" + field.name)
11431138
else:
1144-
self.used = True
11451139
if field.type == "symbol":
11461140
self.emit("%s_t* m_%s = x->m_%s;" % (field.type, field.name, field.name), level)
11471141
elif field.type == "do_loop_head":
@@ -1461,12 +1455,6 @@ def visitConstructor(self, cons, _):
14611455
def make_visitor(self, name, fields, cons):
14621456
self.emit("void visit_%s(const %s_t &x) {" % (name, name), 1)
14631457
self.emit( 's.append("(");', 2)
1464-
subs = {
1465-
"Assignment": "=",
1466-
"Associate": "=>",
1467-
}
1468-
if name in subs:
1469-
name = subs[name]
14701458

14711459
# For ASR
14721460
symbol = [
@@ -1680,7 +1668,7 @@ def visitField(self, field, cons):
16801668
self.emit( 's.append("()");', 3)
16811669
self.emit("}", 2)
16821670
else:
1683-
if field.name == "intrinsic_id":
1671+
if field.name == "intrinsic_id" or field.name == "inquiry_id":
16841672
self.emit('s.append(self().convert_intrinsic_id(x.m_%s));' % field.name, 2)
16851673
elif field.name == "impure_intrinsic_id":
16861674
self.emit('s.append(self().convert_impure_intrinsic_id(x.m_%s));' % field.name, 2)
@@ -2593,7 +2581,8 @@ def make_visitor(self, name, fields):
25932581
LCOMPILERS_ASSERT(!ASR::is_a<ASR::ExternalSymbol_t>(*e->m_external));
25942582
s = e->m_external;
25952583
}
2596-
if( ASR::down_cast<ASR::Variable_t>(s)->m_storage !=
2584+
if( ASR::is_a<ASR::Function_t>(*s) ||
2585+
ASR::down_cast<ASR::Variable_t>(s)->m_storage !=
25972586
ASR::storage_typeType::Parameter ) {
25982587
return nullptr;
25992588
}

0 commit comments

Comments
 (0)