From 7f75f97a075d94fced05bacc6a4b3890629900f6 Mon Sep 17 00:00:00 2001 From: Derek Hower Date: Mon, 14 Oct 2024 19:22:46 -0700 Subject: [PATCH 1/2] Add exception analysis back in generators --- backends/crd_doc/templates/crd.adoc.erb | 17 ++++++------- .../manual/templates/instruction.adoc.erb | 3 +-- .../templates/profile_pdf.adoc.erb | 17 ++++++------- lib/arch_obj_models/instruction.rb | 25 ++++++------------- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/backends/crd_doc/templates/crd.adoc.erb b/backends/crd_doc/templates/crd.adoc.erb index c2fe6cb851..0e221915ea 100644 --- a/backends/crd_doc/templates/crd.adoc.erb +++ b/backends/crd_doc/templates/crd.adoc.erb @@ -452,20 +452,17 @@ RV64:: ==== Exceptions -// TODO: add back after sym table update for generic arch def is merged in profiles branch -<%# -<%- exception_list = inst.reachable_exceptions_str(crd.arch_def.symtab) -% > -<%- if exception_list.empty? -% > +<%- exception_list = inst.reachable_exceptions_str(crd.arch_def.symtab) -%> +<%- if exception_list.empty? -%> This instruction does not generate synchronous exceptions. -<%- else -% > +<%- else -%> This instruction may result in the following synchronous exceptions: - <%- exception_list.sort.each do |etype| -% > - * <%= etype % > - <%- end -% > + <%- exception_list.sort.each do |etype| -%> + * <%= etype %> + <%- end -%> -<%- end -% > -%> +<%- end -%> <%- end -%> diff --git a/backends/manual/templates/instruction.adoc.erb b/backends/manual/templates/instruction.adoc.erb index 030b1a6005..9a53354036 100644 --- a/backends/manual/templates/instruction.adoc.erb +++ b/backends/manual/templates/instruction.adoc.erb @@ -108,8 +108,7 @@ RV64:: ---- <%- end -%> -<%# exception_list = inst.reachable_exceptions_str(inst.arch_def.sym_table_64, 64) -%> -<%- exception_list = [] -%> +<% exception_list = inst.reachable_exceptions_str(inst.arch_def.symtab, 64) -%> <%- unless exception_list.empty? -%> == Exceptions diff --git a/backends/profile_doc/templates/profile_pdf.adoc.erb b/backends/profile_doc/templates/profile_pdf.adoc.erb index ffe1f31369..4d03f12ba9 100644 --- a/backends/profile_doc/templates/profile_pdf.adoc.erb +++ b/backends/profile_doc/templates/profile_pdf.adoc.erb @@ -618,20 +618,17 @@ RV64:: ==== Exceptions -// TODO: add back after sym table update for generic arch def is merged in profiles branch -<%# -<%- exception_list = inst.reachable_exceptions_str(arch_def.symtab) -% > -<%- if exception_list.empty? -% > +<%- exception_list = inst.reachable_exceptions_str(arch_def.symtab) -%> +<%- if exception_list.empty? -%> This instruction does not generate synchronous exceptions. -<%- else -% > +<%- else -%> This instruction may result in the following synchronous exceptions: - <%- exception_list.sort.each do |etype| -% > - * <%= etype % > - <%- end -% > + <%- exception_list.sort.each do |etype| -%> + * <%= etype %> + <%- end -%> -<%- end -% > -%> +<%- end -%> <%- end -%> diff --git a/lib/arch_obj_models/instruction.rb b/lib/arch_obj_models/instruction.rb index 9b9fa0070d..0dcd681a13 100644 --- a/lib/arch_obj_models/instruction.rb +++ b/lib/arch_obj_models/instruction.rb @@ -160,7 +160,6 @@ def reachable_exceptions_str(symtab, effective_xlen=nil) if @data["operation()"].nil? [] else - # RubyProf.start etype = symtab.get("ExceptionCode") if effective_xlen.nil? if symtab.archdef.multi_xlen? @@ -174,21 +173,18 @@ def reachable_exceptions_str(symtab, effective_xlen=nil) puts "done" pruned_ast = pruned_operation_ast(symtab, 64) print "Determining reachable exceptions from #{name}#RV64..." - e64 = mask_to_array(prunted_ast.reachable_exceptions(fill_symtab(symtab, 64, pruned_ast))).map { |code| + e64 = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, 64, pruned_ast))).map { |code| etype.element_name(code) } - puts done + puts "done" e32 + e64 ).uniq else pruned_ast = pruned_operation_ast(symtab, base) print "Determining reachable exceptions from #{name}..." - result = RubyProf.profile do - e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, base, pruned_ast))).map { |code| - etype.element_name(code) - } - end - RubyProf::CallStackPrinter.new(result).print(File.open("#{name}-profile.html", "w+"), {}) + e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, base, pruned_ast))).map { |code| + etype.element_name(code) + } puts "done" e end @@ -196,12 +192,9 @@ def reachable_exceptions_str(symtab, effective_xlen=nil) effective_xlen = symtab.archdef.mxlen pruned_ast = pruned_operation_ast(symtab, effective_xlen) print "Determining reachable exceptions from #{name}..." - # result = RubyProf.profile do - e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, effective_xlen, pruned_ast))).map { |code| - etype.element_name(code) - } - # end - # RubyProf::FlameGraphPrinter.new(result).print(File.open("#{name}-profile.html", "w+"), {}) + e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, effective_xlen, pruned_ast))).map { |code| + etype.element_name(code) + } puts "done" e end @@ -215,8 +208,6 @@ def reachable_exceptions_str(symtab, effective_xlen=nil) puts "done" e end - # result = RubyProf.stop - # RubyProf::FlatPrinter.new(result).print(STDOUT) end end From b05682024b32c08bba1e1f4a9d866122524c6dd7 Mon Sep 17 00:00:00 2001 From: dhower-qc <134728312+dhower-qc@users.noreply.github.com> Date: Wed, 16 Oct 2024 21:37:00 -0400 Subject: [PATCH 2/2] Fix typo in instruction.rb Signed-off-by: dhower-qc <134728312+dhower-qc@users.noreply.github.com> --- lib/arch_obj_models/instruction.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/arch_obj_models/instruction.rb b/lib/arch_obj_models/instruction.rb index 0dcd681a13..1779b95905 100644 --- a/lib/arch_obj_models/instruction.rb +++ b/lib/arch_obj_models/instruction.rb @@ -202,7 +202,7 @@ def reachable_exceptions_str(symtab, effective_xlen=nil) pruned_ast = pruned_operation_ast(symtab, effective_xlen) print "Determining reachable exceptions from #{name}..." - e = mask_to_array(prunted_ast.reachable_exceptions(fill_symtab(symtab, effective_xlen, pruned_ast))).map { |code| + e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, effective_xlen, pruned_ast))).map { |code| etype.element_name(code) } puts "done"