Skip to content
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

Add exception analysis back in generators #93

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions backends/crd_doc/templates/crd.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -455,20 +455,18 @@ 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 -%>

Expand Down
3 changes: 1 addition & 2 deletions backends/manual/templates/instruction.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 7 additions & 10 deletions backends/profile_doc/templates/profile_pdf.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>

Expand Down
27 changes: 9 additions & 18 deletions lib/arch_obj_models/instruction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -174,49 +173,41 @@ 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
else
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
else
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"
e
end
# result = RubyProf.stop
# RubyProf::FlatPrinter.new(result).print(STDOUT)
end
end

Expand Down
Loading