Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # The instruction set the compiler should use when generating application |
| 2 | # code. The kernel is always compiled with arm code at present. arm code |
| 3 | # is the original 32 bit ARM instruction set, thumb code is the 16 bit |
| 4 | # encoded RISC sub-set. Thumb code is smaller (maybe 70% of the ARM size) |
| 5 | # but requires more instructions (140% for 70% smaller code) so may be |
| 6 | # slower. |
| 7 | TUNEVALID[thumb] = "Use thumb instructions instead of ARM" |
| 8 | ARM_THUMB_OPT = "${@['arm', 'thumb'][d.getVar('ARM_INSTRUCTION_SET', True) == 'thumb']}" |
| 9 | ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv4', 't', '', d)}" |
| 10 | ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv5', 't', '', d)}" |
| 11 | ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv6', 't', '', d)}" |
| 12 | ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv7a', 't2', '', d)}" |
| 13 | ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv7r', 't2', '', d)}" |
| 14 | ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv7m', 't2', '', d)}" |
| 15 | |
| 16 | # If the device supports ARM, then respect ARM_THUMB_OPT (which can be "arm" or "thumb") |
| 17 | # If the defice doesn't support ARM, then always set "thumb" even when |
| 18 | # some recipe explicitly sets ARM_INSTRUCTION_SET to "arm" |
| 19 | ARM_M_OPT = "${@bb.utils.contains('TUNE_FEATURES', 'arm', '${ARM_THUMB_OPT}', 'thumb', d)}" |
| 20 | python () { |
| 21 | if bb.utils.contains('TUNE_FEATURES', 'thumb', 'False', 'True', d): |
| 22 | return |
| 23 | selected = d.getVar('ARM_INSTRUCTION_SET', True) |
| 24 | if selected == None: |
| 25 | return |
| 26 | used = d.getVar('ARM_M_OPT', True) |
| 27 | if selected != used: |
| 28 | pn = d.getVar('PN', True) |
| 29 | bb.warn("Recipe '%s' selects ARM_INSTRUCTION_SET to be '%s', but tune configuration overrides it to '%s'" % (pn, selected, used)) |
| 30 | } |
| 31 | |
| 32 | TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'thumb', ' -m${ARM_M_OPT}', '', d)}" |
| 33 | OVERRIDES .= "${@bb.utils.contains('TUNE_FEATURES', 'thumb', ':thumb', '', d)}" |
| 34 | |
| 35 | # Add suffix from ARM_THUMB_SUFFIX only if after all this we still set ARM_M_OPT to thumb |
| 36 | ARMPKGSFX_THUMB .= "${@bb.utils.contains('TUNE_FEATURES', 'thumb', '${ARM_THUMB_SUFFIX}', '', d) if d.getVar('ARM_M_OPT', True) == 'thumb' else ''}" |
| 37 | |
| 38 | # Whether to compile with code to allow interworking between the two |
| 39 | # instruction sets. This allows thumb code to be executed on a primarily |
| 40 | # arm system and vice versa. It is strongly recommended that DISTROs not |
| 41 | # turn this off - the actual cost is very small. |
| 42 | TUNEVALID[no-thumb-interwork] = "Disable mixing of thumb and ARM functions" |
| 43 | THUMB_TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'no-thumb-interwork', ' -mno-thumb-interwork', ' -mthumb-interwork', d)}" |
| 44 | THUMB_OVERRIDES .= "${@bb.utils.contains('TUNE_FEATURES', 'no-thumb-interwork', ':thumb-interwork', '', d)}" |
| 45 | TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'thumb', ' ${THUMB_TUNE_CCARGS}', '', d)}" |
| 46 | OVERRIDES .= "${@bb.utils.contains('TUNE_FEATURES', 'thumb', '${THUMB_OVERRIDES}', '', d)}" |
| 47 | |
| 48 | # what about armv7m devices which don't support -marm (e.g. Cortex-M3)? |
| 49 | TARGET_CC_KERNEL_ARCH += "${@bb.utils.contains('TUNE_FEATURES', 'thumb', '-mno-thumb-interwork -marm', '', d)}" |