Add instructions to allocate and deallocate packs.

Having added these, I'm not entirely sure we couldn't just use
alloc_stack and dealloc_stack.  Well, if we find ourselves adding
a lot of redundancy with those instructions (e.g. around DI), we
can always go back and rip these out.
This commit is contained in:
John McCall
2023-01-31 22:39:34 -05:00
parent c491d25d06
commit 6bf9ac858b
18 changed files with 174 additions and 2 deletions

View File

@@ -1525,6 +1525,12 @@ public:
// It's illegal code but the compiler should not crash on it.
}
void checkAllocPackInst(AllocPackInst *AI) {
requireAddressType(SILPackType, AI->getType(),
"result of alloc_pack must be an address of "
"lowered pack type");
}
void checkAllocRefBase(AllocRefInstBase *ARI) {
requireReferenceValue(ARI, "Result of alloc_ref");
verifyLocalArchetype(ARI, ARI->getType().getASTType());
@@ -3130,6 +3136,11 @@ public:
"Operand of dealloc_stack must be an alloc_stack or partial_apply "
"[stack]");
}
void checkDeallocPackInst(DeallocPackInst *DI) {
require(isa<SILUndef>(DI->getOperand()) ||
isa<AllocPackInst>(DI->getOperand()),
"Operand of dealloc_pack must be an alloc_pack");
}
void checkDeallocRefInst(DeallocRefInst *DI) {
require(DI->getOperand()->getType().isObject(),
"Operand of dealloc_ref must be object");