Cr0a3 / ygen

Ygen - Yet another code generation libary
https://ygen.vercel.app/
Apache License 2.0
85 stars 3 forks source link

[x64] cast code gen #4

Closed Cr0a3 closed 2 months ago

Cr0a3 commented 2 months ago

Describe the bug The following function:

define i64 @add( i32 %0,  i32 %1 ) {
 entry:
    %2 = add i32 %0, %1
    %3 = cast %2 to i64
    ret i64 %3

}

Generates following assembly:

section .text

add:
    lea eax, [ ecx + edx ]
    mov rax, rcx // wrong it will just  mov arg1 into output it should be nothing because the lea overrides eax (and the also the upper half of rax) which would mean a cast to 64bit 
    ret