-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
draft: hexagon system emulation initial #99
base: tip
Are you sure you want to change the base?
Changes from 8 commits
521f902
1cb87d4
736cebe
64d2954
de05b22
31efbf2
87b2699
368dd86
8c2e641
ce5058f
c6fd603
e976e8e
7220f12
c0bbdbd
f18e9bd
0451994
b7fff0a
7ad9f91
2809f85
ade7eec
b961c8e
7ad78ae
79ccf99
e43d4f1
cd9ce8b
8bb107c
5836715
b894648
95f9dac
404f998
51ddc6c
3fdb2f0
46b7c36
d08ab18
903067d
49b7120
17e09db
560243f
0c3f47f
d82c776
f2e343c
7411a69
ad71d23
3243399
2ce28d3
8cc9d4a
dbf9147
29c5a16
9dcba11
edf745f
ea7ac92
1ed4048
75bd590
2af5088
d905f73
a7f2da3
f700155
6a9cc68
b72c595
15e0625
9fc10a7
5026cc9
9c30064
209a966
5186210
64f749a
4e99d60
14e3167
189c35b
a1e454d
5df06af
24f2069
93a8b32
f0c8321
ba898c1
223548b
5262161
95a2d24
c968627
28c8c09
018dcf7
6ec1673
9df8d78
206e1cb
7212626
a72e283
2d3237b
0c23a77
d819f50
4ace7fa
aebf62b
4433c21
515be7f
ccf017d
2163ff5
61f5ce8
4237944
d4d0a5f
ea6db76
8932b0c
ab9a180
55a84e3
cc1b794
1dd8d5d
c425299
3a44861
3440997
6f08d02
1298fe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,14 @@ def gen_analyze_func(f, tag, regs, imms): | |
f.write(f"static void analyze_{tag}(DisasContext *ctx)\n") | ||
f.write("{\n") | ||
|
||
if hex_common.tag_ignore(tag): | ||
f.write("}\n\n") | ||
return | ||
|
||
if ("A_PRIV" in hex_common.attribdict[tag] or | ||
"A_GUEST" in hex_common.attribdict[tag]): | ||
f.write("#ifndef CONFIG_USER_ONLY\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be outside the function definition?
|
||
|
||
f.write(" Insn *insn G_GNUC_UNUSED = ctx->insn;\n") | ||
if (hex_common.is_hvx_insn(tag)): | ||
if hex_common.has_hvx_helper(tag): | ||
|
@@ -74,6 +82,10 @@ def gen_analyze_func(f, tag, regs, imms): | |
if reg.is_written(): | ||
reg.analyze_write(f, tag, regno) | ||
|
||
if ("A_PRIV" in hex_common.attribdict[tag] or | ||
"A_GUEST" in hex_common.attribdict[tag]): | ||
f.write("#endif /* !CONFIG_USER_ONLY */\n") | ||
|
||
f.write("}\n\n") | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,26 +109,23 @@ def main(): | |
tagimms = hex_common.get_tagimms() | ||
|
||
with open(args.out, "w") as f: | ||
for tag in hex_common.tags: | ||
## Skip the priv instructions | ||
if "A_PRIV" in hex_common.attribdict[tag]: | ||
for tag in hex_common.get_user_tags(): | ||
if hex_common.tag_ignore(tag): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the I think it makes it easier to understand the motivation behind this helper function if added together with its use here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest combining this patch with the one that defines get_user_tags Have get_user_tags/get_sys_tags/get_all_tags remove that tag_ignore ones, so you don't have to check it here. |
||
continue | ||
## Skip the guest instructions | ||
if "A_GUEST" in hex_common.attribdict[tag]: | ||
continue | ||
## Skip the diag instructions | ||
if tag == "Y6_diag": | ||
continue | ||
if tag == "Y6_diag0": | ||
if hex_common.skip_qemu_helper(tag): | ||
continue | ||
if tag == "Y6_diag1": | ||
if hex_common.is_idef_parser_enabled(tag): | ||
continue | ||
gen_helper_function(f, tag, tagregs, tagimms) | ||
|
||
f.write("#if !defined(CONFIG_USER_ONLY)\n") | ||
for tag in hex_common.get_sys_tags(): | ||
if hex_common.skip_qemu_helper(tag): | ||
continue | ||
if hex_common.is_idef_parser_enabled(tag): | ||
continue | ||
|
||
gen_helper_function(f, tag, tagregs, tagimms) | ||
f.write("#endif\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,8 @@ def main(): | |
f.write('#include "macros.h.inc"\n\n') | ||
|
||
for tag in hex_common.tags: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hex_common.get_user_tags() Pretty sure idef parser doesn't deal with system instructions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, and we actually skip those below: ## Skip the priv instructions
if "A_PRIV" in hex_common.attribdict[tag]:
continue
## Skip the guest instructions
if "A_GUEST" in hex_common.attribdict[tag]:
continue So we can probably remove these |
||
if hex_common.tag_ignore(tag): | ||
continue | ||
## Skip the priv instructions | ||
if "A_PRIV" in hex_common.attribdict[tag]: | ||
continue | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,10 @@ def main(): | |
## Generate a list of all the opcodes | ||
## | ||
with open(args.out, "w") as f: | ||
for tag in hex_common.tags: | ||
for tag in hex_common.get_user_tags(): | ||
f.write(f"OPCODE({tag}),\n") | ||
|
||
for tag in hex_common.get_sys_tags(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrap these with #ifndef CONFIG_USER_ONLY |
||
f.write(f"OPCODE({tag}),\n") | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,19 +41,9 @@ def main(): | |
f.write("#define HEXAGON_FUNC_TABLE_H\n\n") | ||
|
||
f.write("const SemanticInsn opcode_genptr[XX_LAST_OPCODE] = {\n") | ||
|
||
for tag in hex_common.tags: | ||
## Skip the priv instructions | ||
if "A_PRIV" in hex_common.attribdict[tag]: | ||
continue | ||
## Skip the guest instructions | ||
if "A_GUEST" in hex_common.attribdict[tag]: | ||
continue | ||
## Skip the diag instructions | ||
if tag == "Y6_diag": | ||
continue | ||
if tag == "Y6_diag0": | ||
continue | ||
if tag == "Y6_diag1": | ||
if hex_common.tag_ignore(tag): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you modify the get_*_tags functions to remove the tag_ignore functions, this could be `for tag in hex_common.get_all_tags(): It seems like your intent is to remove all uses of hex_common.tags, correct?` |
||
continue | ||
|
||
f.write(f" [{tag}] = generate_{tag},\n") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
import re | ||
import string | ||
import hex_common | ||
|
||
from textwrap import dedent | ||
|
||
## | ||
## Generate the TCG code to call the helper | ||
|
@@ -50,6 +50,18 @@ def gen_tcg_func(f, tag, regs, imms): | |
|
||
f.write(" Insn *insn G_GNUC_UNUSED = ctx->insn;\n") | ||
|
||
if "A_PRIV" in hex_common.attribdict[tag]: | ||
f.write(dedent("""\ | ||
#ifdef CONFIG_USER_ONLY | ||
hex_gen_exception_end_tb(ctx, HEX_CAUSE_PRIV_USER_NO_SINSN); | ||
#else | ||
""")) | ||
if "A_GUEST" in hex_common.attribdict[tag]: | ||
f.write(dedent("""\ | ||
#ifdef CONFIG_USER_ONLY | ||
hex_gen_exception_end_tb(ctx, HEX_CAUSE_PRIV_USER_NO_GINSN); | ||
#else | ||
""")) | ||
if hex_common.need_ea(tag): | ||
f.write(" TCGv EA G_GNUC_UNUSED = tcg_temp_new();\n") | ||
|
||
|
@@ -97,6 +109,11 @@ def gen_tcg_func(f, tag, regs, imms): | |
if reg.is_written(): | ||
reg.log_write(f, tag) | ||
|
||
if ( | ||
"A_PRIV" in hex_common.attribdict[tag] | ||
or "A_GUEST" in hex_common.attribdict[tag] | ||
): | ||
f.write("#endif /* CONFIG_USER_ONLY */\n") | ||
f.write("}\n\n") | ||
|
||
|
||
|
@@ -121,18 +138,7 @@ def main(): | |
f.write('#include "idef-generated-emitter.h.inc"\n\n') | ||
|
||
for tag in hex_common.tags: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comments on prior patch regarding hex_common.get_all_tags() and tag_ignore. |
||
## Skip the priv instructions | ||
if "A_PRIV" in hex_common.attribdict[tag]: | ||
continue | ||
## Skip the guest instructions | ||
if "A_GUEST" in hex_common.attribdict[tag]: | ||
continue | ||
## Skip the diag instructions | ||
if tag == "Y6_diag": | ||
continue | ||
if tag == "Y6_diag0": | ||
continue | ||
if tag == "Y6_diag1": | ||
if hex_common.tag_ignore(tag): | ||
continue | ||
|
||
gen_def_tcg_func(f, tag, tagregs, tagimms) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For tag_ignore's, we should bail early and never need to generate the analyze function.