Skip to content

Commit ea9171f

Browse files
author
Derek Hower
committed
Merge remote-tracking branch 'rvi/main' into manual_appendices
2 parents 4b6691b + e1e595b commit ea9171f

File tree

10 files changed

+66
-68
lines changed

10 files changed

+66
-68
lines changed

arch/crd/MC-1.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ MC-1:
88
# semantic version within the CRD family
99
version: "1.0"
1010

11+
# XLEN used by rakefile
12+
base: 32
13+
1114
description: |
1215
MC-1 can be though of as a minimal 32-bit RISC-V processor with M-mode support:
1316
@@ -47,7 +50,7 @@ MC-1:
4750
parameters:
4851
TIME_CSR_IMPLEMENTED: {} # Unconstrained
4952
- name: Sm
50-
version: "~> 1.11"
53+
version: "~> 1.11.0"
5154
presence: mandatory
5255
parameters:
5356
MTVEC_BASE_ALIGNMENT_DIRECT: {} # Unconstrained
@@ -60,10 +63,6 @@ MC-1:
6063
MTVAL_WIDTH: {} # Unconstrained
6164
MTVEC_MODES: {} # Unconstrained
6265
PHYS_ADDR_WIDTH: {} # Unconstrained
63-
CONFIG_PTR_ADDRESS:
64-
schema:
65-
const: 0xdeadbeef
66-
note: "This parameter and its associated CSR shouldn't be here. See GitHub issue #53."
6766
PRECISE_SYNCHRONOUS_EXCEPTIONS:
6867
schema:
6968
const: true

arch/crd/MockCRD-1.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ MockCRD-1:
66

77
family: MockCRDFamily
88

9+
# XLEN used by rakefile
10+
base: 64
11+
912
# semantic version within the CRD family
1013
version: "1.0"
1114

@@ -124,7 +127,7 @@ MockCRD-1:
124127
const: little
125128
XLEN:
126129
schema:
127-
const: 32
130+
const: 64
128131
CONFIG_PTR_ADDRESS:
129132
schema:
130133
const: 0xdeadbeef

backends/crd_doc/tasks.rake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ Dir.glob("#{$root}/arch/crd/*.yaml") do |f|
1313
crd_name = File.basename(f, ".yaml")
1414
crd_obj = YAML.load_file(f, permitted_classes: [Date])
1515
raise "Ill-formed CRD file #{f}: missing 'family' field" if crd_obj.dig(crd_name, 'family').nil?
16+
17+
base = crd_obj[crd_name]["base"]
18+
raise "Missing CRD base" if base.nil?
1619

1720
file "#{$root}/gen/crd_doc/adoc/#{crd_name}.adoc" => [
1821
"#{$root}/arch/crd/#{crd_name}.yaml",
1922
"#{$root}/arch/crd_family/#{crd_obj[crd_name]['family']}.yaml",
2023
"#{CRD_DOC_DIR}/templates/crd.adoc.erb",
2124
__FILE__,
22-
"#{$root}/.stamps/arch-gen-_64.stamp"
25+
"#{$root}/.stamps/arch-gen-_#{base}.stamp"
2326
] do |t|
2427
# TODO: schema validation
25-
arch_def = arch_def_for("_64")
28+
arch_def = arch_def_for("_#{base}")
2629
crd = arch_def.crd(crd_name)
2730
raise "No CRD defined for #{crd_name}" if crd.nil?
2831

backends/crd_doc/templates/crd.adoc.erb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ If the "Allowed Value(s)" is "Any" then any value allowed by the type is accepta
117117
<% if crd.all_in_scope_ext_params.empty? -%>
118118
None
119119
<% else -%>
120-
[cols="4,2,1,1,3"]
120+
[cols="4,2,1,1,2"]
121121
|===
122122
| Parameter | Type | Allowed Value(s) | Extension(s) | Note
123123
@@ -316,7 +316,7 @@ The following instructions are added by this extension:
316316
317317
<% crd.in_scope_ext_params(ext_req).sort.each do |ext_param| -%>
318318
[[ext-<%= ext_req.name %>-param-<%= ext_param.name %>-def]]
319-
<%= ext_param.name %>::
319+
<%= ext_param.name %> &#8658; <%= ext_param.param_db.schema_type %>::
320320
+
321321
--
322322
<%= ext_param.param_db.desc %>
@@ -329,7 +329,7 @@ The following instructions are added by this extension:
329329
330330
<% crd.out_of_scope_params(ext_req.name).sort.each do |param_db| -%>
331331
[[ext-<%= ext_req.name %>-param-<%= param_db.name %>-def]]
332-
<%= param_db.name %>::
332+
<%= param_db.name %> &#8658; <%= param_db.schema_type %>::
333333
+
334334
--
335335
<%= param_db.desc %>
@@ -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
@@ -128,8 +128,7 @@ RV64::
128128
----
129129
<%- end -%>
130130

131-
<%# exception_list = inst.reachable_exceptions_str(inst.arch_def.sym_table_64, 64) -%>
132-
<%- exception_list = [] -%>
131+
<% exception_list = inst.reachable_exceptions_str(inst.arch_def.symtab, 64) -%>
133132
<%- unless exception_list.empty? -%>
134133
== Exceptions
135134

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/crd.rb

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ def value
222222
end
223223

224224
# @return [String] - # What parameter values are allowed by the CRD.
225-
#
226-
# Old implementation:
227-
# def schema_pretty_crd_merged_with_param_db
228-
# Schema.new(@param_db.schema).merge!(@schema_crd).to_pretty_s
229-
# end
230225
def allowed_values
231226
if (@schema_crd.empty?)
232227
# CRD doesn't add any constraints on parameter's value.
@@ -236,11 +231,9 @@ def allowed_values
236231
# Create a Schema object just using information in the parameter database.
237232
schema_obj = @param_db.schema
238233

239-
# Merge in constraints imposed by the CRD on the parameter.
240-
schema_obj.merge!(@schema_crd)
241-
242-
# Create string showing allowed values of parameter with CRD constraints added
243-
schema_obj.to_pretty_s
234+
# Merge in constraints imposed by the CRD on the parameter and then
235+
# create string showing allowed values of parameter with CRD constraints added
236+
schema_obj.merge(@schema_crd).to_pretty_s
244237
end
245238

246239
# sorts by name
@@ -273,6 +266,11 @@ def all_in_scope_ext_params
273266
param_db = ext_db.params.find { |p| p.name == param_name }
274267
raise "There is no param '#{param_name}' in extension '#{ext_crd["name"]}" if param_db.nil?
275268

269+
next unless ext_db.versions.any? do |ver|
270+
Gem::Requirement.new(ext_crd["version"]).satisfied_by?(Gem::Version.new(ver["version"])) &&
271+
param_db.defined_in_extension_version?(ver["version"])
272+
end
273+
276274
@all_in_scope_ext_params <<
277275
InScopeExtensionParameter.new(param_db, param_data["schema"], param_data["note"])
278276
end
@@ -302,6 +300,11 @@ def in_scope_ext_params(ext_req)
302300
ext_param_db = ext_db.params.find { |p| p.name == param_name }
303301
raise "There is no param '#{param_name}' in extension '#{ext_crd["name"]}" if ext_param_db.nil?
304302

303+
next unless ext_db.versions.any? do |ver|
304+
Gem::Requirement.new(ext_crd["version"]).satisfied_by?(Gem::Version.new(ver["version"])) &&
305+
ext_param_db.defined_in_extension_version?(ver["version"])
306+
end
307+
305308
ext_params <<
306309
InScopeExtensionParameter.new(ext_param_db, param_data["schema"], param_data["note"])
307310
end
@@ -315,8 +318,15 @@ def all_out_of_scope_params
315318

316319
@all_out_of_scope_params = []
317320
in_scope_ext_reqs.each do |ext_req|
318-
@arch_def.extension(ext_req.name).params.each do |param_db|
321+
ext_db = @arch_def.extension(ext_req.name)
322+
ext_db.params.each do |param_db|
319323
next if all_in_scope_ext_params.any? { |c| c.param_db.name == param_db.name }
324+
325+
next unless ext_db.versions.any? do |ver|
326+
Gem::Requirement.new(ext_req.version_requirement).satisfied_by?(Gem::Version.new(ver["version"])) &&
327+
param_db.defined_in_extension_version?(ver["version"])
328+
end
329+
320330
@all_out_of_scope_params << param_db
321331
end
322332
end

lib/arch_obj_models/extension.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def initialize(ext, name, data)
6767
def defined_in_extension_version?(version)
6868
return true if @data.dig("when", "version").nil?
6969

70-
Gem::Requirement.new(@data["when"]["version"]).satisfied_by?(version)
70+
Gem::Requirement.new(@data["when"]["version"]).satisfied_by?(Gem::Version.new(version))
7171
end
7272

7373
# @return [String]

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

lib/arch_obj_models/schema.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,12 @@ def large2hex(value)
122122
end
123123
end
124124

125-
def merge!(other_schema)
125+
def merge(other_schema)
126126
raise ArgumentError, "Expecting Schema" unless (other_schema.is_a?(Schema) || other_schema.is_a?(Hash))
127127

128-
hash = other_schema.is_a?(Schema) ? other_schema.instance_variable_get(:@schema_hash) : other_schema
128+
other_hash = other_schema.is_a?(Schema) ? other_schema.instance_variable_get(:@schema_hash) : other_schema
129129

130-
@schema_hash.merge!(hash)
131-
132-
self
130+
Schema.new(@schema_hash.merge(other_hash))
133131
end
134132

135133
def empty?

0 commit comments

Comments
 (0)