English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 17 January 2024, 21:26   #1
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,002
VBCC complaining about specifying registers in the function declaration

Hello,

In a project of mine which contains 68K parts and PPC (WarpOS parts) I recently observed that the compiler is complaining about when I assign certain registers to parameters. The project initially was compiled in 2021. I only updated the 68K parts since and I updated VBCC somewhere in 2022. So the PPC objects file were from 2021 still.

Now recently, a recompile was triggered for the PPC parts and now I get all these warnings that were not there in 2021, so I guess something changed in an update of VBCC.

The functions just assign the standard registers to the parameters, so first parameter = r3 2nd = r4 etc. I can no longer recall why I did that :-) but it didn't give warnings before.

So something like:

Code:
PPCFUNCTION VOID FreeVec68K(__reg("r3") struct PrivatePPCBase* PowerPCBase, __reg("r4") APTR memBlock)
now give warnings (3 or 4 per function; I am on my phone right now but can give more specifics regarding which warnings when needed, also which VBCC version I am using now) that it didn't with the older VBCC version.

How do I fix this?
Hedeon is offline  
Old 17 January 2024, 21:39   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Hmm. It shouldn't. I cannot check your exact example, because I neither know
PPCFUNCTION
nor
PrivatePPCBase
, but the following simple test definitely works with the last release vbccppc:
Code:
frank@nerthus cat tst.c
void f(__reg("r3") void *x, __reg("r4") void *y)
{
}
frank@nerthus vc +warpos -c tst.c
frank@nerthus ll tst.o
-rw-r--r--  1 frank  users  116 Jan 17 21:35 tst.o
frank@nerthus vbccppc
vbcc V0.9h (c) in 1995-2022 by Volker Barthelmann
vbcc code-generator for PPC V0.7 (c) in 1997-2022 by Volker Barthelmann
I guess I need a real example to work with.
phx is offline  
Old 17 January 2024, 21:47   #3
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,002
https://github.com/Sakura-IT/PowerPC...r/supportppc.c

So the declarations in internalsppc.h do not have the __reg stuff in it. Not sure if that is the problem. PPCFUNCTION just puts the PPC stuff in its own section (internalsppc.h). PrivatePPCBase is just a wrapper for the WarpOS powerpc.library base with added stuff that my own powerpc.library uses (libstructs.h).

Everything worked before.. I mean it still works...just 4 warnings for every function.
Hedeon is offline  
Old 17 January 2024, 21:57   #4
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,002
I am using 0.9h I see now. Warnings are 368, 68, 368 and 123 for each function
Hedeon is offline  
Old 17 January 2024, 22:04   #5
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by Hedeon View Post
So the declarations in internalsppc.h do not have the __reg stuff in it. Not sure if that is the problem.
It is.
Might look stupid in this case, because you specified the correct registers for the ABI, but I guess that the parameter check is done by some general code in the compiler core, which doesn't know the ABI.

Quote:
PPCFUNCTION just puts the PPC stuff in its own section (internalsppc.h).
Strangely this doesn't cause a warning - I would expect one.

Anyway, just write the function declaration the same way as the definition and you have no problems!
phx is offline  
Old 17 January 2024, 22:07   #6
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,002
Quote:
Originally Posted by phx View Post
Strangely this doesn't cause a warning - I would expect one.
Now I am intrigued. Why? :-)

Code:
#define PPCFUNCTION __section ("functions","acrx") __entry
#define PPCKERNEL __section ("kernel","acrx") __entry
#define PPCSETUP __section (".setupppc","acrx") __entry
Hedeon is offline  
Old 17 January 2024, 22:22   #7
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,002
Quote:
Originally Posted by phx View Post
It is.
Anyway, just write the function declaration the same way as the definition and you have no problems!
I did a small test with 1 function and it worked.

Pfffff why did it work before? :-D Now I have to edit 200 function declarations. And some of them are used by the 68K side too, those are complaining now about unknown registers haha. Anyway, I have some puzzle to solve.

Thanks!
Hedeon is offline  
Old 18 January 2024, 00:42   #8
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by Hedeon View Post
Now I am intrigued. Why? :-)
Because a function with with a
__section
attribute shouldn't match a previous function declaration without one?

Quote:
Originally Posted by Hedeon View Post
Pfffff why did it work before? :-D
I guess that was something which needed improvement.
It seemed like a good idea to warn about such differences. Although I would have to read the C-specs if it is really required.

Quote:
Now I have to edit 200 function declarations. And some of them are used by the 68K side too, those are complaining now about unknown registers haha.
Isn't it easier to remove the unnecessary
__reg()
s in the PPC code? Or do you have register arguments in the 68k code as well?
In the worst case you can still write declarations for each cpu, separated by
#ifdef __M68K__
or
__PPC__
.
phx is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
out of registers meynaf Coders. Asm / Hardware 45 30 August 2023 13:51
fd2pragma inline entry for function that returns pointer to another function Sim085 Coders. C/C++ 11 02 March 2022 10:38
VBCC: Restrict usage of registers in C Hedeon Coders. C/C++ 12 01 July 2020 11:42
Preservation of registers guy lateur Coders. Asm / Hardware 51 26 October 2018 14:33
__builtin_ function link library for vbcc matthey Coders. C/C++ 1 25 March 2016 23:28

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:47.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07971 seconds with 15 queries