Class: Extension

Inherits:
ArchDefObject show all
Defined in:
lib/arch_obj_models/extension.rb

Overview

Extension definition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ext_data, arch_def) ⇒ Extension

Returns a new instance of Extension.

Parameters:

  • ext_data (Hash<String, Object>)

    The extension data from the architecture spec

  • arch_def (ArchDef)

    The architecture definition



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_defArchDef (readonly)

Returns The architecture defintion.

Returns:

  • (ArchDef)

    The architecture defintion



122
123
124
# File 'lib/arch_obj_models/extension.rb', line 122

def arch_def
  @arch_def
end

Instance Method Details

#companyString?

Returns:

  • (String)

    Company that developed the extension

  • (nil)

    if the company isn’t known



129
130
131
# File 'lib/arch_obj_models/extension.rb', line 129

def company
  @data["company"]
end

#conflictsObject



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

#csrsArray<Csr>

Returns the list of CSRs implemented by *any version* of this extension (may be empty).

Returns:

  • (Array<Csr>)

    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}?

Returns:

  • ({ name: String, url: String})

    The name and URL of a document license the doc falls under

  • (nil)

    if the license isn’t known



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).

Returns:

  • (Array<Csr>)

    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).

Returns:

  • (Array<Csr>)

    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.

Parameters:

  • version_requirement (String) (defaults to: ">= 0")

    Version requirement

Returns:

  • (Array<ExtensionVersion>)

    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

#instructionsArray<Instruction>

Returns the list of instructions implemented by *any version* of this extension (may be empty).

Returns:

  • (Array<Instruction>)

    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_nameString

Returns Long name of the extension.

Returns:

  • (String)

    Long name of the extension



125
# File 'lib/arch_obj_models/extension.rb', line 125

def long_name = @data["long_name"]

#max_versionExtensionVersion

Returns Maximum defined version of this extension.

Returns:



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_versionExtensionVersion?

Returns:

  • (ExtensionVersion)

    Mimumum defined ratified version of this extension

  • (nil)

    if there is no ratified version



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_versionExtensionVersion

Returns Mimumum defined version of this extension.

Returns:



154
155
156
# File 'lib/arch_obj_models/extension.rb', line 154

def min_version
  versions.min { |a, b| a.version <=> b.version }
end

#paramsArray<ExtensionParameter>

Returns List of parameters added by this extension.

Returns:



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_versionsArray<ExtensionVersion>

Returns Ratified versions hash from config.

Returns:



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

Parameters:

  • symtab (Idl::SymbolTable)

    The evaluation context

Returns:

  • (Array<Idl::FunctionDefAst>)

    Array of IDL functions reachable from any instruction or CSR in the extension



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_unevaluatedArray<Idl::FunctionDefAst>

Returns Array of IDL functions reachable from any instruction or CSR in the extension, irrespective of a specific evaluation context.

Returns:

  • (Array<Idl::FunctionDefAst>)

    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

#versionsArray<Hash>

Returns versions hash from config.

Returns:

  • (Array<Hash>)

    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