Register.tt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. using System.Runtime.InteropServices;
  11. namespace System.Numerics
  12. {
  13. /// <summary>
  14. /// A structure describing the layout of an SSE2-sized register.
  15. /// Contains overlapping fields representing the set of valid numeric types.
  16. /// Allows the generic Vector'T struct to contain an explicit field layout.
  17. /// </summary>
  18. [StructLayout(LayoutKind.Explicit)]
  19. internal struct Register
  20. {
  21. #region Internal Storage Fields
  22. <#
  23. foreach (var type in supportedTypes)
  24. {
  25. Debug.Assert(
  26. totalSize % Marshal.SizeOf(type) == 0,
  27. "The size of supported structs must be a factor of the supported register size.");
  28. #>
  29. // Internal <#= type.FullName #> Fields
  30. <#
  31. for (int g = 0; g < totalSize / Marshal.SizeOf(type); g++)
  32. {
  33. #>
  34. [FieldOffset(<#=Marshal.SizeOf(type) * g#>)]
  35. internal <#= typeAliases[type] #> <#= type.Name.ToLowerInvariant() + "_" + g #>;
  36. <#
  37. }
  38. #>
  39. <#
  40. }
  41. #> #endregion Internal Storage Fields
  42. }
  43. }