Register.tt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <#@ template debug="true" hostSpecific="true" #>
  2. <#@ output extension=".cs" #>
  3. <#@ Assembly Name="System.Core.dll" #>
  4. <#@ Assembly Name="System.Xml.dll" #>
  5. <#@ import namespace="System" #>
  6. <#@ import namespace="System.Linq" #>
  7. <#@ import namespace="System.Runtime.InteropServices" #>
  8. <#@ import namespace="System.Diagnostics" #>
  9. <#@ include file="GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>
  10. #nullable enable
  11. using System.Runtime.InteropServices;
  12. namespace System.Numerics
  13. {
  14. /// <summary>
  15. /// A structure describing the layout of an SSE2-sized register.
  16. /// Contains overlapping fields representing the set of valid numeric types.
  17. /// Allows the generic Vector'T struct to contain an explicit field layout.
  18. /// </summary>
  19. [StructLayout(LayoutKind.Explicit)]
  20. internal struct Register
  21. {
  22. #region Internal Storage Fields
  23. <#
  24. foreach (var type in supportedTypes)
  25. {
  26. Debug.Assert(
  27. totalSize % Marshal.SizeOf(type) == 0,
  28. "The size of supported structs must be a factor of the supported register size.");
  29. #>
  30. // Internal <#= type.FullName #> Fields
  31. <#
  32. for (int g = 0; g < totalSize / Marshal.SizeOf(type); g++)
  33. {
  34. #>
  35. [FieldOffset(<#=Marshal.SizeOf(type) * g#>)]
  36. internal <#= typeAliases[type] #> <#= type.Name.ToLowerInvariant() + "_" + g #>;
  37. <#
  38. }
  39. #>
  40. <#
  41. }
  42. #> #endregion Internal Storage Fields
  43. }
  44. }