Add Cls Instruction. (#67)
* Update AInstEmitAlu.cs * Update ASoftFallback.cs * Update AOpCodeTable.cs
This commit is contained in:
@@ -100,6 +100,24 @@ namespace ChocolArm64.Instruction
|
||||
EmitDataStore(Context, SetFlags);
|
||||
}
|
||||
|
||||
public static void Cls(AILEmitterCtx Context)
|
||||
{
|
||||
AOpCodeAlu Op = (AOpCodeAlu)Context.CurrOp;
|
||||
|
||||
Context.EmitLdintzr(Op.Rn);
|
||||
|
||||
if (Op.RegisterSize == ARegisterSize.Int32)
|
||||
{
|
||||
ASoftFallback.EmitCall(Context, nameof(ASoftFallback.CountLeadingSigns32));
|
||||
}
|
||||
else
|
||||
{
|
||||
ASoftFallback.EmitCall(Context, nameof(ASoftFallback.CountLeadingSigns64));
|
||||
}
|
||||
|
||||
Context.EmitStintzr(Op.Rd);
|
||||
}
|
||||
|
||||
public static void Clz(AILEmitterCtx Context)
|
||||
{
|
||||
AOpCodeAlu Op = (AOpCodeAlu)Context.CurrOp;
|
||||
@@ -383,4 +401,4 @@ namespace ChocolArm64.Instruction
|
||||
Context.EmitStflg((int)APState.CBit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,14 @@ namespace ChocolArm64.Instruction
|
||||
Context.EmitCall(typeof(ASoftFallback), MthdName);
|
||||
}
|
||||
|
||||
public static uint CountLeadingSigns32(uint Value) => (uint)CountLeadingSigns(Value, 32);
|
||||
public static ulong CountLeadingSigns64(ulong Value) => (ulong)CountLeadingSigns(Value, 64);
|
||||
|
||||
private static ulong CountLeadingSigns(ulong Value, int Size)
|
||||
{
|
||||
return CountLeadingZeros((Value >> 1) ^ Value, Size - 1);
|
||||
}
|
||||
|
||||
public static uint CountLeadingZeros32(uint Value) => (uint)CountLeadingZeros(Value, 32);
|
||||
public static ulong CountLeadingZeros64(ulong Value) => (ulong)CountLeadingZeros(Value, 64);
|
||||
|
||||
@@ -398,4 +406,4 @@ namespace ChocolArm64.Instruction
|
||||
throw new ArgumentOutOfRangeException(nameof(Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user