Skip to content

Commit

Permalink
Better inlining codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-st committed Mar 18, 2024
1 parent 0b3a220 commit 61de071
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 278 deletions.
49 changes: 49 additions & 0 deletions src/InlineMethod.Fody/Helper/OpCodeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ public static bool IsLoadLocA(Instruction instruction)
code == Code.Ldloca_S;
}

public static bool IsLoadFlda(Instruction instruction)
=> instruction.OpCode.Code == Code.Ldflda;

public static bool IsStoreLoc(Instruction instruction)
{
var code = instruction.OpCode.Code;
Expand All @@ -277,6 +280,44 @@ public static bool IsLoadArg(Instruction instruction)
code == Code.Ldarg_S;
}

public static bool IsConv(Instruction instruction)
{
var code = instruction.OpCode.Code;
return code == Code.Conv_I ||
code == Code.Conv_I1 ||
code == Code.Conv_I2 ||
code == Code.Conv_I4 ||
code == Code.Conv_I8 ||
code == Code.Conv_U ||
code == Code.Conv_U1 ||
code == Code.Conv_U2 ||
code == Code.Conv_U4 ||
code == Code.Conv_U8 ||
code == Code.Conv_R4 ||
code == Code.Conv_R8 ||
code == Code.Conv_R_Un ||
code == Code.Conv_Ovf_I1_Un ||
code == Code.Conv_Ovf_I2_Un ||
code == Code.Conv_Ovf_I4_Un ||
code == Code.Conv_Ovf_I8_Un ||
code == Code.Conv_Ovf_U1_Un ||
code == Code.Conv_Ovf_U2_Un ||
code == Code.Conv_Ovf_U4_Un ||
code == Code.Conv_Ovf_U8_Un ||
code == Code.Conv_Ovf_I_Un ||
code == Code.Conv_Ovf_U_Un ||
code == Code.Conv_Ovf_I1 ||
code == Code.Conv_Ovf_I2 ||
code == Code.Conv_Ovf_I4 ||
code == Code.Conv_Ovf_I8 ||
code == Code.Conv_Ovf_U1 ||
code == Code.Conv_Ovf_U2 ||
code == Code.Conv_Ovf_U4 ||
code == Code.Conv_Ovf_U8 ||
code == Code.Conv_Ovf_I ||
code == Code.Conv_Ovf_U;
}

public static bool IsLoadArgA(Instruction instruction) =>
instruction.OpCode.Code == Code.Ldarga || instruction.OpCode.Code == Code.Ldarga_S;

Expand Down Expand Up @@ -317,10 +358,18 @@ public static IEnumerable<Instruction> GetTargets(Instruction instruction)
}
}

public static bool HasTargets(Instruction instruction) => instruction.Operand is Instruction || instruction.Operand is Instruction[];

public static void ReplaceInstruction(Instruction target, Instruction source)
{
target.OpCode = source.OpCode;
target.Operand = source.Operand;
}

public static bool IsSizeOf(Instruction instruction)
=> instruction.OpCode.Code == Code.Sizeof;

public static bool IsLoadFld(Instruction instruction)
=> instruction.OpCode.Code == Code.Ldfld;
}
}
2 changes: 1 addition & 1 deletion src/InlineMethod.Fody/InlineMethod.Fody.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FodyHelpers" Version="6.6.3" />
<PackageReference Include="FodyHelpers" Version="6.8.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 61de071

Please sign in to comment.