Skip to content

Commit b2f7999

Browse files
committed
Support cast UnsignedIntegerToUnsignedInteger
1 parent 44892ff commit b2f7999

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/libasr/ASR.asdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ cast_kind
429429
| IntegerToCharacter
430430
| LogicalToCharacter
431431
| UnsignedIntegerToInteger
432+
| UnsignedIntegerToUnsignedInteger
432433
| UnsignedIntegerToReal
433434
| UnsignedIntegerToLogical
434435
| IntegerToUnsignedInteger

src/libasr/codegen/asr_to_c_cpp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,8 +1754,10 @@ PyMODINIT_FUNC PyInit_lpython_module_)" + fn_name + R"((void) {
17541754
// src = src;
17551755
break;
17561756
}
1757-
case (ASR::cast_kindType::IntegerToInteger) : {
1757+
case (ASR::cast_kindType::IntegerToInteger) :
1758+
case (ASR::cast_kindType::UnsignedIntegerToUnsignedInteger) : {
17581759
// In C++, we do not need to cast int <-> long long explicitly:
1760+
// we also do not need to cast uint8_t <-> uint32_t explicitly:
17591761
// src = src;
17601762
break;
17611763
}

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6876,7 +6876,8 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
68766876
}
68776877
break;
68786878
}
6879-
case (ASR::cast_kindType::IntegerToInteger) : {
6879+
case (ASR::cast_kindType::IntegerToInteger) :
6880+
case (ASR::cast_kindType::UnsignedIntegerToUnsignedInteger) : {
68806881
int arg_kind = -1, dest_kind = -1;
68816882
extract_kinds(x, arg_kind, dest_kind);
68826883
if( arg_kind > 0 && dest_kind > 0 &&

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ namespace CastingUtil {
7272
const std::map<ASR::ttypeType, ASR::cast_kindType>& kind_rules = {
7373
{ASR::ttypeType::Complex, ASR::cast_kindType::ComplexToComplex},
7474
{ASR::ttypeType::Real, ASR::cast_kindType::RealToReal},
75-
{ASR::ttypeType::Integer, ASR::cast_kindType::IntegerToInteger}
75+
{ASR::ttypeType::Integer, ASR::cast_kindType::IntegerToInteger},
76+
{ASR::ttypeType::UnsignedInteger, ASR::cast_kindType::UnsignedIntegerToUnsignedInteger}
7677
};
7778

7879
int get_type_priority(ASR::ttypeType type) {

0 commit comments

Comments
 (0)