Skip to content

Commit 412e25d

Browse files
authored
Merge branch 'main' into crd-james
2 parents 4040402 + 8fd3ad1 commit 412e25d

File tree

8 files changed

+63
-64
lines changed

8 files changed

+63
-64
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")

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/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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ def initialize(schema_hash)
1616
# @return [Hash] Hash representation of the JSON Schema
1717
def to_h = @schema_hash
1818

19+
# @return [String] Human-readable type of the schema (e.g., array, string, integer)
20+
def type_pretty
21+
@schema_hash["type"]
22+
end
23+
1924
# @return [String] A human-readable description of the schema
2025
def to_pretty_s(schema_hash = @schema_hash)
2126
raise ArgumentError, "Expecting hash" unless schema_hash.is_a?(Hash)

0 commit comments

Comments
 (0)