Class: Extension
- Inherits:
-
ArchDefObject
- Object
- ArchDefObject
- Extension
- Defined in:
- lib/arch_obj_models/extension.rb
Overview
Extension definition
Instance Attribute Summary collapse
-
#arch_def ⇒ ArchDef
readonly
The architecture defintion.
Instance Method Summary collapse
- #company ⇒ String?
- #conflicts ⇒ Object
-
#csrs ⇒ Array<Csr>
The list of CSRs implemented by *any version* of this extension (may be empty).
- #doc_license ⇒ { name: String, url: String}?
-
#implemented_csrs(archdef) ⇒ Array<Csr>
The list of CSRs implemented by this extension (may be empty).
-
#implemented_instructions(archdef) ⇒ Array<Csr>
The list of CSRs implemented by this extension (may be empty).
-
#implies(version_requirement = ">= 0") ⇒ Array<ExtensionVersion>
Array of extensions implied by any version of this extension meeting version_requirement.
-
#initialize(ext_data, arch_def) ⇒ Extension
constructor
A new instance of Extension.
-
#instructions ⇒ Array<Instruction>
The list of instructions implemented by *any version* of this extension (may be empty).
-
#long_name ⇒ String
Long name of the extension.
-
#max_version ⇒ ExtensionVersion
Maximum defined version of this extension.
- #min_ratified_version ⇒ ExtensionVersion?
-
#min_version ⇒ ExtensionVersion
Mimumum defined version of this extension.
-
#params ⇒ Array<ExtensionParameter>
List of parameters added by this extension.
-
#ratified_versions ⇒ Array<ExtensionVersion>
Ratified versions hash from config.
-
#reachable_functions(symtab) ⇒ Array<Idl::FunctionDefAst>
return the set of reachable functions from any of this extensions’s CSRs or instructions in the given evaluation context.
-
#reachable_functions_unevaluated ⇒ Array<Idl::FunctionDefAst>
Array of IDL functions reachable from any instruction or CSR in the extension, irrespective of a specific evaluation context.
-
#versions ⇒ Array<Hash>
Versions hash from config.
Constructor Details
#initialize(ext_data, arch_def) ⇒ Extension
Returns a new instance of Extension.
186 187 188 189 |
# File 'lib/arch_obj_models/extension.rb', line 186 def initialize(ext_data, arch_def) super(ext_data) @arch_def = arch_def end |
Instance Attribute Details
#arch_def ⇒ ArchDef (readonly)
Returns The architecture defintion.
122 123 124 |
# File 'lib/arch_obj_models/extension.rb', line 122 def arch_def @arch_def end |
Instance Method Details
#company ⇒ String?
129 130 131 |
# File 'lib/arch_obj_models/extension.rb', line 129 def company @data["company"] end |
#conflicts ⇒ Object
199 200 201 202 203 |
# File 'lib/arch_obj_models/extension.rb', line 199 def conflicts return [] if @data["conflicts"].nil? to_extension_requirement_list(@data["conflicts"]) end |
#csrs ⇒ Array<Csr>
Returns the list of CSRs implemented by *any version* of this extension (may be empty).
213 214 215 216 217 |
# File 'lib/arch_obj_models/extension.rb', line 213 def csrs return @csrs unless @csrs.nil? @csrs = arch_def.csrs.select { |csr| versions.any? { |v| csr.defined_by?(v) } } end |
#doc_license ⇒ { name: String, url: String}?
135 136 137 |
# File 'lib/arch_obj_models/extension.rb', line 135 def doc_license @data["doc_license"] end |
#implemented_csrs(archdef) ⇒ Array<Csr>
Returns the list of CSRs implemented by this extension (may be empty).
220 221 222 223 224 225 226 227 228 |
# File 'lib/arch_obj_models/extension.rb', line 220 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"], @arch_def)) } end end |
#implemented_instructions(archdef) ⇒ Array<Csr>
Returns the list of CSRs implemented by this extension (may be empty).
231 232 233 234 235 236 237 238 239 |
# File 'lib/arch_obj_models/extension.rb', line 231 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"], @arch_def)) } end end |
#implies(version_requirement = ">= 0") ⇒ Array<ExtensionVersion>
Returns Array of extensions implied by any version of this extension meeting version_requirement.
193 194 195 196 197 |
# File 'lib/arch_obj_models/extension.rb', line 193 def implies(version_requirement = ">= 0") return [] unless Gem::Requirement.new(version_requirement).satisfied_by?(max_version.version) max_version.implications end |
#instructions ⇒ Array<Instruction>
Returns the list of instructions implemented by *any version* of this extension (may be empty).
206 207 208 209 210 |
# File 'lib/arch_obj_models/extension.rb', line 206 def instructions return @instructions unless @instructions.nil? @instructions = arch_def.instructions.select { |i| versions.any? { |v| i.defined_by?(v) }} end |
#long_name ⇒ String
Returns Long name of the extension.
125 |
# File 'lib/arch_obj_models/extension.rb', line 125 def long_name = @data["long_name"] |
#max_version ⇒ ExtensionVersion
Returns Maximum defined version of this extension.
159 160 161 |
# File 'lib/arch_obj_models/extension.rb', line 159 def max_version versions.max { |a, b| a.version <=> b.version } end |
#min_ratified_version ⇒ ExtensionVersion?
165 166 167 168 169 |
# File 'lib/arch_obj_models/extension.rb', line 165 def min_ratified_version return nil if ratified_versions.empty? ratified_versions.min { |a, b| a.version <=> b.version } end |
#min_version ⇒ ExtensionVersion
Returns Mimumum defined version of this extension.
154 155 156 |
# File 'lib/arch_obj_models/extension.rb', line 154 def min_version versions.min { |a, b| a.version <=> b.version } end |
#params ⇒ Array<ExtensionParameter>
Returns List of parameters added by this extension.
172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/arch_obj_models/extension.rb', line 172 def params return @params unless @params.nil? @params = [] if @data.key?("params") @data["params"].each do |param_name, param_data| @params << ExtensionParameter.new(self, param_name, param_data) end end @params end |
#ratified_versions ⇒ Array<ExtensionVersion>
Returns Ratified versions hash from config.
149 150 151 |
# File 'lib/arch_obj_models/extension.rb', line 149 def ratified_versions versions.select { |v| v.state == "ratified" } end |
#reachable_functions(symtab) ⇒ Array<Idl::FunctionDefAst>
return the set of reachable functions from any of this extensions’s CSRs or instructions in the given evaluation context
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/arch_obj_models/extension.rb', line 245 def reachable_functions(symtab) @reachable_functions ||= {} return @reachable_functions[symtab] unless @reachable_functions[symtab].nil? funcs = [] puts "Finding all reachable functions from extension #{name}" instructions.each do |inst| funcs += inst.reachable_functions(symtab, 32) if inst.defined_in_base?(32) funcs += inst.reachable_functions(symtab, 64) if inst.defined_in_base?(64) end csrs.each do |csr| funcs += csr.reachable_functions(arch_def) end @reachable_functions[symtab] = funcs.uniq end |
#reachable_functions_unevaluated ⇒ Array<Idl::FunctionDefAst>
Returns Array of IDL functions reachable from any instruction or CSR in the extension, irrespective of a specific evaluation context.
267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/arch_obj_models/extension.rb', line 267 def reachable_functions_unevaluated return @reachable_functions_unevaluated unless @reachable_functions_unevaluated.nil? funcs = [] instructions.each do |inst| funcs += inst.operation_ast(arch_def.symtab).reachable_functions(arch_def.symtab) end csrs.each do |csr| funcs += csr.reachable_functions(arch_def) end @reachable_functions_unevaluated = funcs.uniq(&:name) end |
#versions ⇒ Array<Hash>
Returns versions hash from config.
140 141 142 143 144 145 146 |
# File 'lib/arch_obj_models/extension.rb', line 140 def versions return @versions unless @versions.nil? @versions = @data["versions"].map do |v| ExtensionVersion.new(name, v["version"], arch_def) end end |