SIL: a few changes regarding access to a GlobalVariable's static initializer instructions

* add `GlobalVariable.staticInitializerInstructions` to access all initializer instructions of a global
* implement `GlobalVariable.staticInitValue` with `GlobalVariable.staticInitializerInstructions`
* this requires that `InstructionList.reversed()` works without accessing the parent block of the iterator instruction
* allow `Context.erase(instruction:)` to delete instructions from a global's initializer list, which means to handle the case where a deleted instruction has no parent function.
This commit is contained in:
Erik Eckstein
2023-08-09 18:15:59 +02:00
parent 89d3326ff4
commit 7e33e554ef
5 changed files with 33 additions and 8 deletions

View File

@@ -97,7 +97,7 @@ public struct InstructionList : CollectionLikeSequence, IteratorProtocol {
public func reversed() -> ReverseInstructionList {
if let inst = currentInstruction {
let lastInst = inst.parentBlock.bridged.getLastInst().instruction
let lastInst = inst.bridged.getLastInstOfParent().instruction
return ReverseInstructionList(first: lastInst)
}
return ReverseInstructionList(first: nil)