Skip to content

Commit bb53c35

Browse files
author
Derek Hower
committed
Make CRD gen check ext versions for in scope. Update CSRs with correct version info
1 parent 9607bb8 commit bb53c35

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

arch/csr/medelegh.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ medelegh:
88
base: 32
99
description: |
1010
Alias of the upper 32 bits of `medeleg`.
11-
definedBy: I
11+
definedBy: S
1212
fields: {}

arch/csr/mseccfg.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ mseccfg:
88
description: Machine Security Configuration
99
definedBy:
1010
name: Sm
11-
version: ">=1.12"
11+
version: ">= 1.12"
1212
fields: {}
1313

arch/csr/mseccfgh.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ mseccfgh:
88
description: Machine Security Configuration
99
definedBy:
1010
name: Sm
11-
version: ">=1.12"
11+
version: ">= 1.12"
1212
fields: {}
1313

arch/csr/mstatush.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ mstatush:
77
base: 32
88
length: 32
99
description: The mstatus register tracks and controls the hart's current operating state.
10-
definedBy: Sm
10+
definedBy:
11+
name: Sm
12+
version: ">= 1.12"
1113
fields:
1214
MPV:
1315
location: 7

backends/crd_doc/templates/crd.adoc.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ None
176176
== CSR Summary
177177

178178
<%
179-
csrs = crd.in_scope_extensions.map { |ext_crd| ext_crd.csrs }.flatten.uniq
179+
csrs = crd.in_scope_ext_reqs.map { |ext_crd_req| ext_crd_req.csrs(crd.arch_def) }.flatten.uniq
180180
-%>
181181

182182
=== By Name
@@ -476,7 +476,7 @@ This instruction may result in the following synchronous exceptions:
476476
== CSR Details
477477

478478
<%
479-
csrs = crd.in_scope_extensions.map { |ext_crd| ext_crd.csrs }.flatten.uniq
479+
csrs = crd.in_scope_ext_reqs.map { |ext_crd_req| ext_crd_req.csrs(crd.arch_def) }.flatten.uniq
480480
csrs.sort_by!(&:name)
481481
-%>
482482

lib/arch_obj_models/extension.rb

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def implemented_instructions(archdef)
369369

370370
return @implemented_instructions unless @implemented_instructions.nil?
371371

372-
@implemented_instructions = archdef.implemented_instructions.select do |inst|
372+
@implemented_instructions = archdef.implementesd_instructions.select do |inst|
373373
inst.defined_by?(self)
374374
end
375375
end
@@ -422,15 +422,24 @@ def satisfying_versions(archdef)
422422
# @param extension_version [ExtensionVersion] A specific extension version
423423
# @return [Boolean] whether or not the extension_version meets this requirement
424424
# @overload
425+
# @param extension_requirement [ExtensionRequirement] A range of extension versions
426+
# @return [Boolean] whether or not extension_requirement is satisfied by this requirement
427+
# @overload
425428
# @param extension_name [#to_s] An extension name
426429
# @param extension_name [#to_s] An extension version
427430
# @return [Boolean] whether or not the extension_version meets this requirement
428431
def satisfied_by?(*args)
429432
if args.size == 1
430-
raise ArgumentError, "Single argument must be an ExtensionVersion" unless args[0].is_a?(ExtensionVersion)
431-
432-
args[0].name == @name &&
433-
@requirement.satisfied_by?(Gem::Version.new(args[0].version))
433+
if args[0].is_a?(ExtensionVersion)
434+
args[0].name == @name &&
435+
@requirement.satisfied_by?(Gem::Version.new(args[0].version))
436+
elsif args[0].is_a?(ExtensionRequirement)
437+
satisfying_versions.all? do |ext_ver|
438+
satified_by?(ext_ver)
439+
end
440+
else
441+
raise ArgumentError, "Single argument must be an ExtensionVersion or ExtensionRquirement"
442+
end
434443
elsif args.size == 2
435444
raise ArgumentError, "First parameter must be an extension name" unless args[0].respond_to?(:to_s)
436445
raise ArgumentError, "First parameter must be an extension version" unless args[1].respond_to?(:to_s)
@@ -442,6 +451,17 @@ def satisfied_by?(*args)
442451
end
443452
end
444453

454+
# @return [Array<Csr>] List of CSRs defined by any extension satisfying this requirement
455+
def csrs(arch_def)
456+
return @csrs unless @csrs.nil?
457+
458+
@csrs = arch_def.csrs.select do |csr|
459+
satisfying_versions(arch_def).any? do |ext_ver|
460+
csr.defined_by?(ext_ver)
461+
end
462+
end
463+
end
464+
445465
# sorts by name
446466
def <=>(other)
447467
raise ArgumentError, "ExtensionRequirements are only comparable to other extension requirements" unless other.is_a?(ExtensionRequirement)

lib/arch_obj_models/obj.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def defined_by?(*args)
151151

152152
# @return [SchemaCondition] Extension(s) that define the instruction. If *any* requirement is met, the instruction is defined.
153153
def defined_by
154+
raise "ERROR: definedBy is nul for #{name}" if @data["definedBy"].nil?
155+
154156
SchemaCondition.new(@data["definedBy"])
155157
end
156158

0 commit comments

Comments
 (0)