Skip to content

Commit 4a7a816

Browse files
dhower-qcayosher
authored andcommitted
Add extension implemented_csr/inst (riscv-software-src#142)
Signed-off-by: Albert Yosher <[email protected]>
1 parent a5a1af4 commit 4a7a816

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

lib/arch_obj_models/extension.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,28 @@ def csrs
222222
@csrs = arch_def.csrs.select { |csr| csr.defined_by?(ExtensionVersion.new(name, max_version)) }
223223
end
224224

225+
# @return [Array<Csr>] the list of CSRs implemented by this extension (may be empty)
226+
def implemented_csrs(archdef)
227+
raise "should only be called with a fully configured arch def" unless archdef.fully_configured?
228+
229+
return @implemented_csrs unless @implemented_csrs.nil?
230+
231+
@implemented_csrs = archdef.implemented_csrs.select do |csr|
232+
versions.any? { |ver| csr.defined_by?(ExtensionVersion.new(name, ver["version"])) }
233+
end
234+
end
235+
236+
# @return [Array<Csr>] the list of CSRs implemented by this extension (may be empty)
237+
def implemented_instructions(archdef)
238+
raise "should only be called with a fully configured arch def" unless archdef.fully_configured?
239+
240+
return @implemented_instructions unless @implemented_instructions.nil?
241+
242+
@implemented_instructions = archdef.implemented_instructions.select do |inst|
243+
versions.any? { |ver| inst.defined_by?(ExtensionVersion.new(name, ver["version"])) }
244+
end
245+
end
246+
225247
# return the set of reachable functions from any of this extensions's CSRs or instructions in the given evaluation context
226248
#
227249
# @param symtab [Idl::SymbolTable] The evaluation context
@@ -326,6 +348,28 @@ def <=>(other)
326348
@version <=> other.version
327349
end
328350
end
351+
352+
# @return [Array<Csr>] the list of CSRs implemented by this extension version (may be empty)
353+
def implemented_csrs(archdef)
354+
raise "should only be called with a fully configured arch def" unless archdef.fully_configured?
355+
356+
return @implemented_csrs unless @implemented_csrs.nil?
357+
358+
@implemented_csrs = archdef.implemented_csrs.select do |csr|
359+
csr.defined_by?(self)
360+
end
361+
end
362+
363+
# @return [Array<Csr>] the list of CSRs implemented by this extension version (may be empty)
364+
def implemented_instructions(archdef)
365+
raise "should only be called with a fully configured arch def" unless archdef.fully_configured?
366+
367+
return @implemented_instructions unless @implemented_instructions.nil?
368+
369+
@implemented_instructions = archdef.implemented_instructions.select do |inst|
370+
inst.defined_by?(self)
371+
end
372+
end
329373
end
330374

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

0 commit comments

Comments
 (0)