Skip to content

Commit 8fd3ad1

Browse files
authored
Add exception analysis back in generators (#93)
* 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]>
1 parent ce35896 commit 8fd3ad1

File tree

4 files changed

+25
-40
lines changed

4 files changed

+25
-40
lines changed

backends/crd_doc/templates/crd.adoc.erb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,20 +455,18 @@ RV64::
455455

456456
==== Exceptions
457457

458-
// TODO: add back after sym table update for generic arch def is merged in profiles branch
459-
<%#
460-
<% exception_list = inst.reachable_exceptions_str(crd.arch_def.symtab) -% >
461-
<% if exception_list.empty? -% >
458+
<%- exception_list = inst.reachable_exceptions_str(crd.arch_def.symtab) -%>
459+
<%- if exception_list.empty? -%>
462460
This instruction does not generate synchronous exceptions.
463-
<% else -% >
461+
<%- else -%>
464462
This instruction may result in the following synchronous exceptions:
465463

466-
<% exception_list.sort.each do |etype| -% >
467-
* <%= etype % >
468-
<% end -% >
464+
<%- exception_list.sort.each do |etype| -%>
465+
* <%= etype %>
466+
<%- end -%>
467+
468+
<%- end -%>
469469

470-
<% end -% >
471-
%>
472470

473471
<% end -%>
474472

backends/manual/templates/instruction.adoc.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ RV64::
108108
----
109109
<%- end -%>
110110

111-
<%# exception_list = inst.reachable_exceptions_str(inst.arch_def.sym_table_64, 64) -%>
112-
<%- exception_list = [] -%>
111+
<% exception_list = inst.reachable_exceptions_str(inst.arch_def.symtab, 64) -%>
113112
<%- unless exception_list.empty? -%>
114113
== Exceptions
115114

backends/profile_doc/templates/profile_pdf.adoc.erb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -618,20 +618,17 @@ RV64::
618618

619619
==== Exceptions
620620

621-
// TODO: add back after sym table update for generic arch def is merged in profiles branch
622-
<%#
623-
<%- exception_list = inst.reachable_exceptions_str(arch_def.symtab) -% >
624-
<%- if exception_list.empty? -% >
621+
<%- exception_list = inst.reachable_exceptions_str(arch_def.symtab) -%>
622+
<%- if exception_list.empty? -%>
625623
This instruction does not generate synchronous exceptions.
626-
<%- else -% >
624+
<%- else -%>
627625
This instruction may result in the following synchronous exceptions:
628626

629-
<%- exception_list.sort.each do |etype| -% >
630-
* <%= etype % >
631-
<%- end -% >
627+
<%- exception_list.sort.each do |etype| -%>
628+
* <%= etype %>
629+
<%- end -%>
632630

633-
<%- end -% >
634-
%>
631+
<%- end -%>
635632

636633
<%- end -%>
637634

lib/arch_obj_models/instruction.rb

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ def reachable_exceptions_str(symtab, effective_xlen=nil)
160160
if @data["operation()"].nil?
161161
[]
162162
else
163-
# RubyProf.start
164163
etype = symtab.get("ExceptionCode")
165164
if effective_xlen.nil?
166165
if symtab.archdef.multi_xlen?
@@ -174,49 +173,41 @@ def reachable_exceptions_str(symtab, effective_xlen=nil)
174173
puts "done"
175174
pruned_ast = pruned_operation_ast(symtab, 64)
176175
print "Determining reachable exceptions from #{name}#RV64..."
177-
e64 = mask_to_array(prunted_ast.reachable_exceptions(fill_symtab(symtab, 64, pruned_ast))).map { |code|
176+
e64 = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, 64, pruned_ast))).map { |code|
178177
etype.element_name(code)
179178
}
180-
puts done
179+
puts "done"
181180
e32 + e64
182181
).uniq
183182
else
184183
pruned_ast = pruned_operation_ast(symtab, base)
185184
print "Determining reachable exceptions from #{name}..."
186-
result = RubyProf.profile do
187-
e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, base, pruned_ast))).map { |code|
188-
etype.element_name(code)
189-
}
190-
end
191-
RubyProf::CallStackPrinter.new(result).print(File.open("#{name}-profile.html", "w+"), {})
185+
e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, base, pruned_ast))).map { |code|
186+
etype.element_name(code)
187+
}
192188
puts "done"
193189
e
194190
end
195191
else
196192
effective_xlen = symtab.archdef.mxlen
197193
pruned_ast = pruned_operation_ast(symtab, effective_xlen)
198194
print "Determining reachable exceptions from #{name}..."
199-
# result = RubyProf.profile do
200-
e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, effective_xlen, pruned_ast))).map { |code|
201-
etype.element_name(code)
202-
}
203-
# end
204-
# RubyProf::FlameGraphPrinter.new(result).print(File.open("#{name}-profile.html", "w+"), {})
195+
e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, effective_xlen, pruned_ast))).map { |code|
196+
etype.element_name(code)
197+
}
205198
puts "done"
206199
e
207200
end
208201
else
209202
pruned_ast = pruned_operation_ast(symtab, effective_xlen)
210203

211204
print "Determining reachable exceptions from #{name}..."
212-
e = mask_to_array(prunted_ast.reachable_exceptions(fill_symtab(symtab, effective_xlen, pruned_ast))).map { |code|
205+
e = mask_to_array(pruned_ast.reachable_exceptions(fill_symtab(symtab, effective_xlen, pruned_ast))).map { |code|
213206
etype.element_name(code)
214207
}
215208
puts "done"
216209
e
217210
end
218-
# result = RubyProf.stop
219-
# RubyProf::FlatPrinter.new(result).print(STDOUT)
220211
end
221212
end
222213

0 commit comments

Comments
 (0)