/// <summary> /// Returns initial and unconstrained alignment information. /// </summary> /// <param name="node">The IR node.</param> /// <returns>The initial alignment information.</returns> private static int GetInitialAlignment(Value node) { switch (node) { case Alloca alloca: return(AllocaAlignments.GetInitialAlignment(alloca)); case AlignViewTo alignTo: // Use a compile-time known alignment constant for the alignment // information instead of type-based alignment reasoning return(alignTo.GetAlignmentConstant()); case NewView _: case BaseAddressSpaceCast _: case SubViewValue _: case LoadElementAddress _: case LoadFieldAddress _: case GetField _: case SetField _: case StructureValue _: case Load _: case Store _: case PhiValue _: case PrimitiveValue _: case NullValue _: case UndefinedValue _: return(int.MaxValue); default: return(1); } }
/// <summary> /// Returns the alignment information determined and used for the given /// alloca. /// </summary> /// <param name="alloca"> /// The alloca to get the alignment information for. /// </param> /// <returns>The determined and used alignment in bytes.</returns> public readonly int GetAllocaAlignment(Alloca alloca) => GetAlignment( alloca, AllocaAlignments.GetInitialAlignment(alloca));