[cfe-dev] Emit target specific defines based on CodeGenOptions

Tamas Petz via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 26 01:35:57 PDT 2020


Dear List,

I am looking into adding some new Arm-specific feature test macros defined by the latest release of ACLE: https://developer.arm.com/docs/101028/0010/feature-test-macros

Namely these areĀ __ARM_FEATURE_BTI_DEFAULT andĀ __ARM_FEATURE_PAC_DEFAULT.

However, CodeGenOptions is not accessible from TargetInfo, as far as I can tell, and there is no use-case for emitting such a define as of today.

I am asking for some advice how to implement it correctly.

I think there are three possible solutions:

1. Refactor getTargetDefines() to have CodeGenOptions as argument, pass CodeGenOptions through preprocessor.

2. Use adjustTargetOptions(), remove const qualifier, store state in AArch64TargetInfo, use stored state to generate macros.

3. Add new virtual function to TargetInfo (getTargetDefinesCGO()?), pass CodeGenOptions through preprocessor, invoke getTargetDefinesCGO() right after getTargetDefines().

I would prefer option 1 but it is a massive diff.

What do you think? Is there a better way to achieve this?

Looking forward to you comments.

Best regards,
Tamas Petz

u.i.: should be there a disclaimer in this mail, please ignore it.


More information about the cfe-dev mailing list