Skip to content

Commit 3e7a84e

Browse files
taylorsimpsonrth7680
authored andcommitted
Hexagon build infrastructure
Add file to default-configs Add hexagon to meson.build Add hexagon to target/meson.build Add target/hexagon/meson.build Change scripts/qemu-binfmt-conf.sh We can build a hexagon-linux-user target and run programs on the Hexagon scalar core. With hexagon-linux-clang installed, "make check-tcg" will pass. Tested-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Taylor Simpson <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> [rth: Use top-level python variable] Signed-off-by: Richard Henderson <[email protected]>
1 parent 703c08d commit 3e7a84e

File tree

5 files changed

+199
-1
lines changed

5 files changed

+199
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TARGET_ARCH=hexagon

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ disassemblers = {
11881188
'arm' : ['CONFIG_ARM_DIS'],
11891189
'avr' : ['CONFIG_AVR_DIS'],
11901190
'cris' : ['CONFIG_CRIS_DIS'],
1191+
'hexagon' : ['CONFIG_HEXAGON_DIS'],
11911192
'hppa' : ['CONFIG_HPPA_DIS'],
11921193
'i386' : ['CONFIG_I386_DIS'],
11931194
'x86_64' : ['CONFIG_I386_DIS'],

scripts/qemu-binfmt-conf.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
qemu_target_list="i386 i486 alpha arm armeb sparc sparc32plus sparc64 \
55
ppc ppc64 ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \
66
sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \
7-
microblaze microblazeel or1k x86_64"
7+
microblaze microblazeel or1k x86_64 hexagon"
88

99
i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
1010
i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
@@ -136,6 +136,10 @@ or1k_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\
136136
or1k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
137137
or1k_family=or1k
138138

139+
hexagon_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xa4\x00'
140+
hexagon_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
141+
hexagon_family=hexagon
142+
139143
qemu_get_family() {
140144
cpu=${HOST_ARCH:-$(uname -m)}
141145
case "$cpu" in

target/hexagon/meson.build

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
##
2+
## Copyright(c) 2020-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
3+
##
4+
## This program is free software; you can redistribute it and/or modify
5+
## it under the terms of the GNU General Public License as published by
6+
## the Free Software Foundation; either version 2 of the License, or
7+
## (at your option) any later version.
8+
##
9+
## This program is distributed in the hope that it will be useful,
10+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
## GNU General Public License for more details.
13+
##
14+
## You should have received a copy of the GNU General Public License
15+
## along with this program; if not, see <http://www.gnu.org/licenses/>.
16+
##
17+
18+
hexagon_ss = ss.source_set()
19+
20+
hex_common_py = 'hex_common.py'
21+
attribs_def = meson.current_source_dir() / 'attribs_def.h.inc'
22+
gen_tcg_h = meson.current_source_dir() / 'gen_tcg.h'
23+
24+
#
25+
# Step 1
26+
# We use a C program to create semantics_generated.pyinc
27+
#
28+
gen_semantics = executable(
29+
'gen_semantics',
30+
'gen_semantics.c',
31+
native: true, build_by_default: false)
32+
33+
semantics_generated = custom_target(
34+
'semantics_generated.pyinc',
35+
output: 'semantics_generated.pyinc',
36+
input: gen_semantics,
37+
command: ['@INPUT@', '@OUTPUT@'],
38+
)
39+
hexagon_ss.add(semantics_generated)
40+
41+
#
42+
# Step 2
43+
# We use Python scripts to generate the following files
44+
# shortcode_generated.h.inc
45+
# helper_protos_generated.h.inc
46+
# tcg_funcs_generated.c.inc
47+
# tcg_func_table_generated.c.inc
48+
# helper_funcs_generated.c.inc
49+
# printinsn_generated.h.inc
50+
# op_regs_generated.h.inc
51+
# op_attribs_generated.h.inc
52+
# opcodes_def_generated.h.inc
53+
#
54+
shortcode_generated = custom_target(
55+
'shortcode_generated.h.inc',
56+
output: 'shortcode_generated.h.inc',
57+
input: 'gen_shortcode.py',
58+
depends: [semantics_generated],
59+
depend_files: [hex_common_py, attribs_def],
60+
command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
61+
)
62+
hexagon_ss.add(shortcode_generated)
63+
64+
helper_protos_generated = custom_target(
65+
'helper_protos_generated.h.inc',
66+
output: 'helper_protos_generated.h.inc',
67+
input: 'gen_helper_protos.py',
68+
depends: [semantics_generated],
69+
depend_files: [hex_common_py, attribs_def, gen_tcg_h],
70+
command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
71+
)
72+
hexagon_ss.add(helper_protos_generated)
73+
74+
tcg_funcs_generated = custom_target(
75+
'tcg_funcs_generated.c.inc',
76+
output: 'tcg_funcs_generated.c.inc',
77+
input: 'gen_tcg_funcs.py',
78+
depends: [semantics_generated],
79+
depend_files: [hex_common_py, attribs_def, gen_tcg_h],
80+
command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
81+
)
82+
hexagon_ss.add(tcg_funcs_generated)
83+
84+
tcg_func_table_generated = custom_target(
85+
'tcg_func_table_generated.c.inc',
86+
output: 'tcg_func_table_generated.c.inc',
87+
input: 'gen_tcg_func_table.py',
88+
depends: [semantics_generated],
89+
depend_files: [hex_common_py, attribs_def],
90+
command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
91+
)
92+
hexagon_ss.add(tcg_func_table_generated)
93+
94+
helper_funcs_generated = custom_target(
95+
'helper_funcs_generated.c.inc',
96+
output: 'helper_funcs_generated.c.inc',
97+
input: 'gen_helper_funcs.py',
98+
depends: [semantics_generated],
99+
depend_files: [hex_common_py, attribs_def, gen_tcg_h],
100+
command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
101+
)
102+
hexagon_ss.add(helper_funcs_generated)
103+
104+
printinsn_generated = custom_target(
105+
'printinsn_generated.h.inc',
106+
output: 'printinsn_generated.h.inc',
107+
input: 'gen_printinsn.py',
108+
depends: [semantics_generated],
109+
depend_files: [hex_common_py, attribs_def],
110+
command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
111+
)
112+
hexagon_ss.add(printinsn_generated)
113+
114+
op_regs_generated = custom_target(
115+
'op_regs_generated.h.inc',
116+
output: 'op_regs_generated.h.inc',
117+
input: 'gen_op_regs.py',
118+
depends: [semantics_generated],
119+
depend_files: [hex_common_py, attribs_def],
120+
command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
121+
)
122+
hexagon_ss.add(op_regs_generated)
123+
124+
op_attribs_generated = custom_target(
125+
'op_attribs_generated.h.inc',
126+
output: 'op_attribs_generated.h.inc',
127+
input: 'gen_op_attribs.py',
128+
depends: [semantics_generated],
129+
depend_files: [hex_common_py, attribs_def],
130+
command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
131+
)
132+
hexagon_ss.add(op_attribs_generated)
133+
134+
opcodes_def_generated = custom_target(
135+
'opcodes_def_generated.h.inc',
136+
output: 'opcodes_def_generated.h.inc',
137+
input: 'gen_opcodes_def.py',
138+
depends: [semantics_generated],
139+
depend_files: [hex_common_py, attribs_def],
140+
command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
141+
)
142+
hexagon_ss.add(opcodes_def_generated)
143+
144+
#
145+
# Step 3
146+
# We use a C program to create iset.py which is imported into dectree.py
147+
# to create the decode tree
148+
#
149+
gen_dectree_import = executable(
150+
'gen_dectree_import',
151+
'gen_dectree_import.c', opcodes_def_generated, op_regs_generated,
152+
native: true, build_by_default: false)
153+
154+
iset_py = custom_target(
155+
'iset.py',
156+
output: 'iset.py',
157+
input: gen_dectree_import,
158+
command: ['@INPUT@', '@OUTPUT@'],
159+
)
160+
hexagon_ss.add(iset_py)
161+
162+
#
163+
# Step 4
164+
# We use the dectree.py script to generate the decode tree header file
165+
#
166+
dectree_generated = custom_target(
167+
'dectree_generated.h.inc',
168+
output: 'dectree_generated.h.inc',
169+
input: 'dectree.py',
170+
depends: [iset_py],
171+
command: ['PYTHONPATH=' + meson.current_build_dir(), '@INPUT@', '@OUTPUT@'],
172+
)
173+
hexagon_ss.add(dectree_generated)
174+
175+
hexagon_ss.add(files(
176+
'cpu.c',
177+
'translate.c',
178+
'op_helper.c',
179+
'gdbstub.c',
180+
'genptr.c',
181+
'reg_fields.c',
182+
'decode.c',
183+
'iclass.c',
184+
'opcodes.c',
185+
'printinsn.c',
186+
'arch.c',
187+
'fma_emu.c',
188+
'conv_emu.c',
189+
))
190+
191+
target_arch += {'hexagon': hexagon_ss}

target/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ subdir('alpha')
22
subdir('arm')
33
subdir('avr')
44
subdir('cris')
5+
subdir('hexagon')
56
subdir('hppa')
67
subdir('i386')
78
subdir('lm32')

0 commit comments

Comments
 (0)