GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — LLVM: Support Unsigned Int in visit_Variable by Smit-create · Pull Request #2171 · lcompilers/lpython

Conversation

@Smit-create

@Smit-create Smit-create commented Jul 17, 2023

Copy link
Copy Markdown
Collaborator

Fixes #2170

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Smit-create added 2 commits July 17, 2023 20:11
@Smit-create
Support Unsigned Int in visit_variable
4c1787d
@Smit-create
Add tests
244d711
certik
certik approved these changes Jul 17, 2023
View reviewed changes

@certik certik left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but after merging let's add tests for all unsigned kinds as well as checking that the value is present in the variable correctly.

What exactly was the problem --- that this is using global variables?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@certik
certik marked this pull request as ready for review July 17, 2023 14:58
@certik
certik enabled auto-merge July 17, 2023 14:59
@certik
certik merged commit ea9715b into lcompilers:main Jul 17, 2023
@ubaidsk

ubaidsk commented Jul 17, 2023

Copy link
Copy Markdown
Collaborator

Please see #2170 (comment). I think the else if condition added in this PR would never be executed since the first if in the visit_Variable() would be executed for Integers as well as UnsingedIntegers. Thus, it seems the else if condition is more like a dead code.

lpython/src/libasr/codegen/asr_to_llvm.cpp

Lines 2356 to 2378 in ea9715b

if (x.m_type->type == ASR::ttypeType::Integer
|| x.m_type->type == ASR::ttypeType::UnsignedInteger) {
int a_kind = ASRUtils::extract_kind_from_ttype_t(x.m_type);
llvm::Type *type;
int init_value_bits = 8*a_kind;
type = llvm_utils->getIntType(a_kind);
llvm::Constant *ptr = module->getOrInsertGlobal(x.m_name,
type);
if (!external) {
if (ASRUtils::is_array(x.m_type)) {
throw CodeGenError("Arrays are not supported by visit_Variable");
}
if (init_value) {
module->getNamedGlobal(x.m_name)->setInitializer(
init_value);
} else {
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantInt::get(context,
llvm::APInt(init_value_bits, 0)));
}
}
llvm_symtab[h] = ptr;
} else if (x.m_type->type == ASR::ttypeType::UnsignedInteger) {

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ubaidsk

ubaidsk commented Jul 17, 2023

Copy link
Copy Markdown
Collaborator

This is fine, but after merging let's add tests for all unsigned kinds as well as checking that the value is present in the variable correctly.

Yes, I tested different unsigned kinds in https://github.com/lcompilers/lpython/pull/2164/files#diff-b6a08444f0697e1ea781c919bcdf3b29eba7b542bddef56ce0125f3c2997c973.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ubaidsk
ubaidsk reviewed Jul 17, 2023
View reviewed changes
Comment thread integration_tests/test_unsigned_02.py
x : i32

for i in range(i32(u)):
x = i * 2

@ubaidsk ubaidsk Jul 17, 2023

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If in case we update the changes in this PR, I suggest we add an assert in this test case (and also possibly a print statement before the assert).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

certik reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ubaidsk ubaidsk ubaidsk left review comments
@certik certik certik approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

type casting between u16 and i32 needed

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Smit-create @ubaidsk @certik
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.