Skip to content

Commit

Permalink
Reworked access to artificial fixed buffer fields
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-st committed Oct 5, 2023
1 parent 4ea7b5a commit 43f9853
Show file tree
Hide file tree
Showing 22 changed files with 147 additions and 653 deletions.
43 changes: 0 additions & 43 deletions src/ZstdSharp/Unsafe/HUF_CStream_t.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp.Unsafe
{
public unsafe struct HUF_CStream_t
Expand All @@ -14,52 +11,12 @@ public unsafe struct _bitContainer_e__FixedBuffer
{
public nuint e0;
public nuint e1;
public ref nuint this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_bitContainer_e__FixedBuffer, nuint>(this) + index);
}

public ref nuint this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_bitContainer_e__FixedBuffer, nuint>(this) + index);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator nuint*(in _bitContainer_e__FixedBuffer t) => RefToPointer<_bitContainer_e__FixedBuffer, nuint>(t);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static nuint* operator +(in _bitContainer_e__FixedBuffer t, nuint index) => RefToPointer<_bitContainer_e__FixedBuffer, nuint>(t) + index;
}

public unsafe struct _bitPos_e__FixedBuffer
{
public nuint e0;
public nuint e1;
public ref nuint this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_bitPos_e__FixedBuffer, nuint>(this) + index);
}

public ref nuint this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_bitPos_e__FixedBuffer, nuint>(this) + index);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator nuint*(in _bitPos_e__FixedBuffer t) => RefToPointer<_bitPos_e__FixedBuffer, nuint>(t);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static nuint* operator +(in _bitPos_e__FixedBuffer t, nuint index) => RefToPointer<_bitPos_e__FixedBuffer, nuint>(t) + index;
}
}
}
182 changes: 0 additions & 182 deletions src/ZstdSharp/Unsafe/HUF_DecompressFastArgs.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;
using InlineIL;
using static InlineIL.IL.Emit;

namespace ZstdSharp.Unsafe
{
/**
Expand Down Expand Up @@ -32,65 +27,6 @@ public unsafe struct _ip_e__FixedBuffer
public byte* e1;
public byte* e2;
public byte* e3;
public ref byte* this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return ref *(byte**)IL.ReturnPointer();
}
}

public ref byte* this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return ref *(byte**)IL.ReturnPointer();
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator byte**(in _ip_e__FixedBuffer t)
{
Ldarg_0();
Conv_U();
return (byte**)IL.ReturnPointer();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static byte** operator +(in _ip_e__FixedBuffer t, nuint index)
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return (byte**)IL.ReturnPointer();
}
}

public unsafe struct _op_e__FixedBuffer
Expand All @@ -99,65 +35,6 @@ public unsafe struct _op_e__FixedBuffer
public byte* e1;
public byte* e2;
public byte* e3;
public ref byte* this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return ref *(byte**)IL.ReturnPointer();
}
}

public ref byte* this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return ref *(byte**)IL.ReturnPointer();
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator byte**(in _op_e__FixedBuffer t)
{
Ldarg_0();
Conv_U();
return (byte**)IL.ReturnPointer();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static byte** operator +(in _op_e__FixedBuffer t, nuint index)
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return (byte**)IL.ReturnPointer();
}
}

public unsafe struct _iend_e__FixedBuffer
Expand All @@ -166,65 +43,6 @@ public unsafe struct _iend_e__FixedBuffer
public byte* e1;
public byte* e2;
public byte* e3;
public ref byte* this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return ref *(byte**)IL.ReturnPointer();
}
}

public ref byte* this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return ref *(byte**)IL.ReturnPointer();
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator byte**(in _iend_e__FixedBuffer t)
{
Ldarg_0();
Conv_U();
return (byte**)IL.ReturnPointer();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static byte** operator +(in _iend_e__FixedBuffer t, nuint index)
{
Ldarg_0();
Conv_U();
Ldarg_1();
Conv_I();
Sizeof(new TypeRef(typeof(byte*)));
Conv_I();
Mul();
Add();
return (byte**)IL.ReturnPointer();
}
}
}
}
43 changes: 0 additions & 43 deletions src/ZstdSharp/Unsafe/HUF_ReadDTableX2_Workspace.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp.Unsafe
{
public unsafe struct HUF_ReadDTableX2_Workspace
Expand All @@ -25,26 +22,6 @@ public unsafe struct _rankVal_e__FixedBuffer
public rankValCol_t e9;
public rankValCol_t e10;
public rankValCol_t e11;
public ref rankValCol_t this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_rankVal_e__FixedBuffer, rankValCol_t>(this) + index);
}

public ref rankValCol_t this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_rankVal_e__FixedBuffer, rankValCol_t>(this) + index);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator rankValCol_t*(in _rankVal_e__FixedBuffer t) => RefToPointer<_rankVal_e__FixedBuffer, rankValCol_t>(t);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static rankValCol_t* operator +(in _rankVal_e__FixedBuffer t, nuint index) => RefToPointer<_rankVal_e__FixedBuffer, rankValCol_t>(t) + index;
}

public unsafe struct _sortedSymbol_e__FixedBuffer
Expand Down Expand Up @@ -305,26 +282,6 @@ public unsafe struct _sortedSymbol_e__FixedBuffer
public sortedSymbol_t e253;
public sortedSymbol_t e254;
public sortedSymbol_t e255;
public ref sortedSymbol_t this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_sortedSymbol_e__FixedBuffer, sortedSymbol_t>(this) + index);
}

public ref sortedSymbol_t this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_sortedSymbol_e__FixedBuffer, sortedSymbol_t>(this) + index);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator sortedSymbol_t*(in _sortedSymbol_e__FixedBuffer t) => RefToPointer<_sortedSymbol_e__FixedBuffer, sortedSymbol_t>(t);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static sortedSymbol_t* operator +(in _sortedSymbol_e__FixedBuffer t, nuint index) => RefToPointer<_sortedSymbol_e__FixedBuffer, sortedSymbol_t>(t) + index;
}
}
}
43 changes: 0 additions & 43 deletions src/ZstdSharp/Unsafe/HUF_buildCTable_wksp_tables.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp.Unsafe
{
public struct HUF_buildCTable_wksp_tables
Expand Down Expand Up @@ -521,26 +518,6 @@ public unsafe struct _huffNodeTbl_e__FixedBuffer
public nodeElt_s e509;
public nodeElt_s e510;
public nodeElt_s e511;
public ref nodeElt_s this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_huffNodeTbl_e__FixedBuffer, nodeElt_s>(this) + index);
}

public ref nodeElt_s this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_huffNodeTbl_e__FixedBuffer, nodeElt_s>(this) + index);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator nodeElt_s*(in _huffNodeTbl_e__FixedBuffer t) => RefToPointer<_huffNodeTbl_e__FixedBuffer, nodeElt_s>(t);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static nodeElt_s* operator +(in _huffNodeTbl_e__FixedBuffer t, nuint index) => RefToPointer<_huffNodeTbl_e__FixedBuffer, nodeElt_s>(t) + index;
}

public unsafe struct _rankPosition_e__FixedBuffer
Expand Down Expand Up @@ -737,26 +714,6 @@ public unsafe struct _rankPosition_e__FixedBuffer
public rankPos e189;
public rankPos e190;
public rankPos e191;
public ref rankPos this[nuint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_rankPosition_e__FixedBuffer, rankPos>(this) + index);
}

public ref rankPos this[nint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
get => ref *(RefToPointer<_rankPosition_e__FixedBuffer, rankPos>(this) + index);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static implicit operator rankPos*(in _rankPosition_e__FixedBuffer t) => RefToPointer<_rankPosition_e__FixedBuffer, rankPos>(t);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[InlineMethod.Inline]
public static rankPos* operator +(in _rankPosition_e__FixedBuffer t, nuint index) => RefToPointer<_rankPosition_e__FixedBuffer, rankPos>(t) + index;
}
}
}
Loading

0 comments on commit 43f9853

Please sign in to comment.