Skip to content

Commit

Permalink
Add exception analysis back in generators (#93)
Browse files Browse the repository at this point in the history
* Add exception analysis back in generators

* Fix typo in instruction.rb

Signed-off-by: dhower-qc <[email protected]>

---------

Signed-off-by: dhower-qc <[email protected]>
  • Loading branch information
dhower-qc authored Oct 17, 2024
1 parent ce35896 commit 8fd3ad1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 40 deletions.
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

0 comments on commit 8fd3ad1

Please sign in to comment.