Skip to content

Commit 4c1787d

Browse files
committed
Support Unsigned Int in visit_variable
1 parent a14d2c8 commit 4c1787d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/libasr/codegen/asr_to_llvm.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,27 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
23742374
}
23752375
}
23762376
llvm_symtab[h] = ptr;
2377+
} else if (x.m_type->type == ASR::ttypeType::UnsignedInteger) {
2378+
int a_kind = down_cast<ASR::UnsignedInteger_t>(x.m_type)->m_kind;
2379+
llvm::Type *type;
2380+
int init_value_bits = 8*a_kind;
2381+
type = llvm_utils->getIntType(a_kind);
2382+
llvm::Constant *ptr = module->getOrInsertGlobal(x.m_name,
2383+
type);
2384+
if (!external) {
2385+
if (ASRUtils::is_array(x.m_type)) {
2386+
throw CodeGenError("Arrays are not supported by visit_Variable");
2387+
}
2388+
if (init_value) {
2389+
module->getNamedGlobal(x.m_name)->setInitializer(
2390+
init_value);
2391+
} else {
2392+
module->getNamedGlobal(x.m_name)->setInitializer(
2393+
llvm::ConstantInt::get(context,
2394+
llvm::APInt(init_value_bits, 0)));
2395+
}
2396+
}
2397+
llvm_symtab[h] = ptr;
23772398
} else if (x.m_type->type == ASR::ttypeType::Real) {
23782399
int a_kind = down_cast<ASR::Real_t>(x.m_type)->m_kind;
23792400
llvm::Type *type;

0 commit comments

Comments
 (0)