Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eegcc sn (ps2) cc1plus.exe emits wrong built-in function call for 64bits operations #76

Open
AngheloAlf opened this issue Apr 4, 2024 · 0 comments

Comments

@AngheloAlf
Copy link
Contributor

From what I have seen cc1plus.exe is emitting a __mulll3 call instead of a __muldi3 call for 64 bits multiplications. From a quick test other 64 bits operations seems to present the same issue.

Minimal reproducer:

// test.cpp
unsigned long test_mul(unsigned long a, unsigned long b) {
    return a * b;
}

Produces this under wibo:

	.file	1 "test.cpp"
gcc2_compiled.:
__gnu_compiled_cplusplus:
	.text
	.align	3
	.globl	test_mul__FUlUl
	.text
	.ent	test_mul__FUlUl
test_mul__FUlUl:
	.frame	$sp,16,$31		# vars= 0, regs= 2/0, args= 0, extra= 0
	.mask	0x80000000,-16
	.fmask	0x00000000,0
	subu	$sp,$sp,16
	sq $31,0($sp)
	jal	__mulll3
	lq $31,0($sp)
	.set	noreorder
	.set	nomacro
	j	$31
	addu	$sp,$sp,16
	.set	macro
	.set	reorder

	.end	test_mul__FUlUl

This is what is produced under wine

	.file	1 "test.cpp"
gcc2_compiled.:
__gnu_compiled_cplusplus:
	.text
	.align	3
	.globl	test_mul__FUlUl
	.text
	.ent	test_mul__FUlUl
test_mul__FUlUl:
	.frame	$sp,16,$31		# vars= 0, regs= 2/0, args= 0, extra= 0
	.mask	0x80000000,-16
	.fmask	0x00000000,0
	subu	$sp,$sp,16
	sq $31,0($sp)
	jal	__muldi3
	lq $31,0($sp)
	.set	noreorder
	.set	nomacro
	j	$31
	addu	$sp,$sp,16
	.set	macro
	.set	reorder

	.end	test_mul__FUlUl

(The only difference is the jal __mulll3 vs jal __muldi3)

Those were generated with the following flags:

ee/gcc/lib/gcc-lib/ee/2.95.3/cc1plus.exe -Os -quiet -g0 -fno-exceptions  test.cpp -o test_wibo.s

cc1plus.exe can be found here: https://github.com/AngheloAlf/sce_ps2_sdk_24/releases

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

No branches or pull requests

1 participant