public override LLLocation Load(LLInstructionBlock pBlock) { LLLocation destination = LLTemporaryLocation.Create(pBlock.Function.CreateTemporary(Type.PointerDepthMinusOne)); pBlock.EmitLoad(destination, this); return(destination); }
internal void Transform() { Labels.ForEach(l => LLFunction.CreateLabel(l.Identifier)); foreach (HLInstructionBlock hl in Blocks) { LLInstructionBlock ll = LLFunction.CreateBlock(LLFunction.Labels.GetByIdentifier(hl.StartLabel.Identifier)); LLFunction.CurrentBlock = ll; if (hl == Blocks.First()) { foreach (HLParameter parameter in Parameters.Where(p => p.RequiresAddressing)) { LLFunction.CurrentBlock.EmitStore(LLLocalLocation.Create(parameter.AddressableLocal), LLParameterLocation.Create(LLFunction.Parameters[parameter.Name])); } } hl.Instructions.ForEach(i => i.Transform(LLFunction)); } }
internal static void CheckStaticConstructorCalled(LLFunction pFunction, HLType pType) { if (pType.StaticConstructor == null) { return; } if (pType.StaticConstructor.LLFunction == pFunction) { return; } LLLocation locationConstructorCalled = LLGlobalLocation.Create(LLModule.GetGlobal(pType.ToString())); LLLocation locationConstructorCalledOriginal = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationConstructorCalled.Type.PointerDepthMinusOne)); pFunction.CurrentBlock.EmitCompareExchange(locationConstructorCalledOriginal, locationConstructorCalled, LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "0")), LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "1")), LLCompareExchangeOrdering.acq_rel); LLLocation locationConstructorCall = LLTemporaryLocation.Create(pFunction.CreateTemporary(LLModule.BooleanType)); pFunction.CurrentBlock.EmitCompareIntegers(locationConstructorCall, locationConstructorCalledOriginal, LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "0")), LLCompareIntegersCondition.eq); LLLabel labelTrue = pFunction.CreateLabel(pFunction.Labels.Count); LLLabel labelFalse = pFunction.CreateLabel(pFunction.Labels.Count); LLLabel labelNext = pFunction.CreateLabel(pFunction.Labels.Count); pFunction.CurrentBlock.EmitBranch(locationConstructorCall, labelTrue, labelFalse); LLInstructionBlock blockTrue = pFunction.CreateBlock(labelTrue); List <LLLocation> parameters = new List <LLLocation>(); parameters.Add(LLLiteralLocation.Create(LLLiteral.Create(pType.StaticConstructor.LLFunction.Parameters[0].Type, "zeroinitializer"))); blockTrue.EmitCall(null, LLFunctionLocation.Create(pType.StaticConstructor.LLFunction), parameters); blockTrue.EmitGoto(labelNext); LLInstructionBlock blockFalse = pFunction.CreateBlock(labelFalse); blockFalse.EmitGoto(labelNext); pFunction.CurrentBlock = pFunction.CreateBlock(labelNext); }
public override void Store(LLInstructionBlock pBlock, LLLocation pSource) { LLLocation source = pBlock.EmitConversion(pSource, Type.PointerDepthMinusOne); pBlock.EmitStore(this, source); }
public override LLLocation Load(LLInstructionBlock pBlock) { LLLocation destination = LLTemporaryLocation.Create(pBlock.Function.CreateTemporary(Type.PointerDepthMinusOne)); pBlock.EmitLoad(destination, this); return destination; }
public override LLLocation Load(LLInstructionBlock pBlock) { return this; }
public override LLLocation Load(LLInstructionBlock pBlock) { return(this); }