Skip to content

Commit

Permalink
Improvement to mosa#85 Fix
Browse files Browse the repository at this point in the history
Code improvement
  • Loading branch information
charsleysa committed Mar 29, 2015
1 parent 638a75b commit 10d6039
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Source/Mosa.Compiler.Framework/BaseMethodCompilerStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public abstract class BaseMethodCompilerStage : IMethodCompilerStage, ITraceFact
protected int NativePointerSize { get; private set; }

/// <summary>
/// Holds the native pointer alignment
/// Holds the native alignment
/// </summary>
protected int NativePointerAlignment { get; private set; }
protected int NativeAlignment { get; private set; }

/// <summary>
/// Gets the type of the platform internal runtime.
Expand Down Expand Up @@ -115,7 +115,7 @@ void IMethodCompilerStage.Initialize(BaseMethodCompiler compiler)
CallingConvention = Architecture.CallingConvention;

NativePointerSize = Architecture.NativePointerSize;
NativePointerAlignment = Architecture.NativeAlignment;
NativeAlignment = Architecture.NativeAlignment;
NativeInstructionSize = Architecture.NativeInstructionSize;

traceLogs = new List<TraceLog>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ void CIL.ICILVisitor.Ldstr(Context context)

context.SetInstruction(IRInstruction.Move, context.Result, context.Operand1);

var symbol = linker.CreateSymbol(symbolName, SectionKind.ROData, NativePointerAlignment, NativePointerSize * 3 + stringdata.Length * 2);
var symbol = linker.CreateSymbol(symbolName, SectionKind.ROData, NativeAlignment, NativePointerSize * 3 + stringdata.Length * 2);
var stream = symbol.Stream;

// Type Definition and sync block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void EmitProtectedRegionTable()
{
var trace = CreateTraceLog("Regions");

var protectedRegionTableSymbol = MethodCompiler.Linker.CreateSymbol(MethodCompiler.Method.FullName + Metadata.ProtectedRegionTable, SectionKind.ROData, NativePointerAlignment, 0);
var protectedRegionTableSymbol = MethodCompiler.Linker.CreateSymbol(MethodCompiler.Method.FullName + Metadata.ProtectedRegionTable, SectionKind.ROData, NativeAlignment, 0);
var writer = new EndianAwareBinaryWriter(protectedRegionTableSymbol.Stream, Architecture.Endianness);

int sectioncount = 0;
Expand Down
4 changes: 2 additions & 2 deletions Source/Mosa.Platform.x86/Architecture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public override void InsertMoveInstruction(Context context, Operand destination,
/// <param name="size">The size.</param>
public override void InsertCompoundMoveInstruction(BaseMethodCompiler compiler, Context context, Operand destination, Operand source, int size)
{
int alignedSize = size - (size % 4);
int alignedSize = size - (size % NativeAlignment);
Debug.Assert(size > 0);

var src = source;
Expand All @@ -308,7 +308,7 @@ public override void InsertCompoundMoveInstruction(BaseMethodCompiler compiler,

context.AppendInstruction(X86.Lea, srcReg, src);
context.AppendInstruction(X86.Lea, dstReg, dest);
for (int i = 0; i < alignedSize; i += 4)
for (int i = 0; i < alignedSize; i += NativeAlignment)
{
context.AppendInstruction(X86.Mov, InstructionSize.Size32, tmp, Operand.CreateMemoryAddress(src.Type.TypeSystem.BuiltIn.I4, srcReg, i));
context.AppendInstruction(X86.Mov, InstructionSize.Size32, Operand.CreateMemoryAddress(dest.Type.TypeSystem.BuiltIn.I4, dstReg, i), tmp);
Expand Down
12 changes: 6 additions & 6 deletions Source/Mosa.Platform.x86/Stages/IRTransformationStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void IIRVisitor.CompoundLoad(Context context)
{
var type = context.Result.Type;
int typeSize = TypeLayout.GetTypeSize(type);
int alignedTypeSize = typeSize - (typeSize % 4);
int alignedTypeSize = typeSize - (typeSize % NativeAlignment);
Debug.Assert(typeSize > 0, context.Operand2.Name);

int offset = 0;
Expand All @@ -373,7 +373,7 @@ void IIRVisitor.CompoundLoad(Context context)
context.AppendInstruction(X86.Add, srcReg, srcReg, offsetop);
}

for (int i = 0; i < alignedTypeSize; i += 4)
for (int i = 0; i < alignedTypeSize; i += NativeAlignment)
{
context.AppendInstruction(X86.Mov, InstructionSize.Size32, tmp, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, srcReg, i + offset));
context.AppendInstruction(X86.Mov, InstructionSize.Size32, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, dstReg, i), tmp);
Expand Down Expand Up @@ -529,7 +529,7 @@ void IIRVisitor.CompoundMove(Context context)
{
var type = context.Result.Type;
int typeSize = TypeLayout.GetTypeSize(type);
int alignedTypeSize = typeSize - (typeSize % 4);
int alignedTypeSize = typeSize - (typeSize % NativeAlignment);
Debug.Assert(typeSize > 0, MethodCompiler.Method.FullName);

var src = context.Operand1;
Expand All @@ -551,7 +551,7 @@ void IIRVisitor.CompoundMove(Context context)
}
context.AppendInstruction(X86.Lea, dstReg, dest);

for (int i = 0; i < alignedTypeSize; i += 4)
for (int i = 0; i < alignedTypeSize; i += NativeAlignment)
{
context.AppendInstruction(X86.Mov, InstructionSize.Size32, tmp, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, srcReg, i));
context.AppendInstruction(X86.Mov, InstructionSize.Size32, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, dstReg, i), tmp);
Expand Down Expand Up @@ -697,7 +697,7 @@ void IIRVisitor.CompoundStore(Context context)
{
var type = context.Operand3.Type;
int typeSize = TypeLayout.GetTypeSize(type);
int alignedTypeSize = typeSize - (typeSize % 4);
int alignedTypeSize = typeSize - (typeSize % NativeAlignment);
Debug.Assert(typeSize > 0, MethodCompiler.Method.FullName);

int offset = 0;
Expand All @@ -724,7 +724,7 @@ void IIRVisitor.CompoundStore(Context context)
context.AppendInstruction(X86.Add, dstReg, dstReg, offsetop);
}

for (int i = 0; i < alignedTypeSize; i += 4)
for (int i = 0; i < alignedTypeSize; i += NativeAlignment)
{
context.AppendInstruction(X86.Mov, InstructionSize.Size32, tmp, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, srcReg, i));
context.AppendInstruction(X86.Mov, InstructionSize.Size32, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, dstReg, i + offset), tmp);
Expand Down

0 comments on commit 10d6039

Please sign in to comment.