Skip to content

Commit

Permalink
Add extension implemented_csr/inst (riscv-software-src#142)
Browse files Browse the repository at this point in the history
Signed-off-by: Albert Yosher <[email protected]>
  • Loading branch information
dhower-qc authored and Albert Yosher committed Nov 20, 2024
1 parent a5a1af4 commit 4a7a816
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/arch_obj_models/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,28 @@ def csrs
@csrs = arch_def.csrs.select { |csr| csr.defined_by?(ExtensionVersion.new(name, max_version)) }
end

# @return [Array<Csr>] the list of CSRs implemented by this extension (may be empty)
def implemented_csrs(archdef)
raise "should only be called with a fully configured arch def" unless archdef.fully_configured?

return @implemented_csrs unless @implemented_csrs.nil?

@implemented_csrs = archdef.implemented_csrs.select do |csr|
versions.any? { |ver| csr.defined_by?(ExtensionVersion.new(name, ver["version"])) }
end
end

# @return [Array<Csr>] the list of CSRs implemented by this extension (may be empty)
def implemented_instructions(archdef)
raise "should only be called with a fully configured arch def" unless archdef.fully_configured?

return @implemented_instructions unless @implemented_instructions.nil?

@implemented_instructions = archdef.implemented_instructions.select do |inst|
versions.any? { |ver| inst.defined_by?(ExtensionVersion.new(name, ver["version"])) }
end
end

# return the set of reachable functions from any of this extensions's CSRs or instructions in the given evaluation context
#
# @param symtab [Idl::SymbolTable] The evaluation context
Expand Down Expand Up @@ -326,6 +348,28 @@ def <=>(other)
@version <=> other.version
end
end

# @return [Array<Csr>] the list of CSRs implemented by this extension version (may be empty)
def implemented_csrs(archdef)
raise "should only be called with a fully configured arch def" unless archdef.fully_configured?

return @implemented_csrs unless @implemented_csrs.nil?

@implemented_csrs = archdef.implemented_csrs.select do |csr|
csr.defined_by?(self)
end
end

# @return [Array<Csr>] the list of CSRs implemented by this extension version (may be empty)
def implemented_instructions(archdef)
raise "should only be called with a fully configured arch def" unless archdef.fully_configured?

return @implemented_instructions unless @implemented_instructions.nil?

@implemented_instructions = archdef.implemented_instructions.select do |inst|
inst.defined_by?(self)
end
end
end

# Represents an extension requirement, that is an extension name paired with version requirement(s)
Expand Down

0 comments on commit 4a7a816

Please sign in to comment.