Skip to content

Commit 946932a

Browse files
committed
Sync libasr from LFortran
1 parent f16201f commit 946932a

Some content is hidden

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

42 files changed

+4763
-1337
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ RUN(NAME enum_06 LABELS cpython llvm c)
723723
RUN(NAME enum_07 IMPORT_PATH ..
724724
LABELS cpython llvm c)
725725
RUN(NAME union_01 LABELS cpython llvm c)
726-
RUN(NAME union_02 LABELS cpython llvm c)
726+
RUN(NAME union_02 LABELS cpython llvm c NOFAST)
727727
RUN(NAME union_03 LABELS cpython llvm c)
728728
RUN(NAME union_04 IMPORT_PATH ..
729729
LABELS cpython llvm c)

src/libasr/ASR.asdl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ abi -- External ABI
170170

171171
stmt
172172
= Allocate(alloc_arg* args, expr? stat, expr? errmsg, expr? source)
173+
| ReAlloc(alloc_arg* args)
173174
| Assign(int label, identifier variable)
174175
| Assignment(expr target, expr value, stmt? overloaded)
175176
| Associate(expr target, expr value)
@@ -193,7 +194,7 @@ stmt
193194
| If(expr test, stmt* body, stmt* orelse)
194195
| IfArithmetic(expr test, int lt_label, int eq_label, int gt_label)
195196
| Print(expr? fmt, expr* values, expr? separator, expr? end)
196-
| FileOpen(int label, expr? newunit, expr? filename, expr? status)
197+
| FileOpen(int label, expr? newunit, expr? filename, expr? status, expr? form)
197198
| FileClose(int label, expr? unit, expr? iostat, expr? iomsg, expr? err, expr? status)
198199
| FileRead(int label, expr? unit, expr? fmt, expr? iomsg, expr? iostat, expr? id, expr* values)
199200
| FileBackspace(int label, expr? unit, expr? iostat, expr? err)
@@ -221,6 +222,8 @@ stmt
221222
| SelectType(expr selector, type_stmt* body, stmt* default)
222223
| CPtrToPointer(expr cptr, expr ptr, expr? shape, expr? lower_bounds)
223224
| BlockCall(int label, symbol m)
225+
| SetInsert(expr a, expr ele)
226+
| SetRemove(expr a, expr ele)
224227
| ListInsert(expr a, expr pos, expr ele)
225228
| ListRemove(expr a, expr ele)
226229
| ListClear(expr a)
@@ -261,6 +264,7 @@ expr
261264
| RealUnaryMinus(expr arg, ttype type, expr? value)
262265
| RealCompare(expr left, cmpop op, expr right, ttype type, expr? value)
263266
| RealBinOp(expr left, binop op, expr right, ttype type, expr? value)
267+
| RealCopySign(expr target, expr source, ttype type, expr? value)
264268
| ComplexConstant(float re, float im, ttype type)
265269
| ComplexUnaryMinus(expr arg, ttype type, expr? value)
266270
| ComplexCompare(expr left, cmpop op, expr right, ttype type, expr? value)
@@ -311,10 +315,8 @@ expr
311315
| ArrayBound(expr v, expr? dim, ttype type, arraybound bound,
312316
expr? value)
313317
| ArrayTranspose(expr matrix, ttype type, expr? value)
314-
| ArrayMatMul(expr matrix_a, expr matrix_b, ttype type, expr? value)
315318
| ArrayPack(expr array, expr mask, expr? vector, ttype type, expr? value)
316319
| ArrayReshape(expr array, expr shape, ttype type, expr? value)
317-
| ArrayMaxloc(expr array, expr? dim, expr? mask, expr? kind, expr? back, ttype type, expr? value)
318320
| ArrayAll(expr mask, expr? dim, ttype type, expr? value)
319321

320322
| BitCast(expr source, expr mold, expr? size, ttype type, expr? value)
@@ -417,6 +419,7 @@ ttype
417419
array_physical_type
418420
= DescriptorArray
419421
| PointerToDataArray
422+
| UnboundedPointerToDataArray
420423
| FixedSizeArray
421424
| NumPyArray
422425
| ISODescriptorArray

src/libasr/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ set(SRC
7070
string_utils.cpp
7171
asr_scopes.cpp
7272
modfile.cpp
73+
pickle.cpp
7374
serialization.cpp
7475
utils2.cpp
7576
)

src/libasr/asdl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def check(mod):
194194

195195
def parse(filename):
196196
"""Parse ASDL from the given file and return a Module node describing it."""
197-
with open(filename) as f:
197+
with open(filename, encoding='utf8') as f:
198198
parser = ASDLParser()
199199
return parser.parse(f.read())
200200

src/libasr/asr_scopes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include <libasr/asr_scopes.h>
55
#include <libasr/asr_utils.h>
66

7-
87
std::string lcompilers_unique_ID;
8+
99
namespace LCompilers {
1010

1111
template< typename T >
@@ -53,7 +53,6 @@ void SymbolTable::mark_all_variables_external(Allocator &al) {
5353
}
5454
}
5555

56-
5756
ASR::symbol_t *SymbolTable::find_scoped_symbol(const std::string &name,
5857
size_t n_scope_names, char **m_scope_names) {
5958
const SymbolTable *s = this;

src/libasr/asr_utils.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,47 @@ ASR::symbol_t* import_class_procedure(Allocator &al, const Location& loc,
13451345
return original_sym;
13461346
}
13471347

1348+
ASR::asr_t* make_Binop_util(Allocator &al, const Location& loc, ASR::binopType binop,
1349+
ASR::expr_t* lexpr, ASR::expr_t* rexpr, ASR::ttype_t* ttype) {
1350+
switch (ttype->type) {
1351+
case ASR::ttypeType::Real: {
1352+
return ASR::make_RealBinOp_t(al, loc, lexpr, binop, rexpr,
1353+
ASRUtils::duplicate_type(al, ttype), nullptr);
1354+
}
1355+
case ASR::ttypeType::Integer: {
1356+
return ASR::make_IntegerBinOp_t(al, loc, lexpr, binop, rexpr,
1357+
ASRUtils::duplicate_type(al, ttype), nullptr);
1358+
}
1359+
case ASR::ttypeType::Complex: {
1360+
return ASR::make_ComplexBinOp_t(al, loc, lexpr, binop, rexpr,
1361+
ASRUtils::duplicate_type(al, ttype), nullptr);
1362+
}
1363+
default:
1364+
throw LCompilersException("Not implemented " + std::to_string(ttype->type));
1365+
}
1366+
}
1367+
1368+
ASR::asr_t* make_Cmpop_util(Allocator &al, const Location& loc, ASR::cmpopType cmpop,
1369+
ASR::expr_t* lexpr, ASR::expr_t* rexpr, ASR::ttype_t* ttype) {
1370+
ASR::ttype_t* expr_type = ASRUtils::TYPE(ASR::make_Logical_t(al, loc, 4));
1371+
switch (ttype->type) {
1372+
case ASR::ttypeType::Real: {
1373+
return ASR::make_RealCompare_t(al, loc, lexpr, cmpop, rexpr, expr_type, nullptr);
1374+
}
1375+
case ASR::ttypeType::Integer: {
1376+
return ASR::make_IntegerCompare_t(al, loc, lexpr, cmpop, rexpr, expr_type, nullptr);
1377+
}
1378+
case ASR::ttypeType::Complex: {
1379+
return ASR::make_ComplexCompare_t(al, loc, lexpr, cmpop, rexpr, expr_type, nullptr);
1380+
}
1381+
case ASR::ttypeType::Character: {
1382+
return ASR::make_StringCompare_t(al, loc, lexpr, cmpop, rexpr, expr_type, nullptr);
1383+
}
1384+
default:
1385+
throw LCompilersException("Not implemented " + std::to_string(ttype->type));
1386+
}
1387+
}
1388+
13481389
//Initialize pointer to zero so that it can be initialized in first call to get_instance
13491390
ASRUtils::LabelGenerator* ASRUtils::LabelGenerator::label_generator = nullptr;
13501391

0 commit comments

Comments
 (0)