This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Add support for target("arm") and target("thumb").

Authored by fhahn on May 31 2017, 6:11 AM.



This patch adds support for the target("arm") and target("thumb")
attributes, which can be used to force the compiler to generated ARM or
Thumb code for a function.

In LLVM, ARM or Thumb code generation can be controlled by the
thumb-mode target feature. But GCC already uses target("arm") and
target("thumb"), so we have to substitute "arm" with -thumb-mode and
"thumb" with +thumb-mode.

Diff Detail

Event Timeline

fhahn created this revision.May 31 2017, 6:11 AM
1774 ↗(On Diff #100854)

Would this be a more accurate comment:

"...arm and thumb to thumb-mode" => "arm and thumb to arm-mode or thumb-mode, respectively"
"[-|+] thumb-mode"

fhahn updated this revision to Diff 100880.May 31 2017, 9:41 AM

reworded comment and improved test case to ensure only a single thumb-mode attribute is added.

fhahn marked an inline comment as done.May 31 2017, 9:41 AM
echristo added inline comments.May 31 2017, 1:11 PM
1790–1794 ↗(On Diff #100880)

This is a little painful here - I wonder if we have access to TargetInfo or maybe translate it in the target specific area of the front end? I worry about this sort of thing getting unwieldy.


Otherwise OK.

fhahn updated this revision to Diff 100994.Jun 1 2017, 3:22 AM

Agreed, ARMTargetInfo is a much better place to do the conversion! Moved attribute conversion to ARMTargetInfo::initFeatureMap. Unfortunately FeaturesVec is const, so creating a mutable clone seemed the most straight-forward thing to do.

fhahn marked an inline comment as done.Jun 1 2017, 3:22 AM
echristo added inline comments.Jun 1 2017, 2:38 PM

Won't work below in handleTargetFeatures?

fhahn added inline comments.Jun 2 2017, 3:19 AM

Unfortunately I don't think so, as it seems like handleTargetFeatures is only called once in TargetInfo::CreateTargetInfo (
), while initFeatureMap is called for each function and thus can be used to modify the user provided target-features for individual functions (

ahatanak added inline comments.

This can be "else if".

fhahn updated this revision to Diff 101427.Jun 5 2017, 10:13 AM
fhahn marked an inline comment as done.

use else if

echristo accepted this revision.Jun 5 2017, 3:49 PM

Ah right. Thanks for looking.



This revision is now accepted and ready to land.Jun 5 2017, 3:49 PM
fhahn closed this revision.Jun 6 2017, 2:26 AM