Skip to content

Commit 9607bb8

Browse files
authored
Add extension implemented_csr/inst (#142)
1 parent 5e2d93c commit 9607bb8

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
@@ -225,6 +225,28 @@ def csrs
225225
@csrs = arch_def.csrs.select { |csr| csr.defined_by?(ExtensionVersion.new(name, max_version)) }
226226
end
227227

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

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

0 commit comments

Comments
 (0)