Skip to content

feat: Add x86 control registers to the inline asm register list - #3486

Merged
lerno merged 4 commits into
c3lang:masterfrom
ssimb:master
Sep 2, 2026
Merged

feat: Add x86 control registers to the inline asm register list#3486
lerno merged 4 commits into
c3lang:masterfrom
ssimb:master

Conversation

@ssimb

@ssimb ssimb commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

We add x86 control registers to the register list so we can use them with inline asm

CR0 is 32bit on both x86 and x86_64, that's why I registered it seperately.

@lerno

lerno commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Please add a test and update the releasenotes too

Comment thread src/compiler/asm_target.c Outdated
reg_register_list(target, x86_control_regs, 3, ASM_REG_INT, ARG_BITS_64, X86_CR2);
}

reg_register(target, x86_control_regs[3], ASM_REG_INT, ARG_BITS_32, X86_CR0);

@lerno lerno Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is CR0 32 bit on 64 bit processors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, yeah I double checked and it turns out CR0 is indeed 64-bits, just that the top 32-bits are unusable and reserved. I'll fix this

@ssimb

ssimb commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Quick question, where do I put the test? I saw in the README it says that they should go in test/unit, however I see that the bulk of the asm tests seem to be in test/test_suite. Furthermore the CR* registers result in a General Protection fault if used in usermode, so it shouldn't be run.

@lerno

lerno commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Use test/test_suite. Look at how the other asm tests are done. They basically will generate asm that LLVM then validates. And that's enough to show that they work.

@lerno
lerno merged commit 4264d82 into c3lang:master Sep 2, 2026
1 check passed
@lerno

lerno commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants