aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Translation
diff options
context:
space:
mode:
authorAlex Barney <thealexbarney@gmail.com>2019-07-01 21:39:22 -0500
committerAc_K <Acoustik666@gmail.com>2019-07-02 04:39:22 +0200
commitb2b736abc2569ab5d8199da666aef8d8394844a0 (patch)
tree88bcc2ae4fb0d4161c95df2cd7edb12388de922a /ChocolArm64/Translation
parent10c74182babaf8cf6bedaeffd64c3109df4ea816 (diff)
Misc cleanup (#708)
* Fix typos * Remove unneeded using statements * Enforce var style more * Remove redundant qualifiers * Fix some indentation * Disable naming warnings on files with external enum names * Fix build * Mass find & replace for comments with no spacing * Standardize todo capitalization and for/if spacing
Diffstat (limited to 'ChocolArm64/Translation')
-rw-r--r--ChocolArm64/Translation/ILEmitterCtx.cs50
-rw-r--r--ChocolArm64/Translation/RegisterUsage.cs4
-rw-r--r--ChocolArm64/Translation/TranslatedSub.cs12
-rw-r--r--ChocolArm64/Translation/Translator.cs10
-rw-r--r--ChocolArm64/Translation/TranslatorCache.cs14
5 files changed, 45 insertions, 45 deletions
diff --git a/ChocolArm64/Translation/ILEmitterCtx.cs b/ChocolArm64/Translation/ILEmitterCtx.cs
index b4360fda..0deb29b2 100644
--- a/ChocolArm64/Translation/ILEmitterCtx.cs
+++ b/ChocolArm64/Translation/ILEmitterCtx.cs
@@ -56,10 +56,10 @@ namespace ChocolArm64.Translation
private OpCode64 _optOpLastCompare;
private OpCode64 _optOpLastFlagSet;
- //This is the index of the temporary register, used to store temporary
- //values needed by some functions, since IL doesn't have a swap instruction.
- //You can use any value here as long it doesn't conflict with the indices
- //for the other registers. Any value >= 64 or < 0 will do.
+ // This is the index of the temporary register, used to store temporary
+ // values needed by some functions, since IL doesn't have a swap instruction.
+ // You can use any value here as long it doesn't conflict with the indices
+ // for the other registers. Any value >= 64 or < 0 will do.
private const int ReservedLocalsCount = 64;
private const int RorTmpIndex = ReservedLocalsCount + 0;
@@ -69,7 +69,7 @@ namespace ChocolArm64.Translation
private const int IntGpTmp2Index = ReservedLocalsCount + 4;
private const int UserIntTempStart = ReservedLocalsCount + 5;
- //Vectors are part of another "set" of locals.
+ // Vectors are part of another "set" of locals.
private const int VecGpTmp1Index = ReservedLocalsCount + 0;
private const int VecGpTmp2Index = ReservedLocalsCount + 1;
private const int VecGpTmp3Index = ReservedLocalsCount + 2;
@@ -139,10 +139,10 @@ namespace ChocolArm64.Translation
public void ResetBlockStateForPredicatedOp()
{
- //Check if this is a predicated instruction that modifies flags,
- //in this case the value of the flags is unknown as we don't know
- //in advance if the instruction is going to be executed or not.
- //So, we reset the block state to prevent an invalid optimization.
+ // Check if this is a predicated instruction that modifies flags,
+ // in this case the value of the flags is unknown as we don't know
+ // in advance if the instruction is going to be executed or not.
+ // So, we reset the block state to prevent an invalid optimization.
if (CurrOp == _optOpLastFlagSet)
{
ResetBlockState();
@@ -167,8 +167,8 @@ namespace ChocolArm64.Translation
public bool TryOptEmitSubroutineCall()
{
- //Calls should always have a next block, unless
- //we're translating a single basic block.
+ // Calls should always have a next block, unless
+ // we're translating a single basic block.
if (_currBlock.Next == null)
{
return false;
@@ -239,15 +239,15 @@ namespace ChocolArm64.Translation
&& cond != Condition.GtUn
&& cond != Condition.LeUn)
{
- //There are several limitations that needs to be taken into account for CMN comparisons:
- //- The unsigned comparisons are not valid, as they depend on the
- //carry flag value, and they will have different values for addition and
- //subtraction. For addition, it's carry, and for subtraction, it's borrow.
- //So, we need to make sure we're not doing a unsigned compare for the CMN case.
- //- We can only do the optimization for the immediate variants,
- //because when the second operand value is exactly INT_MIN, we can't
- //negate the value as theres no positive counterpart.
- //Such invalid values can't be encoded on the immediate encodings.
+ // There are several limitations that needs to be taken into account for CMN comparisons:
+ // - The unsigned comparisons are not valid, as they depend on the
+ // carry flag value, and they will have different values for addition and
+ // subtraction. For addition, it's carry, and for subtraction, it's borrow.
+ // So, we need to make sure we're not doing a unsigned compare for the CMN case.
+ // - We can only do the optimization for the immediate variants,
+ // because when the second operand value is exactly INT_MIN, we can't
+ // negate the value as theres no positive counterpart.
+ // Such invalid values can't be encoded on the immediate encodings.
if (_optOpLastCompare is IOpCodeAluImm64 op)
{
Ldloc(CmpOptTmp1Index, RegisterType.Int, _optOpLastCompare.RegisterSize);
@@ -513,11 +513,11 @@ namespace ChocolArm64.Translation
public void EmitLdflg(int index) => Ldloc(index, RegisterType.Flag);
public void EmitStflg(int index)
{
- //Set this only if any of the NZCV flag bits were modified.
- //This is used to ensure that when emiting a direct IL branch
- //instruction for compare + branch sequences, we're not expecting
- //to use comparison values from an old instruction, when in fact
- //the flags were already overwritten by another instruction further along.
+ // Set this only if any of the NZCV flag bits were modified.
+ // This is used to ensure that when emiting a direct IL branch
+ // instruction for compare + branch sequences, we're not expecting
+ // to use comparison values from an old instruction, when in fact
+ // the flags were already overwritten by another instruction further along.
if (index >= (int)PState.VBit)
{
_optOpLastFlagSet = CurrOp;
diff --git a/ChocolArm64/Translation/RegisterUsage.cs b/ChocolArm64/Translation/RegisterUsage.cs
index fe0c8659..f88fa0cd 100644
--- a/ChocolArm64/Translation/RegisterUsage.cs
+++ b/ChocolArm64/Translation/RegisterUsage.cs
@@ -153,7 +153,7 @@ namespace ChocolArm64.Translation
public static long ClearCallerSavedIntRegs(long mask, ExecutionMode mode)
{
- //TODO: ARM32 support.
+ // TODO: ARM32 support.
if (mode == ExecutionMode.Aarch64)
{
mask &= ~(CallerSavedIntRegistersMask | PStateNzcvFlagsMask);
@@ -164,7 +164,7 @@ namespace ChocolArm64.Translation
public static long ClearCallerSavedVecRegs(long mask, ExecutionMode mode)
{
- //TODO: ARM32 support.
+ // TODO: ARM32 support.
if (mode == ExecutionMode.Aarch64)
{
mask &= ~CallerSavedVecRegistersMask;
diff --git a/ChocolArm64/Translation/TranslatedSub.cs b/ChocolArm64/Translation/TranslatedSub.cs
index 704e3b47..cf42e202 100644
--- a/ChocolArm64/Translation/TranslatedSub.cs
+++ b/ChocolArm64/Translation/TranslatedSub.cs
@@ -10,9 +10,9 @@ namespace ChocolArm64.Translation
class TranslatedSub
{
- //This is the minimum amount of calls needed for the method
- //to be retranslated with higher quality code. It's only worth
- //doing that for hot code.
+ // This is the minimum amount of calls needed for the method
+ // to be retranslated with higher quality code. It's only worth
+ // doing that for hot code.
private const int MinCallCountForOpt = 30;
public ArmSubroutine Delegate { get; private set; }
@@ -32,7 +32,7 @@ namespace ChocolArm64.Translation
public TranslatedSub(DynamicMethod method, TranslationTier tier, bool rejit)
{
- Method = method ?? throw new ArgumentNullException(nameof(method));;
+ Method = method ?? throw new ArgumentNullException(nameof(method));
Tier = tier;
_rejit = rejit;
}
@@ -74,7 +74,7 @@ namespace ChocolArm64.Translation
public bool Rejit()
{
- if (!_rejit)
+ if (!_rejit)
{
return false;
}
@@ -84,7 +84,7 @@ namespace ChocolArm64.Translation
return false;
}
- //Only return true once, so that it is added to the queue only once.
+ // Only return true once, so that it is added to the queue only once.
_rejit = false;
return true;
diff --git a/ChocolArm64/Translation/Translator.cs b/ChocolArm64/Translation/Translator.cs
index 2f88aaf9..0803df09 100644
--- a/ChocolArm64/Translation/Translator.cs
+++ b/ChocolArm64/Translation/Translator.cs
@@ -209,11 +209,11 @@ namespace ChocolArm64.Translation
context.ResetBlockStateForPredicatedOp();
- //If this is the last op on the block, and there's no "next" block
- //after this one, then we have to return right now, with the address
- //of the next instruction to be executed (in the case that the condition
- //is false, and the branch was not taken, as all basic blocks should end
- //with some kind of branch).
+ // If this is the last op on the block, and there's no "next" block
+ // after this one, then we have to return right now, with the address
+ // of the next instruction to be executed (in the case that the condition
+ // is false, and the branch was not taken, as all basic blocks should end
+ // with some kind of branch).
if (isLastOp && block.Next == null)
{
context.EmitStoreContext();
diff --git a/ChocolArm64/Translation/TranslatorCache.cs b/ChocolArm64/Translation/TranslatorCache.cs
index d10d6757..cf6510ad 100644
--- a/ChocolArm64/Translation/TranslatorCache.cs
+++ b/ChocolArm64/Translation/TranslatorCache.cs
@@ -8,13 +8,13 @@ namespace ChocolArm64.Translation
{
class TranslatorCache
{
- //Maximum size of the cache, the unit used is completely arbitrary.
+ // Maximum size of the cache, the unit used is completely arbitrary.
private const int MaxTotalSize = 0x800000;
- //Minimum time required in milliseconds for a method to be eligible for deletion.
+ // Minimum time required in milliseconds for a method to be eligible for deletion.
private const int MinTimeDelta = 2 * 60000;
- //Minimum number of calls required to update the timestamp.
+ // Minimum number of calls required to update the timestamp.
private const int MinCallCountForUpdate = 250;
private class CacheBucket
@@ -122,10 +122,10 @@ namespace ChocolArm64.Translation
{
try
{
- //The bucket value on the dictionary may have changed between the
- //time we get the value from the dictionary, and we acquire the
- //lock. So we need to ensure we are working with the latest value,
- //we can do that by getting the value again, inside the lock.
+ // The bucket value on the dictionary may have changed between the
+ // time we get the value from the dictionary, and we acquire the
+ // lock. So we need to ensure we are working with the latest value,
+ // we can do that by getting the value again, inside the lock.
if (_cache.TryGetValue(position, out CacheBucket latestBucket))
{
latestBucket.CallCount = 0;