/// <summary> /// Writes functions to set the GMV types to scalar value. /// </summary> /// <param name="S"></param> /// <param name="cgd">Results go here. Also intermediate data for code generation. Also contains plugins and cog.</param> public static void WriteSetScalar(Specification S, G25.CG.Shared.CGdata cgd) { //StringBuilder declSB = cgd.m_declSB; StringBuilder defSB = (S.m_inlineSet) ? cgd.m_inlineDefSB : cgd.m_defSB; G25.GMV gmv = S.m_GMV; foreach (G25.FloatType FT in S.m_floatTypes) { string className = FT.GetMangledName(S, gmv.Name); string funcName = "set"; // do we inline this func? string inlineStr = G25.CG.Shared.Util.GetInlineString(S, S.m_inlineSet, " "); string funcDecl = inlineStr + "void " + className + "::" + funcName + "(" + FT.type + " val)"; defSB.Append(funcDecl); defSB.AppendLine(" {"); defSB.AppendLine("\t" + SET_GROUP_USAGE + "(" + (1 << gmv.GetGroupIdx(RefGA.BasisBlade.ONE)) + ");"); defSB.AppendLine("\tm_c[0] = val;"); if (S.m_reportUsage) { defSB.AppendLine("\tm_t = " + G25.CG.Shared.ReportUsage.GetSpecializedConstantName(S, FT.type) + ";"); } defSB.AppendLine("}"); } }
/// <summary> /// Writes functions to set the GMV types to scalar value. /// </summary> /// <param name="S"></param> /// <param name="cgd">Results go here. Also intermediate data for code generation. Also contains plugins and cog.</param> public static void WriteSetScalar(Specification S, G25.CG.Shared.CGdata cgd) { StringBuilder declSB = cgd.m_declSB; StringBuilder defSB = (S.m_inlineSet) ? cgd.m_inlineDefSB : cgd.m_defSB; G25.GMV gmv = S.m_GMV; foreach (G25.FloatType FT in S.m_floatTypes) { String typeName = FT.GetMangledName(S, gmv.Name); String funcName = typeName + "_setScalar"; // write comment declSB.AppendLine("/** Sets a " + typeName + " to a scalar value */"); // do we inline this func? String inlineStr = G25.CG.Shared.Util.GetInlineString(S, S.m_inlineSet, " "); String funcDecl = inlineStr + "void " + funcName + "(" + typeName + " *M, " + FT.type + " val)"; declSB.Append(funcDecl); declSB.AppendLine(";"); defSB.Append(funcDecl); defSB.AppendLine(" {"); defSB.AppendLine("\tM->gu = " + (1 << gmv.GetGroupIdx(RefGA.BasisBlade.ONE)) + ";"); defSB.AppendLine("\tM->c[0] = val;"); defSB.AppendLine("}"); } }
/// <summary> /// Writes functions to set the GMV types to scalar value. /// </summary> /// <param name="SB">Where the output goes.</param> /// <param name="S"></param> /// <param name="cgd">Results go here. Also intermediate data for code generation. Also contains plugins and cog.</param> /// <param name="FT"></param> public static void WriteSetScalar(StringBuilder SB, Specification S, G25.CG.Shared.CGdata cgd, FloatType FT) { int nbTabs = 1; new G25.CG.Shared.Comment("sets this to scalar value.").Write(SB, S, nbTabs); G25.GMV gmv = S.m_GMV; // string className = FT.GetMangledName(S, gmv.Name); string funcName = GetSetFuncName(S); string funcDecl = "\tpublic void " + funcName + "(" + FT.type + " val)"; SB.Append(funcDecl); SB.AppendLine(" {"); SB.AppendLine("\t\t" + GetAllocateGroupsString(S) + "(GroupBitmap.GROUP_" + gmv.GetGroupIdx(RefGA.BasisBlade.ONE) + ");"); SB.AppendLine("\t\tm_c[0][0] = val;"); if (S.m_reportUsage) { SB.AppendLine("\t\tm_t = " + G25.CG.CSJ.GMV.SMV_TYPE + "." + G25.CG.Shared.ReportUsage.GetSpecializedConstantName(S, FT.type) + ";"); } SB.AppendLine("\t}"); }