@@ -385,6 +385,10 @@ def extension_presence(ext_name)
385
385
# @return [Presence] Given an instruction +inst_name+, return the presence.
386
386
# If the instruction name isn't found in the portfolio, return nil.
387
387
def instruction_presence_obj ( inst_name )
388
+ @instruction_presence_obj ||= { }
389
+
390
+ return @instruction_presence_obj [ inst_name ] unless @instruction_presence_obj [ inst_name ] . nil?
391
+
388
392
inst = arch . instruction ( inst_name )
389
393
390
394
raise "Can't find instruction object '#{ inst_name } ' in arch class" if inst . nil?
@@ -399,26 +403,35 @@ def instruction_presence_obj(inst_name)
399
403
ext_versions . any? { |ext_ver | inst . defined_by_condition . possibly_satisfied_by? ( ext_ver ) }
400
404
end
401
405
402
- if is_mandatory
403
- Presence . new ( Presence . mandatory )
404
- elsif is_optional
405
- Presence . new ( Presence . optional )
406
- else
407
- nil
408
- end
406
+ @instruction_presence_obj [ inst_name ] =
407
+ if is_mandatory
408
+ Presence . new ( Presence . mandatory )
409
+ elsif is_optional
410
+ Presence . new ( Presence . optional )
411
+ else
412
+ nil
413
+ end
409
414
end
410
415
411
416
# @return [String] Given an instruction +inst_name+, return the presence as a string.
412
417
# If the instruction name isn't found in the portfolio, return "-".
413
418
def instruction_presence ( inst_name )
419
+ @instruction_presence ||= { }
420
+
421
+ return @instruction_presence [ inst_name ] unless @instruction_presence [ inst_name ] . nil?
422
+
414
423
presence_obj = instruction_presence_obj ( inst_name )
415
424
416
- presence_obj . nil? ? "-" : presence_obj . to_s
425
+ @instruction_presence [ inst_name ] = presence_obj . nil? ? "-" : presence_obj . to_s
417
426
end
418
427
419
428
# @return [Presence] Given an CSR +csr_name+, return the presence.
420
429
# If the CSR name isn't found in the portfolio, return nil.
421
430
def csr_presence_obj ( csr_name )
431
+ @csr_presence_obj ||= { }
432
+
433
+ return @csr_presence_obj [ csr_name ] unless @csr_presence_obj [ csr_name ] . nil?
434
+
422
435
csr = arch . csr ( csr_name )
423
436
424
437
raise "Can't find CSR object '#{ csr_name } ' in arch class" if csr . nil?
@@ -433,21 +446,26 @@ def csr_presence_obj(csr_name)
433
446
ext_versions . any? { |ext_ver | csr . defined_by_condition . possibly_satisfied_by? ( ext_ver ) }
434
447
end
435
448
436
- if is_mandatory
437
- Presence . new ( Presence . mandatory )
438
- elsif is_optional
439
- Presence . new ( Presence . optional )
440
- else
441
- nil
442
- end
449
+ @csr_presence_obj [ csr_name ] =
450
+ if is_mandatory
451
+ Presence . new ( Presence . mandatory )
452
+ elsif is_optional
453
+ Presence . new ( Presence . optional )
454
+ else
455
+ nil
456
+ end
443
457
end
444
458
445
459
# @return [String] Given an CSR +csr_name+, return the presence as a string.
446
460
# If the CSR name isn't found in the portfolio, return "-".
447
461
def csr_presence ( csr_name )
462
+ @csr_presence ||= { }
463
+
464
+ return @csr_presence [ csr_name ] unless @csr_presence [ csr_name ] . nil?
465
+
448
466
presence_obj = csr_presence_obj ( csr_name )
449
467
450
- presence_obj . nil? ? "-" : presence_obj . to_s
468
+ @csr_presence [ csr_name ] = presence_obj . nil? ? "-" : presence_obj . to_s
451
469
end
452
470
453
471
# Returns the greatest presence string for each of the specified versions.
0 commit comments