This is an archive of the discontinued LLVM Phabricator instance.

[ARM][CMSE] Add commandline option and feature macro
ClosedPublic

Authored by javed.absar on Mar 27 2019, 7:07 AM.

Details

Summary

This is first in series of patches following the RFC http://lists.llvm.org/pipermail/cfe-dev/2019-March/061834.html informing the community about providing CMSE support in clang/llvm.

This is patch C1 (as mentioned in the RFC).

It defines macro ARM_FEATURE_CMSE to 1 for v8-M targets and introduces -mcmse option which for v8-M targets sets ARM_FEATURE_CMSE to 3. A diagnostic is produced when the option is given on architectures without support for Security Extensions.

Diff Detail

Repository
rC Clang

Event Timeline

javed.absar created this revision.Mar 27 2019, 7:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2019, 7:07 AM
snidertm added inline comments.Mar 28 2019, 3:01 PM
lib/Basic/Targets/ARM.cpp
438

How does CPUProfile get a value of "B"? I thought any Cortex-M processor would set CPUProfile to "M". Is CMSE available on a processor besides Cortex-m33?

dmgreen added inline comments.
include/clang/Driver/Options.td
2148

Should this say something about compiling for secure state?

lib/Basic/Targets/ARM.cpp
438

"B" was going to be a very old name for v8m-baseline, looks like this one was never cleaned up when that was changed. You can drop the != "B" check.

lib/Driver/ToolChains/Clang.cpp
1427

Don't need the brackets here

lib/Frontend/CompilerInvocation.cpp
2732

This comment seems superfluous

snidertm added inline comments.Mar 29 2019, 6:57 AM
lib/Basic/Targets/ARM.cpp
438

Do all v8 profile == 'M' processor variants support security extensions?

javed.absar marked 4 inline comments as done.May 16 2019, 6:51 AM
javed.absar added inline comments.
lib/Basic/Targets/ARM.cpp
438

Yes

Updated based on review comments

dmgreen accepted this revision.May 16 2019, 10:01 AM

LGTM. With one comment that I will leave to you for what you think is best.

include/clang/Driver/Options.td
2148

Maybe "Enables generation of secure code for CMSE (Armv8-M Security Extensions)".

I meant to say that non-secure code can still be compiled without this flag, and can use some cmse features (as far as I understand). Its the secure side that needs this flag to do the clearing of registers and whatnot.

This revision is now accepted and ready to land.May 16 2019, 10:01 AM
snidertm accepted this revision.May 20 2019, 7:49 AM
This revision was automatically updated to reflect the committed changes.