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

Differentiating between CM33 and CM85 with preprocessor #159

Open
renesas-kyle-finch opened this issue May 7, 2024 · 5 comments
Open

Differentiating between CM33 and CM85 with preprocessor #159

renesas-kyle-finch opened this issue May 7, 2024 · 5 comments
Labels
question Further information is requested

Comments

@renesas-kyle-finch
Copy link
Contributor

In a previous issue submitted to CMSIS 5, I was told that it was no longer advisable to use the arch defines like __ARM_ARCH_8M_MAIN__ and to instead use __ARM_ARCH.

But dumping preprocessor defines for CM33 and CM85 both yield the same __ARM_ARCH* defines:

// Using GCC 13.2
#define __ARM_ARCH 8
#define __ARM_ARCH_8M_MAIN__ 1
#define __ARM_ARCH_EXT_IDIV__ 1
#define __ARM_ARCH_ISA_THUMB 2
#define __ARM_ARCH_PROFILE 77

Note that GCC generates __ARM_ARCH_8M_MAIN__ for both CM33 and CM85.

LLVM 17 generates the same as GCC, with the exception that it generates __ARM_ARCH_8_1M_MAIN__ for CM85.

How should CM33 and CM85 be differentiated with the preprocessor?

@JonatanAntoni
Copy link
Member

Hi @renesas-kyle-finch,

this seems still to be a shortcoming in GCC. According to ACLE one should be able to detect the architecture by looking to __ARM_ARCH, see https://developer.arm.com/documentation/101028/0012/5--Feature-test-macros.

I'll pass this on to our GCC experts.

@renesas-kyle-finch
Copy link
Contributor Author

@JonatanAntoni thank you.

To be clear, both GCC and LLVM both produce __ARM_ARCH 8 for both CM33 and CM85. From the link you provided, I would expect that they would produce __ARM_ARCH 8 for CM33 and __ARM_ARCH 801 for CM85.

Does that match your expectations as well?

@renesas-kyle-finch
Copy link
Contributor Author

renesas-kyle-finch commented May 8, 2024

From some more testing of CM85 with multiple toolchains, this is what I am seeing for __ARM_ARCH and __ARM_ARCH_xx__

Toolchain __ARM_ARCH __ARM_ARCH_xx__
GCC 8 __ARM_ARCH_8M_MAIN__
LLVM 8 __ARM_ARCH_8_1M_MAIN__
AC6 8 __ARM_ARCH_8_1M_MAIN__
IAR 801 __ARM_ARCH_8M_MAIN__

So it seems neither paradigm produces correct output across all of these toolchains.

@ReinhardKeil
Copy link
Contributor

CMSIS contains the revision number of each core using these defines:
https://arm-software.github.io/CMSIS_6/v6.0.0/Core/group__device__config.html

Even when a device vendor does not provide the exact revision of the implementation, the fallback ensures that this define exists:

This information is therefore less dependent on Compiler internal defines specified by ACLE and maybe easier to query.

#if defined (__CM85_REV)    // running on Cortex-M85
 ...

I hope this helps.

@renesas-kyle-finch
Copy link
Contributor Author

I will give that a try.

As far as looking to the future, are the __ARM_ARCH and __ARM_ARCH_ISA_THUMB macros still the advised macros to use and what the compilers should be striving to produce?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants