Add begin_access and end_access instructions.

NFC because we're not actually emitting them.
This commit is contained in:
John McCall
2017-03-26 04:15:55 -04:00
parent f95133070e
commit 57ecaa7fae
18 changed files with 612 additions and 34 deletions

View File

@@ -216,6 +216,19 @@ SILInliner::getOrCreateInlineScope(const SILDebugScope *CalleeScope) {
// Cost Model
//===----------------------------------------------------------------------===//
static InlineCost getEnforcementCost(BeginAccessInst &I) {
switch (I.getEnforcement()) {
case SILAccessEnforcement::Unknown:
llvm_unreachable("evaluating cost of access with unknown enforcement?");
case SILAccessEnforcement::Dynamic:
return InlineCost::Expensive;
case SILAccessEnforcement::Static:
case SILAccessEnforcement::Unsafe:
return InlineCost::Free;
}
llvm_unreachable("bad enforcement");
}
/// For now just assume that every SIL instruction is one to one with an LLVM
/// instruction. This is of course very much so not true.
InlineCost swift::instructionInlineCost(SILInstruction &I) {
@@ -273,6 +286,12 @@ InlineCost swift::instructionInlineCost(SILInstruction &I) {
case ValueKind::BridgeObjectToWordInst:
return InlineCost::Free;
// Access instructions are free unless we're dynamically enforcing them.
case ValueKind::BeginAccessInst:
return getEnforcementCost(cast<BeginAccessInst>(I));
case ValueKind::EndAccessInst:
return getEnforcementCost(*cast<EndAccessInst>(I).getBeginAccess());
// TODO: These are free if the metatype is for a Swift class.
case ValueKind::ThickToObjCMetatypeInst:
case ValueKind::ObjCToThickMetatypeInst: