Skip to content

Commit 02c0b93

Browse files
Merge remote-tracking branch 'origin/main' into crd-james
2 parents 2c36e82 + ce5a74a commit 02c0b93

File tree

11 files changed

+83
-67
lines changed

11 files changed

+83
-67
lines changed

Rakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ DESC
270270
task :regress do
271271
Rake::Task["idl_test"].invoke
272272
Rake::Task["validate"].invoke
273+
ENV["MANUAL_NAME"] = "isa"
274+
ENV["VERSIONS"] = "all"
275+
Rake::Task["gen:html_manual"].invoke
273276
Rake::Task["gen:html"].invoke("generic_rv64")
274277
Rake::Task["gen:crd_pdf"].invoke("MockCRD-1")
275278
Rake::Task["gen:crd_pdf"].invoke("MC-1")

arch/crd/MC-1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ MC-1:
5050
parameters:
5151
TIME_CSR_IMPLEMENTED: {} # Unconstrained
5252
- name: Sm
53-
version: "~> 1.11"
53+
version: "~> 1.11.0"
5454
presence: mandatory
5555
parameters:
5656
MTVEC_BASE_ALIGNMENT_DIRECT: {} # Unconstrained

backends/arch_gen/lib/arch_gen.rb

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,33 +129,39 @@ def ext?(name)
129129

130130
# checks any "extra_validation" given by parameter definitions
131131
def params_extra_validation
132-
fork do
133-
# add parameters as a constant
134-
params.each do |key, value|
135-
self.class.const_set(key, value)
136-
end
137132

138-
@implemented_extensions.each do |ext|
139-
ext_name = ext["name"]
140-
gen_ext_path = @gen_dir / "arch" / "ext" / "#{ext_name}.yaml"
141-
ext_yaml = YAML.safe_load gen_ext_path.read
142-
unless ext_yaml[ext_name]["params"].nil?
143-
ext_yaml[ext_name]["params"].each do |param_name, param_data|
144-
next unless param_data.key?("extra_validation")
145-
begin
146-
eval param_data["extra_validation"]
147-
rescue StandardError => e
148-
warn "While checking extension parameter #{ext_name}::#{param_name}.extra_validation"
149-
warn param_data["extra_validation"]
150-
warn e
151-
exit 1
152-
end
133+
agen = self
134+
135+
eval_context = Class.new do
136+
end
137+
138+
eval_context.class.define_method(:ext?) { |name| agen.send(:ext?, name) }
139+
eval_context.class.define_method(:assert) { |cond| agen.send(:assert, cond) }
140+
141+
# add parameters as a constant
142+
params.each do |key, value|
143+
eval_context.const_set(key, value)
144+
end
145+
146+
147+
@implemented_extensions.each do |ext|
148+
ext_name = ext["name"]
149+
gen_ext_path = @gen_dir / "arch" / "ext" / "#{ext_name}.yaml"
150+
ext_yaml = YAML.safe_load gen_ext_path.read
151+
unless ext_yaml[ext_name]["params"].nil?
152+
ext_yaml[ext_name]["params"].each do |param_name, param_data|
153+
next unless param_data.key?("extra_validation")
154+
begin
155+
eval_context.class_eval param_data["extra_validation"]
156+
rescue StandardError => e
157+
warn "While checking extension parameter #{ext_name}::#{param_name}.extra_validation"
158+
warn param_data["extra_validation"]
159+
warn e
160+
exit 1
153161
end
154162
end
155163
end
156164
end
157-
Process.wait
158-
exit 1 unless $CHILD_STATUS.success?
159165
end
160166
private :params_extra_validation
161167

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/ext.adoc.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ This extension has the following implementation options:
6060
+
6161
--
6262
|===
63-
h| Type | <%= param.schema["type"] %>
64-
h| Valid Values | <%= Schema.new(param.schema).to_pretty_s %>
63+
h| Type | <%= param.schema.type_pretty %>
64+
h| Valid Values | <%= param.schema.to_pretty_s %>
6565
h| Description a| <%= param.desc %>
6666
|===
6767
--

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ def all_in_scope_ext_params
266266
param_db = ext_db.params.find { |p| p.name == param_name }
267267
raise "There is no param '#{param_name}' in extension '#{ext_crd["name"]}" if param_db.nil?
268268

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+
269274
@all_in_scope_ext_params <<
270275
InScopeExtensionParameter.new(param_db, param_data["schema"], param_data["note"])
271276
end
@@ -295,6 +300,11 @@ def in_scope_ext_params(ext_req)
295300
ext_param_db = ext_db.params.find { |p| p.name == param_name }
296301
raise "There is no param '#{param_name}' in extension '#{ext_crd["name"]}" if ext_param_db.nil?
297302

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+
298308
ext_params <<
299309
InScopeExtensionParameter.new(ext_param_db, param_data["schema"], param_data["note"])
300310
end
@@ -308,8 +318,15 @@ def all_out_of_scope_params
308318

309319
@all_out_of_scope_params = []
310320
in_scope_ext_reqs.each do |ext_req|
311-
@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|
312323
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+
313330
@all_out_of_scope_params << param_db
314331
end
315332
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

0 commit comments

Comments
 (0)