private void InitSubroutine(HashSet <long> Callees) { List <ARegister> Params = new List <ARegister>(); void SetParams(long Inputs, ARegisterType BaseType) { for (int Bit = 0; Bit < 64; Bit++) { long Mask = 1L << Bit; if ((Inputs & Mask) != 0) { Params.Add(GetRegFromBit(Bit, BaseType)); } } } SetParams(LocalAlloc.GetIntInputs(Root), ARegisterType.Int); SetParams(LocalAlloc.GetVecInputs(Root), ARegisterType.Vector); DynamicMethod Mthd = new DynamicMethod(SubName, typeof(long), GetParamTypes(Params)); Generator = Mthd.GetILGenerator(); Subroutine = new ATranslatedSub(Mthd, Params, Callees); }
public TranslatedSub GetSubroutine(TranslationTier tier) { LocalAlloc = new LocalAlloc(_ilBlocks, _ilBlocks[0]); DynamicMethod method = new DynamicMethod(_subName, typeof(long), TranslatedSub.FixedArgTypes); Generator = method.GetILGenerator(); TranslatedSub subroutine = new TranslatedSub(method, tier); _locals = new Dictionary <Register, int>(); _localsCount = 0; new ILOpCodeLoadState(_ilBlocks[0]).Emit(this); foreach (ILBlock ilBlock in _ilBlocks) { ilBlock.Emit(this); } subroutine.PrepareMethod(); return(subroutine); }
private void InitSubroutine() { List <Register> Params = new List <Register>(); void SetParams(long inputs, RegisterType baseType) { for (int bit = 0; bit < 64; bit++) { long mask = 1L << bit; if ((inputs & mask) != 0) { Params.Add(GetRegFromBit(bit, baseType)); } } } SetParams(LocalAlloc.GetIntInputs(_root), RegisterType.Int); SetParams(LocalAlloc.GetVecInputs(_root), RegisterType.Vector); DynamicMethod mthd = new DynamicMethod(_subName, typeof(long), GetParamTypes(Params)); Generator = mthd.GetILGenerator(); _subroutine = new TranslatedSub(mthd, Params); }
public TranslatedSub GetSubroutine() { LocalAlloc = new LocalAlloc(_ilBlocks, _root); InitSubroutine(); InitLocals(); foreach (ILBlock ilBlock in _ilBlocks) { ilBlock.Emit(this); } return(_subroutine); }
public TranslatedSub GetSubroutine() { LocalAlloc = new LocalAlloc(_ilBlocks, _ilBlocks[0]); List <Register> subArgs = new List <Register>(); void SetArgs(long inputs, RegisterType baseType) { for (int bit = 0; bit < 64; bit++) { long mask = 1L << bit; if ((inputs & mask) != 0) { subArgs.Add(GetRegFromBit(bit, baseType)); } } } SetArgs(LocalAlloc.GetIntInputs(_ilBlocks[0]), RegisterType.Int); SetArgs(LocalAlloc.GetVecInputs(_ilBlocks[0]), RegisterType.Vector); DynamicMethod method = new DynamicMethod(_subName, typeof(long), GetArgumentTypes(subArgs)); Generator = method.GetILGenerator(); TranslatedSub subroutine = new TranslatedSub(method, subArgs); int argsStart = TranslatedSub.FixedArgTypes.Length; _locals = new Dictionary <Register, int>(); _localsCount = 0; for (int index = 0; index < subroutine.SubArgs.Count; index++) { Register reg = subroutine.SubArgs[index]; Generator.EmitLdarg(index + argsStart); Generator.EmitStloc(GetLocalIndex(reg)); } foreach (ILBlock ilBlock in _ilBlocks) { ilBlock.Emit(this); } return(subroutine); }