Skip to content

Commit a598de5

Browse files
committed
DEV: Add support for xt::amin
1 parent 8395ad4 commit a598de5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/lc/clang_ast_to_asr.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum SpecialFunc {
4646
Sin,
4747
Cos,
4848
AMax,
49+
AMin,
4950
Sum,
5051
Range,
5152
Size,
@@ -70,6 +71,7 @@ std::map<std::string, SpecialFunc> special_function_map = {
7071
{"sin", SpecialFunc::Sin},
7172
{"cos", SpecialFunc::Cos},
7273
{"amax", SpecialFunc::AMax},
74+
{"amin", SpecialFunc::AMin},
7375
{"sum", SpecialFunc::Sum},
7476
{"range", SpecialFunc::Range},
7577
{"size", SpecialFunc::Size},
@@ -626,6 +628,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
626628
array_indices.p, array_indices.size(),
627629
ASRUtils::extract_type(ASRUtils::expr_type(obj)),
628630
ASR::arraystorageType::RowMajor, nullptr);
631+
} else if( ASR::is_a<ASR::IntrinsicArrayFunction_t>(*obj) ) {
632+
tmp = (ASR::asr_t*) obj;
629633
} else {
630634
throw std::runtime_error("Only indexing arrays is supported for now with operator().");
631635
}
@@ -943,7 +947,15 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
943947
static_cast<int64_t>(ASRUtils::IntrinsicArrayFunctions::MaxVal),
944948
args.p, 1, 0, ASRUtils::extract_type(ASRUtils::expr_type(args.p[0])),
945949
nullptr);
946-
} else if( sf == SpecialFunc::Sum ) {
950+
} else if( sf == SpecialFunc::AMin ) {
951+
if( args.size() > 1 && args.p[1] != nullptr ) {
952+
throw std::runtime_error("dim argument not yet supported with " + func_name);
953+
}
954+
tmp = ASRUtils::make_IntrinsicArrayFunction_t_util(al, Lloc(x),
955+
static_cast<int64_t>(ASRUtils::IntrinsicArrayFunctions::MinVal),
956+
args.p, 1, 0, ASRUtils::extract_type(ASRUtils::expr_type(args.p[0])),
957+
nullptr);
958+
} else if( sf == SpecialFunc::Sum ) {
947959
if( args.size() > 1 && args.p[1] != nullptr ) {
948960
throw std::runtime_error("dim argument not yet supported with " + func_name);
949961
}
@@ -1531,7 +1543,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor<ClangASTtoASRVisit
15311543
name == "range" || name == "pow" || name == "equal" ||
15321544
name == "operator<" || name == "operator<=" || name == "operator>=" ||
15331545
name == "operator!=" || name == "operator\"\"i" || name == "sin" ||
1534-
name == "cos" ) {
1546+
name == "cos" || name == "amin" ) {
15351547
if( sym != nullptr && ASR::is_a<ASR::Function_t>(
15361548
*ASRUtils::symbol_get_past_external(sym)) ) {
15371549
throw std::runtime_error("Special function " + name + " cannot be overshadowed yet.");

0 commit comments

Comments
 (0)