Skip to content

Commit 25e3bf8

Browse files
author
Derek Hower
committed
Initial crack at manuals
1 parent b3756c1 commit 25e3bf8

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "ext/docs-resources"]
55
path = ext/docs-resources
66
url = https://github.com/riscv/docs-resources.git
7+
[submodule "ext/riscv-isa-manual"]
8+
path = ext/riscv-isa-manual
9+
url = https://github.com/riscv/riscv-isa-manual

backends/arch_gen/tasks.rake

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,34 @@ file "#{$root}/.stamps/arch-gen.stamp" => (
6666
profile_obj[profile_name]["__source"] = f
6767
[profile_name, profile_obj[profile_name]]
6868
end.to_h
69+
manual_hash = {}
70+
Dir.glob($root / "arch" / "manual" / "**" / "contents.yaml").map do |f|
71+
manual_version = YAML.load_file(f)
72+
manual_id = manual_version["manual"]
73+
unless manual_hash.key?(manual_id)
74+
manual_info_files = Dir.glob($root / "arch" / "manual" / "**" / "#{manual_id}.yaml")
75+
raise "Could not find manual info '#{manual_id}'.yaml, needed by #{f}" if manual_info_files.empty?
76+
raise "Found multiple manual infos '#{manual_id}'.yaml, needed by #{f}" if manual_info_files.size > 1
77+
78+
manual_info_file = manual_info_files.first
79+
manual_hash[manual_id] = YAML.load_file(manual_info_file)
80+
manual_hash[manual_id]["__source"] = manual_info_file
81+
# TODO: schema validation
82+
end
83+
84+
manual_hash[manual_id]["versions"] ||= []
85+
manual_hash[manual_id]["versions"] << YAML.load_file(f)
86+
# TODO: schema validation
87+
manual_hash[manual_id]["versions"].last["__source"] = f
88+
end
6989

7090
arch_def = {
7191
"instructions" => inst_hash,
7292
"extensions" => ext_hash,
7393
"csrs" => csr_hash,
7494
"profile_families" => profile_family_hash,
75-
"profiles" => profile_hash
95+
"profiles" => profile_hash,
96+
"manuals" => manual_hash
7697
}
7798

7899
dest = "#{$root}/gen/_/arch/arch_def.yaml"

ext/riscv-isa-manual

Submodule riscv-isa-manual added at 3539eff

lib/arch_def.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
require_relative "idl/passes/reachable_functions"
1212
require_relative "idl/passes/reachable_functions_unevaluated"
1313
require_relative "idl/passes/reachable_exceptions"
14+
require_relative "arch_obj_models/manual"
1415
require_relative "arch_obj_models/profile"
1516
require_relative "arch_obj_models/csr_field"
1617
require_relative "arch_obj_models/csr"
@@ -224,6 +225,31 @@ def function(name)
224225
function_hash[name]
225226
end
226227

228+
# @return [Array<Manual>] List of all manuals defined by the architecture
229+
def manuals
230+
return @manuals unless @manuals.nil?
231+
232+
@manuals = []
233+
@arch_def["manuals"].each_value do |manual_data|
234+
@manuals << Manual.new(manual_data, self)
235+
end
236+
@manuals
237+
end
238+
239+
# @return [Hash<String, Manual>] All manuals, indexed by name
240+
def manuals_hash
241+
return @manuals_hash unless @manuals_hash.nil?
242+
243+
@manuals_hash = {}
244+
manuals.each do |manual|
245+
@manuals_hash[manual.name] = manual
246+
end
247+
@manuals_hash
248+
end
249+
250+
# @return [Manual,nil] A manual named +name+, or nil if it doesn't exist
251+
def manual(name) = manuals_hash[name]
252+
227253
# @return [Array<ProfileFamily>] All known profile families
228254
def profile_families
229255
return @profile_families unless @profile_families.nil?

0 commit comments

Comments
 (0)