blob: 5632171863f9a33f5250123ce82b349865dbc6a9 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# 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.
7TUNEVALID[thumb] = "Use thumb instructions instead of ARM"
8ARM_THUMB_OPT = "${@['arm', 'thumb'][d.getVar('ARM_INSTRUCTION_SET', True) == 'thumb']}"
9ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv4', 't', '', d)}"
10ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv5', 't', '', d)}"
11ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv6', 't', '', d)}"
12ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv7a', 't2', '', d)}"
13ARM_THUMB_SUFFIX .= "${@bb.utils.contains('TUNE_FEATURES', 'armv7r', 't2', '', d)}"
14ARM_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"
19ARM_M_OPT = "${@bb.utils.contains('TUNE_FEATURES', 'arm', '${ARM_THUMB_OPT}', 'thumb', d)}"
20python () {
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
32TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'thumb', ' -m${ARM_M_OPT}', '', d)}"
33OVERRIDES .= "${@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
36ARMPKGSFX_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.
42TUNEVALID[no-thumb-interwork] = "Disable mixing of thumb and ARM functions"
43THUMB_TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'no-thumb-interwork', ' -mno-thumb-interwork', ' -mthumb-interwork', d)}"
44THUMB_OVERRIDES .= "${@bb.utils.contains('TUNE_FEATURES', 'no-thumb-interwork', ':thumb-interwork', '', d)}"
45TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'thumb', ' ${THUMB_TUNE_CCARGS}', '', d)}"
46OVERRIDES .= "${@bb.utils.contains('TUNE_FEATURES', 'thumb', '${THUMB_OVERRIDES}', '', d)}"
47
48# what about armv7m devices which don't support -marm (e.g. Cortex-M3)?
49TARGET_CC_KERNEL_ARCH += "${@bb.utils.contains('TUNE_FEATURES', 'thumb', '-mno-thumb-interwork -marm', '', d)}"