Skip to content

Commit

Permalink
Merge pull request #122 from riscv-software-src/ext_pdf
Browse files Browse the repository at this point in the history
Make extension doc generation work with extensions that are missing data
  • Loading branch information
dhower-qc authored Oct 18, 2024
2 parents fb1cf3d + 52443b4 commit b1695f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
32 changes: 15 additions & 17 deletions backends/ext_pdf_doc/templates/ext_pdf.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
raise "TODO: #{ext_version["state"]} description"
end
%>
:company: <%= ext.company["name"] %>
:company: <%= ext.company.nil? ? "unknown" : ext.company["name"] %>
:url-riscv: https://riscv.org
:doctype: book
:preface-title: Licensing and Acknowledgements
Expand Down Expand Up @@ -119,20 +119,22 @@ endif::[]

[preface]
== Copyright and license information
This document is released under the <%= ext.doc_license["url"] %>[<%= ext.doc_license["name"] %>].
This document is released under the <%= ext.doc_license.nil? ? "unknown" : ext.doc_license["url"] %>[<%= ext.doc_license.nil? ? "unknown" : ext.doc_license["name"] %>].

Copyright <%= ext_version["ratification_date"].split("-")[0] %> by <%= ext.company["name"] %>.
Copyright <%= ext_version["ratification_date"].split("-")[0] %> by <%= ext.company.nil? ? "unknown" : ext.company["name"] %>.

[preface]
== Acknowledgements

<%- ext.versions.each do |version| -%>
Contributors to version <%= version["version"] %> of the specification (in alphabetical order) include: +

<%- unless version["contributors"].nil? -%>
<%- version["contributors"].sort { |a, b| a["name"].split(" ").last <=> b["name"].split(" ").last }.each do |c| -%>
* <%= c["name"] %> <<%= c["email"] %>> (<%= c["company"] %>)
<%- end -%>
<%- end -%>
<%- end -%>

We express our gratitude to everyone that contributed to, reviewed or
improved this specification through their comments and questions.
Expand Down Expand Up @@ -252,7 +254,7 @@ This CSR format changes dynamically.
<%- csr.fields.each do |field| -%>
| xref:<%=csr.name%>-<%=field.name%>-def[`<%= field.name %>`]
| <%= field.location_pretty(arch_def) %>
| <%= field.type_pretty(arch_def) %>
| <%= field.type_pretty(arch_def.symtab) %>
| <%= field.reset_value_pretty(arch_def) %>

<%- end -%>
Expand All @@ -278,7 +280,7 @@ Description::
<%= field.description %>

Type::
<%= field.type_pretty(arch_def) %>
<%= field.type_pretty(arch_def.symtab) %>

Reset value::
<%= field.reset_value_pretty(arch_def) %>
Expand Down Expand Up @@ -315,7 +317,7 @@ This CSR may return a value that is different from what is stored in hardware.

[source,idl,subs="specialchars,macros"]
----
<%= csr.sw_read_ast(arch_def.idl_compiler).gen_adoc %>
<%= csr.sw_read_ast(arch_def.symtab).gen_adoc %>
----
<%- end -%>

Expand Down Expand Up @@ -415,30 +417,26 @@ RV64::
<%- end -%>

Operation::
<%- unless i.data["operation()"].nil? -%>
[source,idl,subs="specialchars,macros"]
----
<%= i.operation_ast(arch_def.idl_compiler).gen_adoc %>
<%= i.operation_ast(arch_def.symtab).gen_adoc %>
----
<%- end -%>

Included in::
[%header,cols="4,2"]
|===
|Extension
|Minimum version

<%- i.defined_by.each do |ext_req| -%>
|<%= ext_req.name %>
|<%= ext_req.version_requirement %>
<%- end -%>
|===
<%= i.defined_by.to_asciidoc %>


<<<
<%- end -%>
<%- end -%>

<<<
== IDL Functions

<%- ext.reachable_functions_unevaluated.sort { |a,b| a.name <=> b.name }.each do |f| -%>
<%- ext.reachable_functions(arch_def.symtab).sort { |a,b| a.name <=> b.name }.each do |f| -%>
[#<%= f.name %>-func-def]
=== <%= f.name %><%- if f.builtin? -%> (builtin)<%- end -%>

Expand Down
4 changes: 2 additions & 2 deletions lib/arch_obj_models/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ def reachable_functions_unevaluated

funcs = []
instructions.each do |inst|
funcs += inst.operation_ast(arch_def.idl_compiler).reachable_functions_unevaluated(arch_def)
funcs += inst.operation_ast(arch_def.symtab).reachable_functions(arch_def.symtab)
end

csrs.each do |csr|
funcs += csr.reachable_functions_unevaluated(arch_def)
funcs += csr.reachable_functions(arch_def)
end

@reachable_functions_unevaluated = funcs.uniq(&:name)
Expand Down

0 comments on commit b1695f8

Please sign in to comment.