No asm labels for X#

This commit is contained in:
kudzu_cp 2011-07-18 01:25:43 +00:00
parent 812603b385
commit bcfd0dd94f
3 changed files with 21 additions and 18 deletions

View file

@ -14,8 +14,8 @@ using System.Xml;
namespace Cosmos.Compiler.Assembler { namespace Cosmos.Compiler.Assembler {
public abstract class Assembler { public abstract class Assembler {
public virtual void Initialize() { public virtual void Initialize() { }
}
// Contains info on the current stack structure. What type are on the stack, etc // Contains info on the current stack structure. What type are on the stack, etc
public readonly StackContents Stack = new StackContents(); public readonly StackContents Stack = new StackContents();
@ -23,6 +23,8 @@ namespace Cosmos.Compiler.Assembler {
// as it will also cause problems when we thread the compiler // as it will also cause problems when we thread the compiler
private static Assembler mCurrentInstance; private static Assembler mCurrentInstance;
public bool EmitAsmLabels { get; set; }
protected int mCurrentMethodID; protected int mCurrentMethodID;
public int CurrentMethodID { public int CurrentMethodID {
get { return mCurrentMethodID; } get { return mCurrentMethodID; }
@ -101,20 +103,22 @@ namespace Cosmos.Compiler.Assembler {
return null; return null;
} }
public void Add(Instruction aReader){ public void Add(Instruction aReader) {
if (aReader is Label || aReader is Comment) { if (aReader is Label || aReader is Comment) {
} else { } else {
// Only issue label if its executable code. if (EmitAsmLabels) {
// Also above if statement will prevent this new label // Only issue label if its executable code.
// from causing a stack overflow // Also above if statement will prevent this new label
new Label("." + AsmIlIdx.ToString("X2")); // from causing a stack overflow
mAsmIlIdx++; new Label("." + AsmIlIdx.ToString("X2"));
mAsmIlIdx++;
}
}
mInstructions.Add(aReader);
} }
mInstructions.Add(aReader);
}
public void Add(params Instruction[] aReaders) { public void Add(params Instruction[] aReaders) {
mInstructions.Capacity += aReaders.Length; mInstructions.Capacity += aReaders.Length;
foreach (Instruction xInstruction in aReaders) { foreach (Instruction xInstruction in aReaders) {
mInstructions.Add(xInstruction); mInstructions.Add(xInstruction);
} }

View file

@ -51,10 +51,7 @@ namespace Cosmos.Compiler.XSharp {
SetDataMembers(xBlock); SetDataMembers(xBlock);
// Issue label for the routine // Issue label for the routine
// TODO: Instead of issuing IL label, allow ASM option to turn xBlock.Label = CodeBlock.MakeLabel(xType);
// off ASM labeling.
mAsm.CurrentIlLabel = CodeBlock.MakeLabel(xType);
xBlock.Label = mAsm.CurrentIlLabel;
if (xPreserveStack) { if (xPreserveStack) {
xBlock.PushAll(); xBlock.PushAll();

View file

@ -264,6 +264,8 @@ namespace Cosmos.IL2CPU.X86 {
new Label("DebugStub_Step"); new Label("DebugStub_Step");
new Return(); new Return();
} }
// Start emitting assembly labels
Assembler.CurrentInstance.EmitAsmLabels = true;
#if !LFB_1024_8 #if !LFB_1024_8
DataMembers.Add(new DataIfNotDefined("ELF_COMPILATION")); DataMembers.Add(new DataIfNotDefined("ELF_COMPILATION"));