Rename ILEmitter to ILMethodBuilder

This commit is contained in:
gdkchan 2018-11-30 21:38:53 -03:00
commit 3b21dced97
15 changed files with 26 additions and 26 deletions

View file

@ -2,6 +2,6 @@ namespace ChocolArm64.Translation
{ {
interface IILEmit interface IILEmit
{ {
void Emit(ILEmitter context); void Emit(ILMethodBuilder context);
} }
} }

View file

@ -2,6 +2,6 @@ namespace ChocolArm64.Translation
{ {
struct ILBarrier : IILEmit struct ILBarrier : IILEmit
{ {
public void Emit(ILEmitter context) { } public void Emit(ILMethodBuilder context) { }
} }
} }

View file

@ -37,7 +37,7 @@ namespace ChocolArm64.Translation
IntAwOutputs = IntOutputs; IntAwOutputs = IntOutputs;
VecAwOutputs = VecOutputs; VecAwOutputs = VecOutputs;
} }
else if (emitter is ILOpCodeLoad ld && ILEmitter.IsRegIndex(ld.Index)) else if (emitter is ILOpCodeLoad ld && ILMethodBuilder.IsRegIndex(ld.Index))
{ {
switch (ld.IoType) switch (ld.IoType)
{ {
@ -46,7 +46,7 @@ namespace ChocolArm64.Translation
case IoType.Vector: VecInputs |= (1L << ld.Index) & ~VecAwOutputs; break; case IoType.Vector: VecInputs |= (1L << ld.Index) & ~VecAwOutputs; break;
} }
} }
else if (emitter is ILOpCodeStore st && ILEmitter.IsRegIndex(st.Index)) else if (emitter is ILOpCodeStore st && ILMethodBuilder.IsRegIndex(st.Index))
{ {
switch (st.IoType) switch (st.IoType)
{ {
@ -63,7 +63,7 @@ namespace ChocolArm64.Translation
_emitters.Add(emitter); _emitters.Add(emitter);
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
foreach (IILEmit ilEmitter in _emitters) foreach (IILEmit ilEmitter in _emitters)
{ {

View file

@ -8,12 +8,12 @@ namespace ChocolArm64.Translation
private Label _lbl; private Label _lbl;
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
context.Generator.MarkLabel(GetLabel(context)); context.Generator.MarkLabel(GetLabel(context));
} }
public Label GetLabel(ILEmitter context) public Label GetLabel(ILMethodBuilder context)
{ {
if (!_hasLabel) if (!_hasLabel)
{ {

View file

@ -6,7 +6,7 @@ using System.Runtime.Intrinsics;
namespace ChocolArm64.Translation namespace ChocolArm64.Translation
{ {
class ILEmitter class ILMethodBuilder
{ {
public LocalAlloc LocalAlloc { get; private set; } public LocalAlloc LocalAlloc { get; private set; }
@ -20,7 +20,7 @@ namespace ChocolArm64.Translation
private int _localsCount; private int _localsCount;
public ILEmitter(ILBlock[] ilBlocks, string subName) public ILMethodBuilder(ILBlock[] ilBlocks, string subName)
{ {
_ilBlocks = ilBlocks; _ilBlocks = ilBlocks;
_subName = subName; _subName = subName;

View file

@ -11,7 +11,7 @@ namespace ChocolArm64.Translation
_ilOp = ilOp; _ilOp = ilOp;
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
context.Generator.Emit(_ilOp); context.Generator.Emit(_ilOp);
} }

View file

@ -13,7 +13,7 @@ namespace ChocolArm64.Translation
_label = label; _label = label;
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
context.Generator.Emit(_ilOp, _label.GetLabel(context)); context.Generator.Emit(_ilOp, _label.GetLabel(context));
} }

View file

@ -12,7 +12,7 @@ namespace ChocolArm64.Translation
_mthdInfo = mthdInfo; _mthdInfo = mthdInfo;
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
context.Generator.Emit(OpCodes.Call, _mthdInfo); context.Generator.Emit(OpCodes.Call, _mthdInfo);
} }

View file

@ -51,7 +51,7 @@ namespace ChocolArm64.Translation
_value = new ImmVal { R8 = value }; _value = new ImmVal { R8 = value };
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
switch (_type) switch (_type)
{ {

View file

@ -18,7 +18,7 @@ namespace ChocolArm64.Translation
RegisterSize = registerSize; RegisterSize = registerSize;
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
switch (IoType) switch (IoType)
{ {
@ -30,7 +30,7 @@ namespace ChocolArm64.Translation
} }
} }
private void EmitLdloc(ILEmitter context, int index, RegisterType registerType) private void EmitLdloc(ILMethodBuilder context, int index, RegisterType registerType)
{ {
Register reg = new Register(index, registerType); Register reg = new Register(index, registerType);

View file

@ -12,7 +12,7 @@ namespace ChocolArm64.Translation
_block = block; _block = block;
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
long intInputs = context.LocalAlloc.GetIntInputs(_block); long intInputs = context.LocalAlloc.GetIntInputs(_block);
long vecInputs = context.LocalAlloc.GetVecInputs(_block); long vecInputs = context.LocalAlloc.GetVecInputs(_block);
@ -21,7 +21,7 @@ namespace ChocolArm64.Translation
LoadLocals(context, vecInputs, RegisterType.Vector); LoadLocals(context, vecInputs, RegisterType.Vector);
} }
private void LoadLocals(ILEmitter context, long inputs, RegisterType baseType) private void LoadLocals(ILMethodBuilder context, long inputs, RegisterType baseType)
{ {
for (int bit = 0; bit < 64; bit++) for (int bit = 0; bit < 64; bit++)
{ {
@ -29,7 +29,7 @@ namespace ChocolArm64.Translation
if ((inputs & mask) != 0) if ((inputs & mask) != 0)
{ {
Register reg = ILEmitter.GetRegFromBit(bit, baseType); Register reg = ILMethodBuilder.GetRegFromBit(bit, baseType);
context.Generator.EmitLdarg(TranslatedSub.StateArgIdx); context.Generator.EmitLdarg(TranslatedSub.StateArgIdx);
context.Generator.Emit(OpCodes.Ldfld, reg.GetField()); context.Generator.Emit(OpCodes.Ldfld, reg.GetField());

View file

@ -9,7 +9,7 @@ namespace ChocolArm64.Translation
_text = text; _text = text;
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
context.Generator.EmitWriteLine(_text); context.Generator.EmitWriteLine(_text);
} }

View file

@ -18,7 +18,7 @@ namespace ChocolArm64.Translation
RegisterSize = registerSize; RegisterSize = registerSize;
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
switch (IoType) switch (IoType)
{ {
@ -30,7 +30,7 @@ namespace ChocolArm64.Translation
} }
} }
private void EmitStloc(ILEmitter context, int index, RegisterType registerType) private void EmitStloc(ILMethodBuilder context, int index, RegisterType registerType)
{ {
Register reg = new Register(index, registerType); Register reg = new Register(index, registerType);

View file

@ -12,7 +12,7 @@ namespace ChocolArm64.Translation
_block = block; _block = block;
} }
public void Emit(ILEmitter context) public void Emit(ILMethodBuilder context)
{ {
long intOutputs = context.LocalAlloc.GetIntOutputs(_block); long intOutputs = context.LocalAlloc.GetIntOutputs(_block);
long vecOutputs = context.LocalAlloc.GetVecOutputs(_block); long vecOutputs = context.LocalAlloc.GetVecOutputs(_block);
@ -21,7 +21,7 @@ namespace ChocolArm64.Translation
StoreLocals(context, vecOutputs, RegisterType.Vector); StoreLocals(context, vecOutputs, RegisterType.Vector);
} }
private void StoreLocals(ILEmitter context, long outputs, RegisterType baseType) private void StoreLocals(ILMethodBuilder context, long outputs, RegisterType baseType)
{ {
for (int bit = 0; bit < 64; bit++) for (int bit = 0; bit < 64; bit++)
{ {
@ -29,7 +29,7 @@ namespace ChocolArm64.Translation
if ((outputs & mask) != 0) if ((outputs & mask) != 0)
{ {
Register reg = ILEmitter.GetRegFromBit(bit, baseType); Register reg = ILMethodBuilder.GetRegFromBit(bit, baseType);
context.Generator.EmitLdarg(TranslatedSub.StateArgIdx); context.Generator.EmitLdarg(TranslatedSub.StateArgIdx);
context.Generator.EmitLdloc(context.GetLocalIndex(reg)); context.Generator.EmitLdloc(context.GetLocalIndex(reg));

View file

@ -93,7 +93,7 @@ namespace ChocolArm64
string subName = GetSubroutineName(position); string subName = GetSubroutineName(position);
ILEmitter ilMthdBuilder = new ILEmitter(context.GetILBlocks(), subName); ILMethodBuilder ilMthdBuilder = new ILMethodBuilder(context.GetILBlocks(), subName);
TranslatedSub subroutine = ilMthdBuilder.GetSubroutine(); TranslatedSub subroutine = ilMthdBuilder.GetSubroutine();
@ -138,7 +138,7 @@ namespace ChocolArm64
ILBlock[] ilBlocks = context.GetILBlocks(); ILBlock[] ilBlocks = context.GetILBlocks();
ILEmitter ilMthdBuilder = new ILEmitter(ilBlocks, subName); ILMethodBuilder ilMthdBuilder = new ILMethodBuilder(ilBlocks, subName);
TranslatedSub subroutine = ilMthdBuilder.GetSubroutine(); TranslatedSub subroutine = ilMthdBuilder.GetSubroutine();