//===--- SILNodes.def - Swift SIL Metaprogramming ---------------*- C++ -*-===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // This file defines macros used for macro-metaprogramming with SIL nodes. // //===----------------------------------------------------------------------===// /// VALUE(Id, Parent) /// The expression enumerator value is a ValueKind. The node's class name is /// Id, and the name of its base class (in the SILValue hierarchy) is Parent. #ifndef VALUE #define VALUE(Id, Parent) #endif /// INST(Id, Parent, MemBehavior) /// The expression enumerator value is a ValueKind. The node's class name is /// Id, and the name of its base class (in the SILInstruction hierarchy) is /// Parent. MemBehavior is an enum value that reflects the memory behavior of /// the instruction. #ifndef INST #define INST(Id, Parent, MemBehavior) VALUE(Id, Parent) #endif /// TERMINATOR(Id, Parent, MemBehavior) /// Expands for terminator instructions. The expression enumerator value is /// a ValueKind. The node's class name is Id, and the name of its base class /// (in the SILInstruction hierarchy) is Parent. MemBehavior is an enum value /// that reflects the memory behavior of the instruction. #ifndef TERMINATOR #define TERMINATOR(Id, Parent, MemBehavior) INST(Id, Parent, MemBehavior) #endif /// An abstract instruction is an abstract base class in the hierarchy; /// it is never a most-derived type, and it does not have an enumerator in /// ValueKind. /// /// Most metaprograms do not care about abstract expressions, so the default /// is to ignore them. #ifndef ABSTRACT_VALUE #define ABSTRACT_VALUE(Id, Parent) #endif /// A convenience for determining the range of values. These will always /// appear immediately after the last member. #ifndef VALUE_RANGE #define VALUE_RANGE(Id, First, Last) #endif VALUE(SILArgument, ValueBase) // Please keep the order of instructions consistent with the order of their // descriptions in the SIL reference in docs/SIL.rst. ABSTRACT_VALUE(SILInstruction, ValueBase) // Allocation and Deallocation INST(AllocStackInst, SILInstruction, None) INST(AllocRefInst, SILInstruction, None) INST(AllocBoxInst, SILInstruction, None) INST(AllocArrayInst, SILInstruction, None) INST(DeallocStackInst, SILInstruction, MayHaveSideEffects) INST(DeallocRefInst, SILInstruction, MayHaveSideEffects) INST(DeallocBoxInst, SILInstruction, MayHaveSideEffects) // Accessing memory INST(LoadInst, SILInstruction, MayRead) INST(LoadWeakInst, SILInstruction, MayRead) INST(StoreInst, SILInstruction, MayWrite) INST(AssignInst, SILInstruction, MayWrite) INST(MarkUninitializedInst, SILInstruction, None) INST(MarkFunctionEscapeInst, SILInstruction, None) INST(StoreWeakInst, SILInstruction, MayWrite) INST(InitializeVarInst, SILInstruction, MayWrite) INST(CopyAddrInst, SILInstruction, MayReadWrite) INST(DestroyAddrInst, SILInstruction, MayHaveSideEffects) ABSTRACT_VALUE(IndexingInst, SILInstruction) INST(IndexAddrInst, IndexingInst, None) INST(IndexRawPointerInst, IndexingInst, None) VALUE_RANGE(IndexingInst, IndexAddrInst, IndexRawPointerInst) // Reference Counting ABSTRACT_VALUE(RefCountingInst, SILInstruction) INST(StrongRetainInst, RefCountingInst, MayHaveSideEffects) INST(StrongRetainAutoreleasedInst, RefCountingInst, MayHaveSideEffects) INST(StrongReleaseInst, RefCountingInst, MayHaveSideEffects) INST(StrongRetainUnownedInst, RefCountingInst, MayHaveSideEffects) INST(UnownedRetainInst, RefCountingInst, MayHaveSideEffects) INST(UnownedReleaseInst, RefCountingInst, MayHaveSideEffects) VALUE_RANGE(RefCountingInst, StrongRetainInst, UnownedReleaseInst) // Literals INST(FunctionRefInst, SILInstruction, None) INST(BuiltinFunctionRefInst, SILInstruction, None) INST(GlobalAddrInst, SILInstruction, None) INST(IntegerLiteralInst, SILInstruction, None) INST(FloatLiteralInst, SILInstruction, None) INST(StringLiteralInst, SILInstruction, None) INST(BuiltinZeroInst, SILInstruction, None) INST(ModuleInst, SILInstruction, None) // Dynamic Dispatch ABSTRACT_VALUE(MethodInst, SILInstruction) INST(ClassMethodInst, MethodInst, None) INST(SuperMethodInst, MethodInst, None) INST(ArchetypeMethodInst, MethodInst, None) INST(ProtocolMethodInst, MethodInst, None) INST(DynamicMethodInst, MethodInst, None) VALUE_RANGE(MethodInst, ClassMethodInst, DynamicMethodInst) // Function Application INST(ApplyInst, SILInstruction, MayHaveSideEffects) INST(PartialApplyInst, SILInstruction, MayHaveSideEffects) INST(SpecializeInst, SILInstruction, None) // Metatypes INST(MetatypeInst, SILInstruction, None) INST(ClassMetatypeInst, SILInstruction, None) INST(ArchetypeMetatypeInst, SILInstruction, None) INST(ProtocolMetatypeInst, SILInstruction, None) // Aggregate Types INST(CopyValueInst, SILInstruction, MayHaveSideEffects) INST(DestroyValueInst, SILInstruction, MayHaveSideEffects) INST(TupleInst, SILInstruction, None) INST(TupleExtractInst, SILInstruction, None) INST(TupleElementAddrInst, SILInstruction, None) INST(StructInst, SILInstruction, None) INST(StructExtractInst, SILInstruction, None) INST(StructElementAddrInst, SILInstruction, None) INST(RefElementAddrInst, SILInstruction, None) // Enums INST(EnumInst, SILInstruction, None) INST(EnumDataAddrInst, SILInstruction, None) INST(InjectEnumAddrInst, SILInstruction, MayWrite) // Protocol and Protocol Composition Types INST(InitExistentialInst, SILInstruction, MayWrite) INST(UpcastExistentialInst, SILInstruction, MayWrite) INST(DeinitExistentialInst, SILInstruction, MayHaveSideEffects) INST(ProjectExistentialInst, SILInstruction, None) INST(InitExistentialRefInst, SILInstruction, None) INST(UpcastExistentialRefInst, SILInstruction, None) INST(ProjectExistentialRefInst, SILInstruction, None) ABSTRACT_VALUE(ConversionInst, SILInstruction) // Unchecked Conversions INST(CoerceInst, ConversionInst, None) INST(UpcastInst, ConversionInst, None) INST(ArchetypeRefToSuperInst, ConversionInst, None) INST(AddressToPointerInst, ConversionInst, None) INST(PointerToAddressInst, ConversionInst, None) INST(RefToObjectPointerInst, ConversionInst, None) INST(ObjectPointerToRefInst, ConversionInst, None) INST(RefToRawPointerInst, ConversionInst, None) INST(RawPointerToRefInst, ConversionInst, None) INST(RefToUnownedInst, ConversionInst, None) INST(UnownedToRefInst, ConversionInst, None) INST(ConvertFunctionInst, ConversionInst, None) INST(ConvertCCInst, ConversionInst, None) INST(BridgeToBlockInst, ConversionInst, None) INST(ThinToThickFunctionInst, ConversionInst, None) // Checked Conversions ABSTRACT_VALUE(CheckedConversionInst, ConversionInst) INST(DowncastInst, CheckedConversionInst, None) INST(SuperToArchetypeRefInst, CheckedConversionInst, None) INST(DowncastArchetypeRefInst, CheckedConversionInst, None) INST(DowncastArchetypeAddrInst, CheckedConversionInst, None) INST(ProjectDowncastExistentialAddrInst, CheckedConversionInst, None) INST(DowncastExistentialRefInst, CheckedConversionInst, None) VALUE_RANGE(CheckedConversionInst, SuperToArchetypeRefInst, DowncastExistentialRefInst) VALUE_RANGE(ConversionInst, ConvertFunctionInst, DowncastExistentialRefInst) INST(IsNonnullInst, SILInstruction, None) // Terminators ABSTRACT_VALUE(TermInst, SILInstruction) TERMINATOR(UnreachableInst, TermInst, None) TERMINATOR(ReturnInst, TermInst, None) TERMINATOR(AutoreleaseReturnInst, TermInst, None) TERMINATOR(BranchInst, TermInst, None) TERMINATOR(CondBranchInst, TermInst, None) TERMINATOR(SwitchIntInst, TermInst, None) TERMINATOR(SwitchEnumInst, TermInst, None) TERMINATOR(DestructiveSwitchEnumAddrInst, TermInst, MayWrite) TERMINATOR(DynamicMethodBranchInst, TermInst, None) VALUE_RANGE(TermInst, UnreachableInst, DynamicMethodBranchInst) VALUE_RANGE(SILInstruction, AllocStackInst, DynamicMethodBranchInst) #undef VALUE_RANGE #undef ABSTRACT_VALUE #undef TERMINATOR #undef INST #undef VALUE