Skip to content

Fix issue #260#264

Merged
Zuhaitz-dev merged 2 commits intoz-libs:mainfrom
borup3:fix-issue-260
Feb 28, 2026
Merged

Fix issue #260#264
Zuhaitz-dev merged 2 commits intoz-libs:mainfrom
borup3:fix-issue-260

Conversation

@borup3
Copy link
Contributor

@borup3 borup3 commented Feb 28, 2026

Description

This change tries to fix issue #260.
This change adds support for the ASM node, only when it has inputs & outputs, to detect what register size it will need and chooses largest size requirement amongst the inputs and outputs to avoid mixed-width instructions. It defaults to a 32-bit register size if it can't detect that it definitely needs 64-bit or 128-bit. If it detects a 128-bit requirement (TYPE_x128) Zen C will error that this is unsupported. This change applies to ARM64 where C compilers can output a warning when using a 64-bit register where a 32-bit register is sufficient by ensuring we choose a 64-bit register only if it's necessary. For all other architectures (x64, x86, arm32) it uses the previous notation.

In get_asm_register_size(Type *t), I didn't include a TYPE_STRUCT name check for double due to is_float_type not doing it. I kept the name checks for int64_t and uint64_t because is_integer_type does this.

As a new contributor, I'm keen to hear if this the desired solution to the problem.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (see test_asm_arm64.zc)
  • New and existing unit tests pass locally with my changes

@Zuhaitz-dev
Copy link
Member

Looks good, I will do some modifications, but I will merge it as is

@Zuhaitz-dev Zuhaitz-dev merged commit 4ec79cf into z-libs:main Feb 28, 2026
10 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Zen C kanban Feb 28, 2026
@borup3 borup3 deleted the fix-issue-260 branch March 5, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants