Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arch/csr/medelegh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ medelegh:
base: 32
description: |
Alias of the upper 32 bits of `medeleg`.
definedBy: I
definedBy:
name: S
version: ">= 1.13"
fields: {}
2 changes: 1 addition & 1 deletion arch/csr/mseccfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ mseccfg:
description: Machine Security Configuration
definedBy:
name: Sm
version: ">=1.12"
version: ">= 1.12"
fields: {}

2 changes: 1 addition & 1 deletion arch/csr/mseccfgh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ mseccfgh:
description: Machine Security Configuration
definedBy:
name: Sm
version: ">=1.12"
version: ">= 1.12"
fields: {}

4 changes: 3 additions & 1 deletion arch/csr/mstatush.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ mstatush:
base: 32
length: 32
description: The mstatus register tracks and controls the hart's current operating state.
definedBy: Sm
definedBy:
name: Sm
version: ">= 1.12"
fields:
MPV:
location: 7
Expand Down
4 changes: 2 additions & 2 deletions backends/crd_doc/templates/crd.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ None
== CSR Summary

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

=== By Name
Expand Down Expand Up @@ -476,7 +476,7 @@ This instruction may result in the following synchronous exceptions:
== CSR Details

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

Expand Down
28 changes: 24 additions & 4 deletions lib/arch_obj_models/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,24 @@ def satisfying_versions(archdef)
# @param extension_version [ExtensionVersion] A specific extension version
# @return [Boolean] whether or not the extension_version meets this requirement
# @overload
# @param extension_requirement [ExtensionRequirement] A range of extension versions
# @return [Boolean] whether or not extension_requirement is satisfied by this requirement
# @overload
# @param extension_name [#to_s] An extension name
# @param extension_name [#to_s] An extension version
# @return [Boolean] whether or not the extension_version meets this requirement
def satisfied_by?(*args)
if args.size == 1
raise ArgumentError, "Single argument must be an ExtensionVersion" unless args[0].is_a?(ExtensionVersion)

args[0].name == @name &&
@requirement.satisfied_by?(Gem::Version.new(args[0].version))
if args[0].is_a?(ExtensionVersion)
args[0].name == @name &&
@requirement.satisfied_by?(Gem::Version.new(args[0].version))
elsif args[0].is_a?(ExtensionRequirement)
satisfying_versions.all? do |ext_ver|
satified_by?(ext_ver)
end
else
raise ArgumentError, "Single argument must be an ExtensionVersion or ExtensionRquirement"
end
elsif args.size == 2
raise ArgumentError, "First parameter must be an extension name" unless args[0].respond_to?(:to_s)
raise ArgumentError, "First parameter must be an extension version" unless args[1].respond_to?(:to_s)
Expand All @@ -442,6 +451,17 @@ def satisfied_by?(*args)
end
end

# @return [Array<Csr>] List of CSRs defined by any extension satisfying this requirement
def csrs(arch_def)
return @csrs unless @csrs.nil?

@csrs = arch_def.csrs.select do |csr|
satisfying_versions(arch_def).any? do |ext_ver|
csr.defined_by?(ext_ver)
end
end
end

# sorts by name
def <=>(other)
raise ArgumentError, "ExtensionRequirements are only comparable to other extension requirements" unless other.is_a?(ExtensionRequirement)
Expand Down
2 changes: 2 additions & 0 deletions lib/arch_obj_models/obj.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def defined_by?(*args)

# @return [SchemaCondition] Extension(s) that define the instruction. If *any* requirement is met, the instruction is defined.
def defined_by
raise "ERROR: definedBy is nul for #{name}" if @data["definedBy"].nil?

SchemaCondition.new(@data["definedBy"])
end

Expand Down
Loading