public static LLCommentInstruction Create(LLFunction pFunction, string pComment) { LLCommentInstruction instruction = new LLCommentInstruction(pFunction); instruction.mComment = pComment; return(instruction); }
public static LLAllocateInstruction Create(LLFunction pFunction, LLLocation pDestination) { LLAllocateInstruction instruction = new LLAllocateInstruction(pFunction); instruction.mDestination = pDestination; return(instruction); }
public static LLGotoInstruction Create(LLFunction pFunction, LLLabel pTargetLabel) { LLGotoInstruction instruction = new LLGotoInstruction(pFunction); instruction.mTargetLabel = pTargetLabel; return(instruction); }
public static LLBitcastInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pSource) { LLBitcastInstruction instruction = new LLBitcastInstruction(pFunction); instruction.mDestination = pDestination; instruction.mSource = pSource; return instruction; }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (mReturnDestination != null) { sb.AppendFormat("{0} = ", mReturnDestination); } sb.AppendFormat("call {0} {1}(", mReturnDestination == null ? LLModule.VoidType : mReturnDestination.Type, mFunctionSource); for (int index = 0; index < mParameterSources.Count; ++index) { LLLocation parameterSource = mParameterSources[index]; if (index > 0) { sb.Append(", "); } sb.AppendFormat("{0} {1}", parameterSource.Type, parameterSource); } sb.Append(")"); if (mFunctionSource is LLFunctionLocation) { LLFunction function = ((LLFunctionLocation)mFunctionSource).Function; if (function.Description != null) { sb.AppendFormat(" ; {0}", function.Description); } } return(sb.ToString()); }
public static LLIntegerToPointerInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pSource) { LLIntegerToPointerInstruction instruction = new LLIntegerToPointerInstruction(pFunction); instruction.mDestination = pDestination; instruction.mSource = pSource; return instruction; }
public static LLFunctionLocation Create(LLFunction pFunction) { LLFunctionLocation location = new LLFunctionLocation(LLModule.GetOrCreateFunctionType(pFunction.ReturnType, pFunction.Parameters.ToTypeList()).PointerDepthPlusOne); location.mFunction = pFunction; return(location); }
public static LLLabelInstruction Create(LLFunction pFunction, LLLabel pLabel) { LLLabelInstruction instruction = new LLLabelInstruction(pFunction); instruction.mLabel = pLabel; return(instruction); }
public static LLReturnInstruction Create(LLFunction pFunction, LLLocation pSource) { LLReturnInstruction instruction = new LLReturnInstruction(pFunction); instruction.mSource = pSource; return(instruction); }
internal override void Store(LLFunction pFunction, LLLocation pSource) { LLLocation locationLocal = LLLocalLocation.Create(pFunction.Locals[Temporary.Name]); LLLocation locationSource = pFunction.CurrentBlock.EmitConversion(pSource, locationLocal.Type.PointerDepthMinusOne); pFunction.CurrentBlock.EmitStore(locationLocal, locationSource); }
private static void BuildDelegateInstance() { List <LLParameter> parametersFunction = new List <LLParameter>(); parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), "this")); sDelegateInstance = LLModule.GetOrCreateFunction("DelegateInstance", true, true, false, LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), parametersFunction); }
internal void BuildFunction() { // DONE: Convert HLMethods to LLFunctions List <LLParameter> parameters = new List <LLParameter>(); foreach (HLParameter parameter in Parameters) { LLType typeParameter = parameter.Type.LLType; // DONE: Adjust first parameter for string constructors to additional pointer depth plus one if (parameter == Parameters.First() && Container == HLDomain.SystemString && !IsStatic && IsConstructor) { typeParameter = typeParameter.PointerDepthPlusOne; } parameters.Add(LLParameter.Create(typeParameter, parameter.Name)); } bool entryFunction = HLDomain.EntryMethod == this; mLLFunction = LLModule.GetOrCreateFunction(entryFunction ? "main" : (Container.ToString() + "." + ToString()), entryFunction, IsExternal, IsAbstract || IsRuntimeImplemented, ReturnType.LLType, parameters); LLFunction.Description = Signature; foreach (HLParameter parameter in Parameters.Where(p => p.RequiresAddressing)) { parameter.AddressableLocal = LLFunction.CreateLocal(parameter.Type.LLType, "local_" + parameter.Name); } foreach (HLLocal local in Locals) { LLFunction.CreateLocal(local.Type.LLType, local.Name); } foreach (HLTemporary temporary in Temporaries) { LLFunction.CreateLocal(temporary.Type.LLType, temporary.Name); } }
internal override void Store(LLFunction pFunction, LLLocation pSource) { LLLocation locationElementPointer = HLArrayElementAddressLocation.LoadArrayElementPointer(pFunction, Instance, Index, ElementType); LLLocation locationSource = pFunction.CurrentBlock.EmitConversion(pSource, locationElementPointer.Type.PointerDepthMinusOne); pFunction.CurrentBlock.EmitStore(locationElementPointer, locationSource); }
internal override void Store(LLFunction pFunction, LLLocation pSource) { LLLocation locationFieldPointer = HLFieldAddressLocation.LoadInstanceFieldPointer(pFunction, Instance, Field); LLLocation locationSource = pFunction.CurrentBlock.EmitConversion(pSource, locationFieldPointer.Type.PointerDepthMinusOne); pFunction.CurrentBlock.EmitStore(locationFieldPointer, locationSource); }
internal override LLLocation Load(LLFunction pFunction) { LLLocation locationAddress = mAddress.Load(pFunction); locationAddress = pFunction.CurrentBlock.EmitConversion(locationAddress, Type.LLType); return(locationAddress.Load(pFunction.CurrentBlock)); }
internal override void Transform(LLFunction pFunction) { LLLocation locationCondition = mConditionSource.Load(pFunction); locationCondition = pFunction.CurrentBlock.EmitConversion(locationCondition, LLModule.BooleanType); pFunction.CurrentBlock.EmitBranch(locationCondition, pFunction.Labels.GetByIdentifier(mTrueLabel.Identifier), pFunction.Labels.GetByIdentifier(mFalseLabel.Identifier)); }
public static LLGetElementPointerInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pPointerSource, params LLLocation[] pIndexSources) { LLGetElementPointerInstruction instruction = new LLGetElementPointerInstruction(pFunction); instruction.mDestination = pDestination; instruction.mPointerSource = pPointerSource; instruction.mIndexSources = new List<LLLocation>(pIndexSources); return instruction; }
internal override LLLocation Load(LLFunction pFunction) { LLLocation locationFieldPointer = HLFieldAddressLocation.LoadInstanceFieldPointer(pFunction, Instance, Field); LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationFieldPointer.Type.PointerDepthMinusOne)); pFunction.CurrentBlock.EmitLoad(locationTemporary, locationFieldPointer); return(locationTemporary); }
public static LLCallInstruction Create(LLFunction pFunction, LLLocation pReturnDestination, LLLocation pFunctionSource, List<LLLocation> pParameterSources) { LLCallInstruction instruction = new LLCallInstruction(pFunction); instruction.mReturnDestination = pReturnDestination; instruction.mFunctionSource = pFunctionSource; instruction.mParameterSources = new List<LLLocation>(pParameterSources); return instruction; }
public static LLSignedRightShiftInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pLeftSource, LLLocation pRightSource) { LLSignedRightShiftInstruction instruction = new LLSignedRightShiftInstruction(pFunction); instruction.mDestination = pDestination; instruction.mLeftSource = pLeftSource; instruction.mRightSource = pRightSource; return instruction; }
internal override LLLocation Load(LLFunction pFunction) { if (!Parameter.RequiresAddressing) { throw new NotSupportedException(); } return(LLLocalLocation.Create(Parameter.AddressableLocal)); }
private static void BuildVTableFunctionLookup() { List <LLParameter> parametersFunction = new List <LLParameter>(); parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), "this")); parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreateSignedType(32), "index")); sVTableFunctionLookup = LLModule.GetOrCreateFunction("VTableFunctionLookup", true, true, false, LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), parametersFunction); }
internal override LLLocation Load(LLFunction pFunction) { LLLocation locationLocal = LLLocalLocation.Create(pFunction.Locals[Temporary.Name]); LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationLocal.Type.PointerDepthMinusOne)); pFunction.CurrentBlock.EmitLoad(locationTemporary, locationLocal); return(locationTemporary); }
internal override void Store(LLFunction pFunction, LLLocation pSource) { HLStaticFieldAddressLocation.CheckStaticConstructorCalled(pFunction, StaticField.Container); LLLocation locationFieldPointer = LLGlobalLocation.Create(LLModule.GetGlobal(StaticField.Container.ToString() + "." + StaticField.ToString())); LLLocation locationSource = pFunction.CurrentBlock.EmitConversion(pSource, locationFieldPointer.Type.PointerDepthMinusOne); pFunction.CurrentBlock.EmitStore(locationFieldPointer, locationSource); }
internal override LLLocation Load(LLFunction pFunction) { //LLLocation locationFieldPointer = LoadInstanceFieldPointer(pFunction, mInstance, mField); //LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationFieldPointer.Type.PointerDepthMinusOne)); //pFunction.CurrentBlock.EmitLoad(locationTemporary, locationFieldPointer); //return locationTemporary; return(LoadInstanceFieldPointer(pFunction, Instance, Field)); }
public static LLTruncateInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pSource) { LLTruncateInstruction instruction = new LLTruncateInstruction(pFunction); instruction.mDestination = pDestination; instruction.mSource = pSource; return(instruction); }
public static LLBranchInstruction Create(LLFunction pFunction, LLLocation pConditionSource, LLLabel pTrueTargetLabel, LLLabel pFalseTargetLabel) { LLBranchInstruction instruction = new LLBranchInstruction(pFunction); instruction.mConditionSource = pConditionSource; instruction.mTrueTargetLabel = pTrueTargetLabel; instruction.mFalseTargetLabel = pFalseTargetLabel; return instruction; }
private static void BuildGCRoot() { List <LLParameter> parametersFunction = new List <LLParameter>(); parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 2), "ptrloc")); parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), "metadata")); sGCRoot = LLModule.GetOrCreateFunction("llvm.gcroot", true, true, false, LLModule.VoidType, parametersFunction); }
internal override LLLocation Load(LLFunction pFunction) { LLLocation locationElementPointer = HLArrayElementAddressLocation.LoadArrayElementPointer(pFunction, Instance, Index, ElementType); LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationElementPointer.Type.PointerDepthMinusOne)); pFunction.CurrentBlock.EmitLoad(locationTemporary, locationElementPointer); return(locationTemporary); }
internal override void Store(LLFunction pFunction, LLLocation pSource) { LLLocation locationAddress = mAddress.Load(pFunction); locationAddress = pFunction.CurrentBlock.EmitConversion(locationAddress, Type.LLType); LLLocation locationSource = pFunction.CurrentBlock.EmitConversion(pSource, locationAddress.Type.PointerDepthMinusOne); pFunction.CurrentBlock.EmitStore(locationAddress, locationSource); }
internal override void Transform(LLFunction pFunction) { LLLocation locationLeftOperand = mLeftOperandSource.Load(pFunction); LLLocation locationRightOperand = mRightOperandSource.Load(pFunction); LLType typeOperands = LLModule.BinaryResult(locationLeftOperand.Type, locationRightOperand.Type); locationLeftOperand = pFunction.CurrentBlock.EmitConversion(locationLeftOperand, typeOperands); locationRightOperand = pFunction.CurrentBlock.EmitConversion(locationRightOperand, typeOperands); LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(LLModule.BooleanType)); if (typeOperands.Primitive == LLPrimitive.Float) { LLCompareFloatsCondition condition = LLCompareFloatsCondition.oeq; switch (mCompareType) { case HLCompareType.Equal: condition = LLCompareFloatsCondition.oeq; break; case HLCompareType.NotEqual: condition = LLCompareFloatsCondition.one; break; case HLCompareType.GreaterThan: condition = LLCompareFloatsCondition.ogt; break; case HLCompareType.GreaterThanOrEqual: condition = LLCompareFloatsCondition.oge; break; case HLCompareType.LessThan: condition = LLCompareFloatsCondition.olt; break; case HLCompareType.LessThanOrEqual: condition = LLCompareFloatsCondition.ole; break; default: throw new NotSupportedException(); } pFunction.CurrentBlock.EmitCompareFloats(locationTemporary, locationLeftOperand, locationRightOperand, condition); } else { LLCompareIntegersCondition condition = LLCompareIntegersCondition.eq; switch (mCompareType) { case HLCompareType.Equal: condition = LLCompareIntegersCondition.eq; break; case HLCompareType.NotEqual: condition = LLCompareIntegersCondition.ne; break; case HLCompareType.GreaterThan: condition = typeOperands.Primitive == LLPrimitive.Unsigned ? LLCompareIntegersCondition.ugt : LLCompareIntegersCondition.sgt; break; case HLCompareType.GreaterThanOrEqual: condition = typeOperands.Primitive == LLPrimitive.Unsigned ? LLCompareIntegersCondition.uge : LLCompareIntegersCondition.sge; break; case HLCompareType.LessThan: condition = typeOperands.Primitive == LLPrimitive.Unsigned ? LLCompareIntegersCondition.ult : LLCompareIntegersCondition.slt; break; case HLCompareType.LessThanOrEqual: condition = typeOperands.Primitive == LLPrimitive.Unsigned ? LLCompareIntegersCondition.ule : LLCompareIntegersCondition.sle; break; default: throw new NotSupportedException(); } pFunction.CurrentBlock.EmitCompareIntegers(locationTemporary, locationLeftOperand, locationRightOperand, condition); } mDestination.Store(pFunction, locationTemporary); }
public static LLOrInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pLeftSource, LLLocation pRightSource) { LLOrInstruction instruction = new LLOrInstruction(pFunction); instruction.mDestination = pDestination; instruction.mLeftSource = pLeftSource; instruction.mRightSource = pRightSource; return(instruction); }
internal override LLLocation Load(LLFunction pFunction) { HLStaticFieldAddressLocation.CheckStaticConstructorCalled(pFunction, StaticField.Container); LLLocation locationFieldPointer = LLGlobalLocation.Create(LLModule.GetGlobal(StaticField.Container.ToString() + "." + StaticField.ToString())); LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationFieldPointer.Type.PointerDepthMinusOne)); pFunction.CurrentBlock.EmitLoad(locationTemporary, locationFieldPointer); return(locationTemporary); }
public static LLGetElementPointerInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pPointerSource, params LLLocation[] pIndexSources) { LLGetElementPointerInstruction instruction = new LLGetElementPointerInstruction(pFunction); instruction.mDestination = pDestination; instruction.mPointerSource = pPointerSource; instruction.mIndexSources = new List <LLLocation>(pIndexSources); return(instruction); }
private static void BuildGCAllocate() { List <LLParameter> parametersFunction = new List <LLParameter>(); parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 2), "this")); parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreateUnsignedType(32), "size")); parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreateSignedType(32), "handle")); sGCAllocate = LLModule.GetOrCreateFunction("GCAllocate", true, true, false, LLModule.VoidType, parametersFunction); }
public static LLCallInstruction Create(LLFunction pFunction, LLLocation pReturnDestination, LLLocation pFunctionSource, List <LLLocation> pParameterSources) { LLCallInstruction instruction = new LLCallInstruction(pFunction); instruction.mReturnDestination = pReturnDestination; instruction.mFunctionSource = pFunctionSource; instruction.mParameterSources = new List <LLLocation>(pParameterSources); return(instruction); }
public static LLCompareIntegersInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pLeftSource, LLLocation pRightSource, LLCompareIntegersCondition pCondition) { LLCompareIntegersInstruction instruction = new LLCompareIntegersInstruction(pFunction); instruction.mDestination = pDestination; instruction.mLeftSource = pLeftSource; instruction.mRightSource = pRightSource; instruction.mCondition = pCondition; return instruction; }
public static LLCompareExchangeInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pPointerSource, LLLocation pComparedSource, LLLocation pNewSource, LLCompareExchangeOrdering pOrdering) { LLCompareExchangeInstruction instruction = new LLCompareExchangeInstruction(pFunction); instruction.mDestination = pDestination; instruction.mPointerSource = pPointerSource; instruction.mComparedSource = pComparedSource; instruction.mNewSource = pNewSource; instruction.mOrdering = pOrdering; return instruction; }
public static LLGotoInstruction Create(LLFunction pFunction, LLLabel pTargetLabel) { LLGotoInstruction instruction = new LLGotoInstruction(pFunction); instruction.mTargetLabel = pTargetLabel; return instruction; }
private LLGotoInstruction(LLFunction pFunction) : base(pFunction) { }
public static LLReturnInstruction Create(LLFunction pFunction, LLLocation pSource) { LLReturnInstruction instruction = new LLReturnInstruction(pFunction); instruction.mSource = pSource; return instruction; }
public static LLLabelInstruction Create(LLFunction pFunction, LLLabel pLabel) { LLLabelInstruction instruction = new LLLabelInstruction(pFunction); instruction.mLabel = pLabel; return instruction; }
private LLMultiplyInstruction(LLFunction pFunction) : base(pFunction) { }
public static LLFunctionLocation Create(LLFunction pFunction) { LLFunctionLocation location = new LLFunctionLocation(LLModule.GetOrCreateFunctionType(pFunction.ReturnType, pFunction.Parameters.ToTypeList()).PointerDepthPlusOne); location.mFunction = pFunction; return location; }
private LLCompareIntegersInstruction(LLFunction pFunction) : base(pFunction) { }
private LLCompareExchangeInstruction(LLFunction pFunction) : base(pFunction) { }
private LLStoreInstruction(LLFunction pFunction) : base(pFunction) { }
private LLXorInstruction(LLFunction pFunction) : base(pFunction) { }
private LLCommentInstruction(LLFunction pFunction) : base(pFunction) { }
private LLReturnInstruction(LLFunction pFunction) : base(pFunction) { }
private LLBranchInstruction(LLFunction pFunction) : base(pFunction) { }
private LLSignedRightShiftInstruction(LLFunction pFunction) : base(pFunction) { }
private LLIntegerToPointerInstruction(LLFunction pFunction) : base(pFunction) { }
private LLGetElementPointerInstruction(LLFunction pFunction) : base(pFunction) { }
private LLSubtractInstruction(LLFunction pFunction) : base(pFunction) { }
private LLIntegerToFloatInstruction(LLFunction pFunction) : base(pFunction) { }
public static LLCommentInstruction Create(LLFunction pFunction, string pComment) { LLCommentInstruction instruction = new LLCommentInstruction(pFunction); instruction.mComment = pComment; return instruction; }
private LLLabelInstruction(LLFunction pFunction) : base(pFunction) { }
private LLAddInstruction(LLFunction pFunction) : base(pFunction) { }
private LLExtendInstruction(LLFunction pFunction) : base(pFunction) { }