// TODO: Handle call expr? Still need this for reads of params etc. bool FakeDirectiveHandler::VisitDeclRefExpr(DeclRefExpr *S) { if (WaitingHeader && IsChild(S, WaitingHeader)) { return true; } FunctionDecl * F = dyn_cast<FunctionDecl>(S->getDecl()); if (F) { return true; } SourceManager &SM = FullDirectives->GetCI(S->getLocStart()).getSourceManager(); // TODO: Replace with presumed loc stuff SourceLocation Loc = tools::GetNearestValidLoc(S, SM, PM); if (FullDirectives->IsCompletelyPrivate(S, Loc)) { return true; } Expr * Var = getVar(S); Stmt * Base = getBase(S); Stmt * Parent = getParent(Base); Stmt * Top; if (!Parent || FullDirectives->IsLocDirectlyAfterPragma(Parent->getLocStart())) { Top = FullDirectives->GetHeader(S->getLocStart()); } else { Top = Parent; } vector<LocalStmtPair> WritePairs = GenerateWritePairs(Base, Parent, Top); WalkUpExpr(S, Var, WritePairs, true, string()); return true; }
ContactMaster::ContactMaster(const InputParameters & parameters) : DiracKernel(parameters), _component(getParam<unsigned int>("component")), _model(contactModel(getParam<std::string>("model"))), _formulation(contactFormulation(getParam<std::string>("formulation"))), _normalize_penalty(getParam<bool>("normalize_penalty")), _penetration_locator(getPenetrationLocator(getParam<BoundaryName>("boundary"), getParam<BoundaryName>("slave"), Utility::string_to_enum<Order>(getParam<MooseEnum>("order")))), _penalty(getParam<Real>("penalty")), _friction_coefficient(getParam<Real>("friction_coefficient")), _tension_release(getParam<Real>("tension_release")), _capture_tolerance(getParam<Real>("capture_tolerance")), _updateContactSet(true), _residual_copy(_sys.residualGhosted()), _x_var(isCoupled("disp_x") ? coupled("disp_x") : libMesh::invalid_uint), _y_var(isCoupled("disp_y") ? coupled("disp_y") : libMesh::invalid_uint), _z_var(isCoupled("disp_z") ? coupled("disp_z") : libMesh::invalid_uint), _mesh_dimension(_mesh.dimension()), _vars(_x_var, _y_var, _z_var), _nodal_area_var(getVar("nodal_area", 0)), _aux_system(_nodal_area_var->sys()), _aux_solution(_aux_system.currentSolution()) { if (parameters.isParamValid("tangential_tolerance")) _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance")); if (parameters.isParamValid("normal_smoothing_distance")) _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance")); if (parameters.isParamValid("normal_smoothing_method")) _penetration_locator.setNormalSmoothingMethod(parameters.get<std::string>("normal_smoothing_method")); if (_model == CM_GLUED || (_model == CM_COULOMB && _formulation == CF_DEFAULT)) _penetration_locator.setUpdate(false); if (_friction_coefficient < 0) mooseError("The friction coefficient must be nonnegative"); }
MechanicalContactConstraint::MechanicalContactConstraint(const std::string & name, InputParameters parameters) : NodeFaceConstraint(name, parameters), _component(getParam<unsigned int>("component")), _model(contactModel(getParam<std::string>("model"))), _formulation(contactFormulation(getParam<std::string>("formulation"))), _normalize_penalty(getParam<bool>("normalize_penalty")), _penalty(getParam<Real>("penalty")), _friction_coefficient(getParam<Real>("friction_coefficient")), _tension_release(getParam<Real>("tension_release")), _update_contact_set(true), _time_last_called(-std::numeric_limits<Real>::max()), _residual_copy(_sys.residualGhosted()), _x_var(isCoupled("disp_x") ? coupled("disp_x") : 99999), _y_var(isCoupled("disp_y") ? coupled("disp_y") : 99999), _z_var(isCoupled("disp_z") ? coupled("disp_z") : 99999), _mesh_dimension(_mesh.dimension()), _vars(_x_var, _y_var, _z_var), _nodal_area_var(getVar("nodal_area", 0)), _aux_system( _nodal_area_var->sys() ), _aux_solution( _aux_system.currentSolution() ) { _overwrite_slave_residual = false; if (parameters.isParamValid("tangential_tolerance")) _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance")); if (parameters.isParamValid("normal_smoothing_distance")) _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance")); if (parameters.isParamValid("normal_smoothing_method")) _penetration_locator.setNormalSmoothingMethod(parameters.get<std::string>("normal_smoothing_method")); if (_model == CM_GLUED || (_model == CM_COULOMB && _formulation == CF_DEFAULT)) _penetration_locator.setUpdate(false); if (_friction_coefficient < 0) mooseError("The friction coefficient must be nonnegative"); }
const VariableSecond & Coupleable::coupledSecondOlder(const std::string & var_name, unsigned int comp) { if (!isCoupled(var_name)) // Return default 0 return _default_second; coupledCallback(var_name, true); if (_nodal) mooseError("Nodal variables do not have second derivatives"); validateExecutionerType(var_name); MooseVariable * var = getVar(var_name, comp); if (_c_is_implicit) { if (!_coupleable_neighbor) return var->secondSlnOlder(); else return var->secondSlnOlderNeighbor(); } else mooseError("Older values not available for explicit schemes"); }
CrossTermBarrierFunctionBase::CrossTermBarrierFunctionBase(const InputParameters & parameters) : DerivativeMaterialInterface<Material>(parameters), _function_name(getParam<std::string>("function_name")), _g_order(getParam<MooseEnum>("g_order")), _W_ij(getParam<std::vector<Real>>("W_ij")), _num_eta(coupledComponents("etas")), _eta_names(_num_eta), _eta(_num_eta), _prop_g(declareProperty<Real>(_function_name)), _prop_dg(_num_eta), _prop_d2g(_num_eta) { // if Vector W_ij is not the correct size to fill the matrix give error if (_num_eta * _num_eta != _W_ij.size()) mooseError("Size of W_ij does not match (number of etas)^2. Supply W_ij of correct size."); // error out if the W_ij diagonal values are not zero for (unsigned int i = 0; i < _num_eta; ++i) if (_W_ij[_num_eta * i + i] != 0) mooseError("Set on-diagonal values of W_ij to zero."); // declare g derivative properties, fetch eta values for (unsigned int i = 0; i < _num_eta; ++i) { _prop_d2g[i].resize(_num_eta); _eta_names[i] = getVar("etas", i)->name(); } for (unsigned int i = 0; i < _num_eta; ++i) { _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, _eta_names[i]); _eta[i] = &coupledValue("etas", i); for (unsigned int j = i; j < _num_eta; ++j) { _prop_d2g[i][j] = _prop_d2g[j][i] = &declarePropertyDerivative<Real>(_function_name, _eta_names[i], _eta_names[j]); } } }
VariableValue & Coupleable::coupledNodalValueOlder(const std::string & var_name, unsigned int comp) { if (!isCoupled(var_name)) // Need to generate a "default value" filled VariableValue { VariableValue * value = _default_value[var_name]; if (value == NULL) { value = new VariableValue(_coupleable_max_qps, _coupleable_params.defaultCoupledValue(var_name)); _default_value[var_name] = value; } return *_default_value[var_name]; } validateExecutionerType(var_name); coupledCallback(var_name, true); MooseVariable * var = getVar(var_name, comp); if (_c_is_implicit) return var->nodalValueOlder(); else mooseError("Older values not available for explicit schemes"); }
vec2 FileArome::getLatLonVariable(std::string iVar) const { NcVar* var = getVar(iVar); float MV = getMissingValue(var); long count[2] = {getNumLat(), getNumLon()}; float* values = new float[getNumLon()*getNumLat()]; var->get(values, count); vec2 grid; grid.resize(getNumLat()); for(int i = 0; i < getNumLat(); i++) { grid[i].resize(getNumLon()); for(int j = 0; j < getNumLon(); j++) { int index = i*getNumLon() + j; float value = values[index]; if(values[index] == MV) value = Util::MV; grid[i][j] = value; assert(index < getNumLon()*getNumLat()); } } delete[] values; return grid; }
VariableValue & Coupleable::coupledValueOld(const std::string & var_name, unsigned int comp) { if (!isCoupled(var_name)) // Need to generate a "default value" filled VariableValue { VariableValue * value = _default_value[var_name]; if (value == NULL) { value = new VariableValue(_coupleable_max_qps, _coupleable_params.defaultCoupledValue(var_name)); _default_value[var_name] = value; } return *_default_value[var_name]; } validateExecutionerType(var_name); coupledCallback(var_name, true); MooseVariable * var = getVar(var_name, comp); if (_nodal) return (_c_is_implicit) ? var->nodalSlnOld() : var->nodalSlnOlder(); else return (_c_is_implicit) ? var->slnOld() : var->slnOlder(); }
void FileNetcdf::writeTimes() { std::vector<double> times = getTimes(); if(times.size() != getNumTime()) { std::stringstream ss; ss << "The times specified for NetCDF file '" << getFilename() << "' has " << times.size() << " elements, but the time dimension is " << getNumTime() << ". Putting missing values."; Util::warning(ss.str()); times = std::vector<double>(getNumTime(), Util::MV); } // Convert missing for(int i = 0; i < times.size(); i++) { if(!Util::isValid(times[i])) times[i] = NC_FILL_FLOAT; } if(!hasVar("time")) { int dTime = getDim("time"); int id; int status = ncredef(mFile); handleNetcdfError(status, "could not put into define mode"); status = nc_def_var(mFile, "time", NC_DOUBLE, 1, &dTime, &id); handleNetcdfError(status, "creating time variable"); status = ncendef(mFile); handleNetcdfError(status, "could not put into data mode"); } int vTime = getVar("time"); double timesArr[getNumTime()]; for(int t = 0; t < getNumTime(); t++) { timesArr[t] = times[t]; } int status = nc_put_var_double(mFile, vTime, timesArr); handleNetcdfError(status, "could not write times"); setAttribute(vTime, "long_name", "time"); setAttribute(vTime, "standard_name", "time"); setAttribute(vTime, "units", "seconds since 1970-01-01 00:00:00 +00:00"); }
ParsedAux::ParsedAux(const InputParameters & parameters) : AuxKernel(parameters), FunctionParserUtils(parameters), _function(getParam<std::string>("function")), _nargs(coupledComponents("args")), _args(_nargs) { // build variables argument std::string variables; for (unsigned int i = 0; i < _nargs; ++i) { variables += (i == 0 ? "" : ",") + getVar("args", i)->name(); _args[i] = &coupledValue("args", i); } // base function object _func_F = new ADFunction(); // add the constant expressions addFParserConstants(_func_F, getParam<std::vector<std::string> >("constant_names"), getParam<std::vector<std::string> >("constant_expressions")); // parse function if (_func_F->Parse(_function, variables) >= 0) mooseError("Invalid function\n" << _function << "\nin ParsedAux " << name() << ".\n" << _func_F->ErrorMsg()); // optimize if (!_disable_fpoptimizer) _func_F->Optimize(); // just-in-time compile if (_enable_jit) _func_F->JITCompile(); // reserve storage for parameter passing bufefr _func_params.resize(_nargs); }
static QVariantList parseFor(const QString &s, QString *iterVarName, const QVariantMap &context, QString *error) { // for now all we support is "varname in map" int at = s.indexOf(" in "); if(at == -1) { *error = "\"for\" directive must be of the form: \"for variable in container\""; return QVariantList(); } *iterVarName = s.mid(0, at); QString containerName = s.mid(at + 4); QVariant container = getVar(containerName, context); if(container.type() != QVariant::List) { *error = "\"for\" container must be a list"; return QVariantList(); } return container.toList(); }
const DenseVector<Number> & Coupleable::coupledSolutionDoFsOlder(const std::string & var_name, unsigned int comp) { // default coupling is not available for elemental solutions if (!isCoupled(var_name)) mooseError("invalid variable name for coupledSolutionDoFsOlder"); if (_nodal) mooseError("nodal objects should not call coupledSolutionDoFsOlder"); validateExecutionerType(var_name); coupledCallback(var_name, true); MooseVariable * var = getVar(var_name, comp); if (_c_is_implicit) { if (!_coupleable_neighbor) return var->solutionDoFsOlder(); else return var->solutionDoFsOlderNeighbor(); } else mooseError("Older values not available for explicit schemes"); }
void Diff::perform() { if (files.count() != 2) { QOSystem::QBox("Invalid number of selected files"); return; } QSubProcess proc; proc.setWorkDirectory(files[0].path); proc.setBlock(false); QString comp; getVar("COMPARE", comp); QPrInfo info; if (!proc.start( QStringList() << comp << files[0].fullname << files[1].fullname)) { QOSystem::QBox("Could not start compare program"); QOSystem::QBox( info.out + info.err); return; } }
const VariableValue & Coupleable::coupledDotDu(const std::string & var_name, unsigned int comp) { if (!isCoupled(var_name)) // Return default 0 return _default_value_zero; MooseVariable * var = getVar(var_name, comp); if (!_coupleable_neighbor) { if (_nodal) return var->nodalSlnDuDotDu(); else return var->duDotDu(); } else { if (_nodal) return var->nodalSlnDuDotDu(); else return var->duDotDu(); } }
void FlowBasedGlobalConstraint::findProjection(Graph &graph, StoreCost &cost, int varindex, map<Value, Cost> &delta) { //if (ToulBar2::GCLevel == LC_NC) return; pair<Cost, bool> result; delta.clear(); EnumeratedVariable* x = (EnumeratedVariable*)getVar(varindex); for (EnumeratedVariable::iterator j = x->begin(); j != x->end(); ++j) { pair<int,int> edge = mapto(varindex, *j); Cost tmp = cost; //vector<Cost> weight = graph.getWeight(edge.first, edge.second); //if (!weight.empty()) { if (graph.edgeExist(edge.first, edge.second)) { if (zeroEdges[edge.first][edge.second]) { //cout << "good\n"; tmp = cost; } else { vector<pair<int, int> > edges; result = graph.augment(edge.second, edge.first, false, edges); /*if (!result.second) { printf("error! no shortest path\n"); exit(0); }*/ //tmp = cost+result.first+weight[0]; tmp = cost+result.first + graph.getMinWeight(edge.first, edge.second); zeroEdges[edge.first][edge.second] = true; for (vector<pair<int,int> >::iterator i = edges.begin();i != edges.end();i++) { zeroEdges[i->first][i->second] = true; } } } assert(tmp >= 0); delta[*j] = tmp; } }
void Edit::perform() { QSubProcess proc; proc.setWorkDirectory(location); proc.setBlock(false); proc.setShell(true); QString editor; if (!getVar("EDITOR",editor)) { QOSystem::QBox("not editor set"); } // editor = "gvim.exe"; QStringList items; for(int i=0; i<files.count(); i++) { items << files[i].fullname; } if (!proc.start(QStringList() <<editor<<items)) { QOSystem::QBox("Could not start process"); } }
void putInVar(void * A, short t) { struct Var * N; N = (struct Var*) A; switch(t) { case VT_B : setCodeVar(N, t, VIDE); N->b = getBool(); break; case VT_C : setCodeVar(N, t, getString()); break; case VT_N : setCodeVar(N, t, getVar()); break; case VT_L : case VT_F : setCodeVar(N, t, FCT_INST); break; default : setCodeVar(N, VT_I, VIDE); break; } }
// handles lookup by exact name or dot-notation for children static QVariant getVar(const QString &s, const QVariantMap &context) { int at = s.indexOf('.'); if(at != -1) { QString parent = s.mid(0, at); QString member = s.mid(at + 1); if(parent.isEmpty() || !context.contains(parent)) return QVariant(); QVariant subContext = context[parent]; if(subContext.type() != QVariant::Map) return QVariant(); return getVar(member, subContext.toMap()); } else { if(!context.contains(s)) return QVariant(); return context[s]; } }
void MohawkEngine_Riven::updateZipMode() { // Check if a zip mode hotspot is enabled by checking the name/id against the ZIPS records. for (uint32 i = 0; i < _hotspotCount; i++) { if (_hotspots[i].zipModeHotspot) { if (*getVar("azip") != 0) { // Check if a zip mode hotspot is enabled by checking the name/id against the ZIPS records. Common::String hotspotName = getName(HotspotNames, _hotspots[i].name_resource); bool foundMatch = false; if (!hotspotName.empty()) for (uint16 j = 0; j < _zipModeData.size(); j++) if (_zipModeData[j].name == hotspotName) { foundMatch = true; break; } _hotspots[i].enabled = foundMatch; } else // Disable the hotspot if zip mode is disabled _hotspots[i].enabled = false; } } }
SwitchingFunctionPenalty::SwitchingFunctionPenalty(const std::string & name, InputParameters parameters) : DerivativeMaterialInterface<Kernel>(name, parameters), _h_names(getParam<std::vector<MaterialPropertyName> >("h_names")), _num_h(_h_names.size()), _h(_num_h), _dh(_num_h), _penalty(getParam<Real>("penalty")), _number_of_nl_variables(_fe_problem.getNonlinearSystem().nVariables()), _j_eta(_number_of_nl_variables, -1), _a(-1) { // parameter check. We need exactly one eta per h if (_num_h != coupledComponents("etas")) mooseError("Need to pass in as many h_names as etas in SwitchingFunctionPenalty kernel " << name); // fetch switching functions (for the residual) and h derivatives (for the Jacobian) for (unsigned int i = 0; i < _num_h; ++i) { _h[i] = &getMaterialPropertyByName<Real>(_h_names[i]); _dh[i] = &getMaterialPropertyDerivative<Real>(_h_names[i], getVar("etas", i)->name()); // generate the lookup table from j_var -> eta index unsigned int num = coupled("etas", i); if (num < _number_of_nl_variables) _j_eta[num] = i; // figure out which variable this kernel is acting on if (num == _var.number()) _a = i; } if (_a < 0) mooseError("Kernel variable must be listed in etas for SwitchingFunctionPenalty kernel " << name); _d2h = &getMaterialPropertyDerivative<Real>(_h_names[_a], _var.name(), _var.name()); }
void Verotrace::perform() { if (files.count() != 1) { QOSystem::QBox("select Only 1 file"); return; } VTest test; test.read(files[0].fullname); QSet<QString> reqs = test.get_test_reqs(); QStringList rrr = reqs.toList(); QSubProcess proc; proc.setWorkDirectory(location); proc.setBlock(false); QString dbname; getVar("db_name",dbname); QStringList program; program << "VeroTrace.exe"<<"/SERVER=192.168.0.203"<<"/DATABASE="+dbname<<"/PROPSHEET=IMPREQPAGE"<<"/ITEM="+rrr[0]; // proc.start( QStringList() << "verotrace.exe"<<rrr[0]); proc.start( program); }
const VariableValue & Coupleable::coupledValue(const std::string & var_name, unsigned int comp) { if (!isCoupled(var_name)) return *getDefaultValue(var_name); coupledCallback(var_name, false); MooseVariable * var = getVar(var_name, comp); if (!_coupleable_neighbor) { if (_nodal) return (_c_is_implicit) ? var->nodalSln() : var->nodalSlnOld(); else return (_c_is_implicit) ? var->sln() : var->slnOld(); } else { if (_nodal) return (_c_is_implicit) ? var->nodalSlnNeighbor() : var->nodalSlnOldNeighbor(); else return (_c_is_implicit) ? var->slnNeighbor() : var->slnOldNeighbor(); } }
GluedContactConstraint::GluedContactConstraint(const std::string & name, InputParameters parameters) : SparsityBasedContactConstraint(name, parameters), _component(getParam<unsigned int>("component")), _model(contactModel(getParam<std::string>("model"))), _formulation(contactFormulation(getParam<std::string>("formulation"))), _penalty(getParam<Real>("penalty")), _friction_coefficient(getParam<Real>("friction_coefficient")), _tension_release(getParam<Real>("tension_release")), _updateContactSet(true), _time_last_called(-std::numeric_limits<Real>::max()), _residual_copy(_sys.residualGhosted()), _x_var(isCoupled("disp_x") ? coupled("disp_x") : 99999), _y_var(isCoupled("disp_y") ? coupled("disp_y") : 99999), _z_var(isCoupled("disp_z") ? coupled("disp_z") : 99999), _vars(_x_var, _y_var, _z_var), _nodal_area_var(getVar("nodal_area", 0)), _aux_system( _nodal_area_var->sys() ), _aux_solution( _aux_system.currentSolution() ) { // _overwrite_slave_residual = false; if (parameters.isParamValid("tangential_tolerance")) { _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance")); } if (parameters.isParamValid("normal_smoothing_distance")) { _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance")); } if (parameters.isParamValid("normal_smoothing_method")) { _penetration_locator.setNormalSmoothingMethod(parameters.get<std::string>("normal_smoothing_method")); } _penetration_locator.setUpdate(false); }
VecX<Vec3> getVecVertex(std::string a) { VecX<Vec3> val(listVertex.size()); shared_ptr<Var > u, v, w; if (a == "u") { u = getVar("u"); v = getVar("v"); w = getVar("w"); } else { u = getVar(a+"x"); v = getVar(a+"y"); w = getVar(a+"z"); } if (!u || !v || !w) { cout << "Vector not found! " << a << endl; exit(-1); } for (auto i = 0; i<listVertex.size(); ++i) { val[i][0] = (u->loc==1) ? u->get(i): listVertex[i]->evalPhi(u); //.eval(u); val[i][1] = (v->loc==1) ? v->get(i): listVertex[i]->evalPhi(v); //.eval(v); val[i][2] = (w->loc==1) ? w->get(i): listVertex[i]->evalPhi(w);//.eval(w); } return val; }
Vec3 interpVec(shared_ptr<Var> &phi, Vec3 x, int_8 i0=0) { // cout << " in " << endl; if (!phi->isVec) {cout << "Nonvector interpolation" << endl; return Vec3(0); } if (i0 < 0 || i0 >= listVertex.size()) i0=0; i0 = searchVertexbyCoords(x, i0); if (i0 < 0) return 0; //BC shared_ptr<Var > u, v, w; if (phi->name == "u") { u = getVar("u"); v = getVar("v"); w = getVar("w"); } else { auto a = phi->name; a.pop_back(); u = getVar(a+"x"); v = getVar(a+"y"); w = getVar(a+"z"); } auto val0 = listVertex[i0]->evalPhi(u, &x); auto val1 = listVertex[i0]->evalPhi(v, &x); auto val2 = listVertex[i0]->evalPhi(w, &x); // cout << " out "<< endl; return Vec3(val0, val1, val2); }
void Pipeline::use(void) { THREADCHECK(); glUseProgram(this->program); getVar("in_Vertex", &in_Vertex, 0); getVar("in_Normal", &in_Normal, 0); getVar("in_Color", &in_Color, 0); getVar("in_TexCoord", &in_TexCoord, 0); getVar("u_Projection", &state.u_Projection, 1); getVar("u_ModelView", &state.u_ModelView, 1); getVar("u_NormalMat", &state.u_NormalMat, 1); // getVar("u_LightPos", &state.u_LightPos, 1); getVar("u_LightCol", &state.u_LightCol, 1); getVar("u_LightDir", &state.u_LightDir, 1); getVar("u_AmbientLight", &state.u_AmbientLight, 1); getVar("u_MatColor", &state.u_MatColor, 1); getVar("u_Texture", &state.u_Texture, 1); getVar("u_TextureType", &state.u_TextureType, 1); getVar("u_Fog.color", &state.u_FogColor, 1); getVar("u_Fog.start", &state.u_FogStart, 1); getVar("u_Fog.end", &state.u_FogEnd, 1); getVar("u_Fog.density", &state.u_FogDensity, 1); getVar("u_Col1", &state.u_Col1, 1); getVar("u_Col2", &state.u_Col2, 1); }
//将加、减、乘法的三地址码语句转化为mips(已支持浮点数) void genCAL(Quad* quad, VariableMap* map) { fprintf(out, "\t# calculation\n"); if (strcmp(quad->addr1.contents.name, "sp")==0) { if (quad->op == add) fprintf(out,"\taddi, $sp, $sp, %d\n", quad->addr2.contents.intVal); if (quad->op == sub) fprintf(out,"\taddi, $sp, $sp, -%d\n", quad->addr2.contents.intVal); return; } type t1 = UNDEFINED, t2 = UNDEFINED, t3 = UNDEFINED; if (quad->addr3.kind == String && getVar(quad->addr3.contents.name, map)) { addStar(quad->addr3.contents.name); quad->addr3.kind = Val; } if (quad->addr2.kind == String && getVar(quad->addr2.contents.name, map)) { quad->addr2.kind = Val; addStar(quad->addr2.contents.name); } if (quad->addr1.kind == String && getVar(quad->addr1.contents.name, map)) { quad->addr1.kind = Val; addStar(quad->addr1.contents.name); } if (quad->addr3.kind == String) { //关于地址的计算 if (quad->addr1.kind == IntConst) fprintf(out, "\tli $t1, %d\n", quad->addr1.contents.intVal); if (quad->addr1.kind == String) fprintf(out, "\tlw $t1, %s\n", quad->addr1.contents.name); if (quad->addr2.kind == IntConst) fprintf(out, "\tli $t2, %d\n", quad->addr2.contents.intVal); if (quad->addr2.kind == String) fprintf(out, "\tlw $t2, %s\n", quad->addr2.contents.name); if (quad->op == add) fprintf(out, "\tadd $t1, $t1, $t2\n"); if (quad->op == sub) fprintf(out, "\tsub $t1, $t1, $t2\n"); fprintf(out, "\tsw $t1, %s\n", quad->addr3.contents.name); } if (quad->addr3.kind == Val) { //关于值的计算 t3 = getType(quad->addr3.contents.name+1, map); if (t3 == INTEGER) { if (quad->addr1.kind == IntConst) fprintf(out, "\tli $t1, %d\n", quad->addr1.contents.intVal); if (quad->addr1.kind == Val) { fprintf(out, "\tlw $t3, %s\n", quad->addr1.contents.name+1); fprintf(out, "\tlw $t1, 0($t3)\n"); } if (quad->addr2.kind == IntConst) fprintf(out, "\tli $t2, %d\n", quad->addr2.contents.intVal); if (quad->addr2.kind == Val) { fprintf(out, "\tlw $t3, %s\n", quad->addr2.contents.name+1); fprintf(out, "\tlw $t2, 0($t3)\n"); } if (quad->op == add) fprintf(out, "\tadd $t1, $t1, $t2\n"); if (quad->op == sub) fprintf(out, "\tsub $t1, $t1, $t2\n"); if (quad->op == mul) fprintf(out, "\tmul $t1, $t1, $t2\n"); if (quad->op == dvd) fprintf(out, "\tdiv $t1, $t2\n"); if (quad->op != dvd) { fprintf(out, "\tlw $t3, %s\n", quad->addr3.contents.name+1); fprintf(out, "\tsw $t1, 0($t3)\n"); } if (quad->op == dvd) { fprintf(out, "\tlw $t3, %s\n", quad->addr3.contents.name+1); fprintf(out, "\tmflo $t2\n"); fprintf(out, "\tsw $t2 0($t3)\n"); } } if (t3 == FLOAT) { if (quad->addr1.kind == IntConst) fprintf(out, "\tli.s $f1, %d.0\n", quad->addr1.contents.intVal); if (quad->addr1.kind == FloatConst) fprintf(out, "\tli.s $f1, %f\n", quad->addr1.contents.floatVal); if (quad->addr1.kind == Val) { t1 = getType(quad->addr1.contents.name+1, map); fprintf(out, "\tlw $t3, %s\n", quad->addr1.contents.name+1); if (t1 == FLOAT) fprintf(out, "\tl.s $f1, 0($t3)\n"); if (t1 == INTEGER) { fprintf(out, "lw $t1, 0($t3)\n"); fprintf(out, "\tmtc1 $t1, $f1\n"); fprintf(out, "\tcvt.s.w $f1, $f1\n"); } } if (quad->addr2.kind == IntConst) fprintf(out, "\tli.s $f2, %d.0\n", quad->addr2.contents.intVal); if (quad->addr2.kind == FloatConst) fprintf(out, "\tli.s $f2, %f\n", quad->addr2.contents.floatVal); if (quad->addr2.kind == Val) { //要强制转换类型 t2 = getType(quad->addr2.contents.name+1, map); fprintf(out, "\tlw $t3, %s\n", quad->addr2.contents.name+1); if (t2 == FLOAT) fprintf(out, "\tl.s $f2, 0($t3)\n"); if (t2 == INTEGER) { fprintf(out, "\tlw $t2, 0($t3)\n"); fprintf(out, "\tmtc1 $t2, $f2\n"); fprintf(out, "\tcvt.s.w $f2, $f2\n"); } } if (quad->op == add) fprintf(out, "\tadd.s $f3, $f1, $f2\n"); if (quad->op == sub) fprintf(out, "\tsub.s $f3, $f1, $f2\n"); if (quad->op == mul) fprintf(out, "\tmul.s $f3, $f1, $f2\n"); if (quad->op == dvd) fprintf(out, "\tdiv.s $f3, $f1, $f2\n"); fprintf(out, "\tlw $t3, %s\n", quad->addr3.contents.name+1); fprintf(out, "\ts.s $f3, 0($t3)\n"); } if (t3 == DOUBLE) { if (quad->addr1.kind == IntConst) fprintf(out, "\tli.d $f0, %d.0\n", quad->addr1.contents.intVal); if (quad->addr1.kind == FloatConst) fprintf(out, "\tli.d $f0, %f\n", quad->addr1.contents.floatVal); if (quad->addr1.kind == Val) { t1 = getType(quad->addr1.contents.name+1, map); fprintf(out, "\tlw $t3, %s\n", quad->addr1.contents.name+1); if (t1 == INTEGER) { fprintf(out, "\tlw $t1, 0($t3)\n"); fprintf(out, "\tmtc1 $t1, $f0\n"); fprintf(out, "\tcvt.s.w $f0, $f0\n"); fprintf(out, "\tcvt.d.s $f0, $f0\n"); } if (t1 == FLOAT) { fprintf(out, "\tl.s $f0, 0($t3)\n"); fprintf(out, "\tcvt.d.s $f0, $f0\n"); } if (t1 == DOUBLE) fprintf(out, "\tl.d $f0, 0($t3)\n"); } if (quad->addr2.kind == IntConst) fprintf(out, "\tli.d $f2, %d.0\n", quad->addr2.contents.intVal); if (quad->addr2.kind == FloatConst) fprintf(out, "\tli.d $f2, %f\n", quad->addr2.contents.floatVal); if (quad->addr2.kind == Val) { t2 = getType(quad->addr2.contents.name+1, map); fprintf(out, "\tlw $t3, %s\n", quad->addr2.contents.name+1); if (t2 == INTEGER) { fprintf(out, "\tlw $t2, 0($t3)\n"); fprintf(out, "\tmtc1 $t2, $f2\n"); fprintf(out, "\tcvt.s.w $f2, $f2\n"); fprintf(out, "\tcvt.d.s $f2, $f2\n"); } if (t2 == FLOAT) { fprintf(out, "\tl.s $f2, 0($t3)\n"); fprintf(out, "\tcvt.d.s $f2, $f2\n"); } if (t2 == DOUBLE) fprintf(out, "\tl.d $f2, 0($t3)\n"); } if (quad->op == add) fprintf(out, "\tadd.d $f4, $f0, $f2\n"); if (quad->op == sub) fprintf(out, "\tsub.d $f4, $f0, $f2\n"); if (quad->op == mul) fprintf(out, "\tmul.d $f4, $f0, $f2\n"); if (quad->op == dvd) fprintf(out, "\tdiv.d $f4, $f0, $f2\n"); fprintf(out, "\tlw $t3, %s\n", quad->addr3.contents.name+1); fprintf(out, "\ts.d $f4, 0($t3)\n"); } } if (quad->addr3.kind == Val && getVar(quad->addr3.contents.name, map)) { removeStar(quad->addr3.contents.name); quad->addr3.kind = String; } if (quad->addr2.kind == Val && getVar(quad->addr2.contents.name, map)) { quad->addr2.kind = String; removeStar(quad->addr2.contents.name); } if (quad->addr1.kind == Val && getVar(quad->addr1.contents.name, map)) { quad->addr1.kind = String; removeStar(quad->addr1.contents.name); } }
DerivativeMultiPhaseBase::DerivativeMultiPhaseBase(const InputParameters & parameters) : DerivativeFunctionMaterialBase(parameters), _eta_index(_nargs, -1), _num_etas(coupledComponents("etas")), _eta_names(_num_etas), _eta_vars(_num_etas), _fi_names(getParam<std::vector<MaterialPropertyName> >("fi_names")), _num_fi(_fi_names.size()), _prop_Fi(_num_fi), _prop_dFi(_num_fi), _prop_d2Fi(_num_fi), _prop_d3Fi(_num_fi), _hi_names(getParam<std::vector<MaterialPropertyName> >("hi_names")), _num_hi(_hi_names.size()), _hi(_num_hi), _g(getMaterialProperty<Real>("g")), _dg(_num_etas), _d2g(_num_etas), _d3g(_num_etas), _W(getParam<Real>("W")) { // check passed in parameter vectors if (_num_fi != _num_hi) mooseError("Need to pass in as many hi_names as fi_names in DerivativeMultiPhaseBase " << name()); // get order parameter names and libmesh variable names, set barrier function derivatives for (unsigned int i = 0; i < _num_etas; ++i) { _eta_names[i] = getVar("etas", i)->name(); _eta_vars[i] = coupled("etas", i); // for each coupled variable we need to know if it was coupled through "etas" // and - if so - which coupled component of "etas" it comes from _eta_index[argIndex(_eta_vars[i])] = i; // barrier function derivatives _dg[i] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i]); _d2g[i].resize(_num_etas); if (_third_derivatives) _d3g[i].resize(_num_etas); for (unsigned int j = 0; j < _num_etas; ++j) { _d2g[i][j] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i], _eta_names[j]); if (_third_derivatives) { _d3g[i][j].resize(_num_etas); for (unsigned int k = 0; k < _num_etas; ++k) _d3g[i][j][k] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i], _eta_names[j], _eta_names[k]); } } } // reserve space and set phase material properties for (unsigned int n = 0; n < _num_fi; ++n) { // get phase free energy _prop_Fi[n] = &getMaterialPropertyByName<Real>(_fi_names[n]); _prop_dFi[n].resize(_nargs); _prop_d2Fi[n].resize(_nargs); _prop_d3Fi[n].resize(_nargs); // get switching function _hi[n] = &getMaterialPropertyByName<Real>(_hi_names[n]); for (unsigned int i = 0; i < _nargs; ++i) { _prop_dFi[n][i] = &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i]); _prop_d2Fi[n][i].resize(_nargs); if (_third_derivatives) _prop_d3Fi[n][i].resize(_nargs); for (unsigned int j = 0; j < _nargs; ++j) { _prop_d2Fi[n][i][j] = &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i], _arg_names[j]); if (_third_derivatives) { _prop_d3Fi[n][i][j].resize(_nargs); for (unsigned int k = 0; k < _nargs; ++k) _prop_d3Fi[n][i][j][k] = &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i], _arg_names[j], _arg_names[k]); } } } } }
/* * The generic solution to the multiplex operators is to translate * them to a MAL loop. * The call optimizer.multiplex(MOD,FCN,A1,...An) introduces the following code * structure: * * @verbatim * A1rev:=bat.reverse(A1); * resB:= bat.new(A1); * barrier (h,t):= iterator.new(A1); * $1:= algebra.fetch(A1,h); * $2:= A2; # in case of constant? * ... * cr:= MOD.FCN($1,...,$n); * y:=algebra.fetch(A1rev,h); * bat.insert(resB,y,cr); * redo (h,t):= iterator.next(A1); * end h; * @end verbatim * * The algorithm consists of two phases: phase one deals with * collecting the relevant information, phase two is the actual * code construction. */ static str OPTexpandMultiplex(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { int i = 2, resB, iter = 0, cr; int hvar, tvar; int x, y; str mod, fcn; int *alias; InstrPtr q; int ht, tt; (void) cntxt; (void) stk; ht = getHeadType(getArgType(mb, pci, 0)); if (ht != TYPE_oid) throw(MAL, "optimizer.multiplex", "Target head type is missing"); tt = getTailType(getArgType(mb, pci, 0)); if (tt== TYPE_any) throw(MAL, "optimizer.multiplex", "Target tail type is missing"); if (isAnyExpression(getArgType(mb, pci, 0))) throw(MAL, "optimizer.multiplex", "Target type is missing"); mod = VALget(&getVar(mb, getArg(pci, 1))->value); mod = putName(mod,strlen(mod)); fcn = VALget(&getVar(mb, getArg(pci, 2))->value); fcn = putName(fcn,strlen(fcn)); /* search the iterator bat */ for (i = 3; i < pci->argc; i++) if (isaBatType(getArgType(mb, pci, i))) { iter = getArg(pci, i); if (getHeadType(getVarType(mb,iter)) != TYPE_oid) throw(MAL, "optimizer.multiplex", "Iterator BAT is not OID-headed"); break; } if( i == pci->argc) throw(MAL, "optimizer.multiplex", "Iterator BAT type is missing"); OPTDEBUGmultiplex { mnstr_printf(cntxt->fdout,"#calling the optimize multiplex script routine\n"); printFunction(cntxt->fdout,mb, 0, LIST_MAL_ALL ); mnstr_printf(cntxt->fdout,"#multiplex against operator %d %s\n",iter, getTypeName(getVarType(mb,iter))); printInstruction(cntxt->fdout,mb, 0, pci,LIST_MAL_ALL); } /* * Beware, the operator constant (arg=1) is passed along as well, * because in the end we issue a recursive function call that should * find the actual arguments at the proper place of the callee. */ alias= (int*) GDKmalloc(sizeof(int) * pci->maxarg); if (alias == NULL) return NULL; /* x := bat.reverse(A1); */ x = newTmpVariable(mb, newBatType(getTailType(getVarType(mb,iter)), getHeadType(getVarType(mb,iter)))); q = newFcnCall(mb, batRef, reverseRef); getArg(q, 0) = x; q = pushArgument(mb, q, iter); /* resB := new(refBat) */ q = newFcnCall(mb, batRef, newRef); resB = getArg(q, 0); setVarType(mb, getArg(q, 0), newBatType(ht, tt)); q = pushType(mb, q, ht); q = pushType(mb, q, tt); /* barrier (h,r) := iterator.new(refBat); */ q = newFcnCall(mb, iteratorRef, newRef); q->barrier = BARRIERsymbol; hvar = newTmpVariable(mb, TYPE_any); getArg(q,0) = hvar; tvar = newTmpVariable(mb, TYPE_any); q= pushReturn(mb, q, tvar); (void) pushArgument(mb,q,iter); /* $1:= algebra.fetch(Ai,h) or constant */ alias[i] = tvar; for (i++; i < pci->argc; i++) if (isaBatType(getArgType(mb, pci, i))) { q = newFcnCall(mb, algebraRef, "fetch"); alias[i] = newTmpVariable(mb, getTailType(getArgType(mb, pci, i))); getArg(q, 0) = alias[i]; q= pushArgument(mb, q, getArg(pci, i)); (void) pushArgument(mb, q, hvar); } /* cr:= mod.CMD($1,...,$n); */ q = newFcnCall(mb, mod, fcn); cr = getArg(q, 0) = newTmpVariable(mb, TYPE_any); for (i = 3; i < pci->argc; i++) if (isaBatType(getArgType(mb, pci, i))) { q= pushArgument(mb, q, alias[i]); } else { q = pushArgument(mb, q, getArg(pci, i)); } /* y := algebra.fetch(x,h); */ y = newTmpVariable(mb, getHeadType(getVarType(mb,iter))); q = newFcnCall(mb, algebraRef, "fetch"); getArg(q, 0) = y; q = pushArgument(mb, q, x); q = pushArgument(mb, q, hvar); /* insert(resB,h,cr); not append(resB, cr); the head type (oid) may dynamically change */ q = newFcnCall(mb, batRef, insertRef); q= pushArgument(mb, q, resB); q= pushArgument(mb, q, y); (void) pushArgument(mb, q, cr); /* redo (h,r):= iterator.next(refBat); */ q = newFcnCall(mb, iteratorRef, nextRef); q->barrier = REDOsymbol; getArg(q,0) = hvar; q= pushReturn(mb, q, tvar); (void) pushArgument(mb,q,iter); q = newAssignment(mb); q->barrier = EXITsymbol; getArg(q,0) = hvar; (void) pushReturn(mb, q, tvar); q = newAssignment(mb); getArg(q, 0) = getArg(pci, 0); (void) pushArgument(mb, q, resB); GDKfree(alias); return MAL_SUCCEED; }
//生成比较的语句,结果只能为INTEGER? void genCompare(Quad* quad, VariableMap* map) { fprintf(out, "\t# compare\n"); if (quad->addr3.kind == String && getVar(quad->addr3.contents.name, map)) { addStar(quad->addr3.contents.name); quad->addr3.kind = Val; } if (quad->addr2.kind == String && getVar(quad->addr2.contents.name, map)) { quad->addr2.kind = Val; addStar(quad->addr2.contents.name); } if (quad->addr1.kind == String && getVar(quad->addr1.contents.name, map)) { quad->addr1.kind = Val; addStar(quad->addr1.contents.name); } type t1 = UNDEFINED, t2 = UNDEFINED, t=UNDEFINED; if (quad->addr1.kind==Val) t1 = getType(quad->addr1.contents.name+1, map); else switch (quad->addr1.kind) { case IntConst: t1 = INTEGER; break; case FloatConst: t1 = FLOAT; break; default: break; } if (quad->addr2.kind==Val) t2 = getType(quad->addr2.contents.name+1, map); else switch (quad->addr2.kind) { case IntConst: t2 = INTEGER; break; case FloatConst: t2 = FLOAT; break; default: break; } if (t1==DOUBLE || t2 == DOUBLE) t=DOUBLE; else if (t1==FLOAT || t2 == FLOAT) t = FLOAT; else if (t1==INTEGER && t2==INTEGER) t = INTEGER; if (t == INTEGER) { //如果 a = b op c的b和c都是整形 if (quad->addr1.kind == IntConst) fprintf(out, "\tli $t1, %d\n", quad->addr1.contents.intVal); if (quad->addr1.kind == Val) { fprintf(out, "\tlw $t3, %s\n", quad->addr1.contents.name+1); fprintf(out, "\tlw $t1, 0($t3)\n"); } if (quad->addr2.kind == IntConst) fprintf(out, "\tli $t2, %d\n", quad->addr2.contents.intVal); if (quad->addr2.kind == Val) { fprintf(out, "\tlw $t3, %s\n", quad->addr2.contents.name+1); fprintf(out, "\tlw $t2, 0($t3)\n"); } if (quad->op == sm) fprintf(out, "\tslt $t3, $t1, $t2\n"); //如果c=a<b且a确实小于b则t0=1否则t0=0 if (quad->op == gt) fprintf(out, "\tslt $t3, $t2, $t1\n"); if (quad->op == ne) { fprintf(out, "\tslt $t4, $t1, $t2\n"); fprintf(out, "\tslt $t5, $t2, $t1\n"); fprintf(out, "\tor $t3, $t4, $t5\n"); } if (quad->op == eq) { fprintf(out, "\tslt $t4, $t1, $t2\n"); fprintf(out, "\tslt $t5, $t2, $t1\n"); fprintf(out, "\tnor $t3, $t4, $t5\n"); fprintf(out, "\tandi $t3, $t3, 1\n"); } } if (t == FLOAT) { if (quad->addr1.kind == IntConst) fprintf(out, "\tli.s $f0, %d.0\n", quad->addr1.contents.intVal); if (quad->addr1.kind == FloatConst) fprintf(out, "\tli.s $f0, %f\n", quad->addr1.contents.floatVal); if (quad->addr1.kind == Val) { t1 = getType(quad->addr1.contents.name+1, map); fprintf(out, "\tlw $t3, %s\n", quad->addr1.contents.name+1); if (t1 == FLOAT) fprintf(out, "\tl.s $f0, 0($t3)\n"); if (t1 == INTEGER) { fprintf(out, "lw $t1, 0($t3)\n"); fprintf(out, "\tmtc1 $t1, $f0\n"); fprintf(out, "\tcvt.s.w $f0, $f0\n"); } } if (quad->addr2.kind == IntConst) fprintf(out, "\tli.s $f2, %d.0\n", quad->addr2.contents.intVal); if (quad->addr2.kind == FloatConst) fprintf(out, "\tli.s $f2, %f\n", quad->addr2.contents.floatVal); if (quad->addr2.kind == Val) { //要强制转换类型 t2 = getType(quad->addr2.contents.name+1, map); fprintf(out, "\tlw $t3, %s\n", quad->addr2.contents.name+1); if (t2 == FLOAT) fprintf(out, "\tl.s $f2, 0($t3)\n"); if (t2 == INTEGER) { fprintf(out, "\tlw $t2, 0($t3)\n"); fprintf(out, "\tmtc1 $t2, $f2\n"); fprintf(out, "\tcvt.s.w $f2, $f2\n"); } } if (quad->op == sm) fprintf(out, "\tc.lt.s 0, $f0, $f2\n"); if (quad->op == gt) fprintf(out, "\tc.lt.s 0, $f2, $f0\n"); if (quad->op == eq) fprintf(out, "\tc.eq.s 0, $f0, $f2\n"); if (quad->op == ne) fprintf(out, "\tc.neq.s 0, $f2, $f0\n"); fprintf(out, "\tli $t5, 1\n"); fprintf(out, "\tli, $t3, 0\n"); fprintf(out, "\tmovt $t3, $t5, 0\n"); } if (t == DOUBLE) { if (quad->addr1.kind == IntConst) fprintf(out, "\tli.d $f0, %d.0\n", quad->addr1.contents.intVal); if (quad->addr1.kind == FloatConst) fprintf(out, "\tli.d $f0, %f\n", quad->addr1.contents.floatVal); if (quad->addr1.kind == Val) { t1 = getType(quad->addr1.contents.name+1, map); fprintf(out, "\tlw $t3, %s\n", quad->addr1.contents.name+1); if (t1 == INTEGER) { fprintf(out, "\tlw $t1, 0($t3)\n"); fprintf(out, "\tmtc1 $t1, $f0\n"); fprintf(out, "\tcvt.s.w $f0, $f0\n"); fprintf(out, "\tcvt.d.s $f0, $f0\n"); } if (t1 == FLOAT) { fprintf(out, "\tl.s $f0, 0($t3)\n"); fprintf(out, "\tcvt.d.s $f0, $f0\n"); } if (t1 == DOUBLE) fprintf(out, "\tl.d $f0, 0($t3)\n"); } if (quad->addr2.kind == IntConst) fprintf(out, "\tli.d $f2, %d.0\n", quad->addr2.contents.intVal); if (quad->addr2.kind == FloatConst) fprintf(out, "\tli.d $f2, %f\n", quad->addr2.contents.floatVal); if (quad->addr2.kind == Val) { t2 = getType(quad->addr2.contents.name+1, map); fprintf(out, "\tlw $t3, %s\n", quad->addr2.contents.name+1); if (t2 == INTEGER) { fprintf(out, "\tlw $t2, 0($t3)\n"); fprintf(out, "\tmtc1 $t2, $f2\n"); fprintf(out, "\tcvt.s.w $f2, $f2\n"); fprintf(out, "\tcvt.d.s $f2, $f2\n"); } if (t2 == FLOAT) { fprintf(out, "\tl.s $f2, 0($t3)\n"); fprintf(out, "\tcvt.d.s $f2, $f2\n"); } if (t2 == DOUBLE) fprintf(out, "\tl.d $f2, 0($t3)\n"); } if (quad->op == sm) fprintf(out, "\tc.lt.d 0, $f0, $f2\n"); if (quad->op == gt) fprintf(out, "\tc.lt.d 0, $f2, $f0\n"); if (quad->op == eq) fprintf(out, "\tc.eq.d 0, $f0, $f2\n"); if (quad->op == eq) fprintf(out, "\tc.neq.d 0, $f0, $f2\n"); fprintf(out, "\tli $t5, 1\n"); fprintf(out, "\tli, $t3, 0\n"); fprintf(out, "\tmovt $t3, $t5, 0\n"); } if (strcmp(quad->addr3.contents.name, "$t7")==0) { fprintf(out, "\tadd $t7, $t3, $0\n"); return; } t = getType(quad->addr3.contents.name+1, map); fprintf(out, "\tlw $t2, %s\n", quad->addr3.contents.name+1); if (t == INTEGER) fprintf(out, "\tsw $t3, 0($t2)\n"); if (t == FLOAT) { fprintf(out, "\tmtc1 $t3, $f0\n"); fprintf(out, "\tcvt.s.w $f0, $f0\n"); fprintf(out, "\ts.s $f0, 0($t2)"); } if (t == DOUBLE) { fprintf(out, "\tmtc1 $t3, $f0\n"); fprintf(out, "\tcvt.s.w $f0, $f0\n"); fprintf(out, "\tcvt.d.s $f0, $f0\n"); fprintf(out, "\ts.d $f0, 0($t2)\n"); } if (quad->addr3.kind == Val && getVar(quad->addr3.contents.name, map)) { removeStar(quad->addr3.contents.name); quad->addr3.kind = String; } if (quad->addr2.kind == Val && getVar(quad->addr2.contents.name, map)) { quad->addr2.kind = String; removeStar(quad->addr2.contents.name); } if (quad->addr1.kind == Val && getVar(quad->addr1.contents.name, map)) { quad->addr1.kind = String; removeStar(quad->addr1.contents.name); } }