Skip to content

Commit

Permalink
Rename InstBuilder class in IB and reformat.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Apr 18, 2024
1 parent af520b8 commit 4ad0d71
Show file tree
Hide file tree
Showing 43 changed files with 1,490 additions and 1,702 deletions.
2 changes: 1 addition & 1 deletion compiler/documentator/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ static void calcEqnsNicknames(const vector<string>& eqNames, vector<string>& eqN
// for( vector<string>::iterator it = v.begin(); it < v.end()-1; ++it ) {
// if (init == *it) {
// //cerr << "!! Warning Documentator : calcEqnsNicknames : duplicates \"" <<
//init << "\"" << endl;
// init << "\"" << endl;
// }
// }
eqNicknames.push_back(init);
Expand Down
21 changes: 9 additions & 12 deletions compiler/extended/powprim.hh
Original file line number Diff line number Diff line change
Expand Up @@ -165,34 +165,31 @@ class PowPrim : public xtended {
Typed::VarType rtype = convert2FIRType(result->nature());

// Expand the pow depending on the exponent argument
BlockInst* block = InstBuilder::genBlockInst();
BlockInst* block = IB::genBlockInst();
std::string faust_power_name = container->getFaustPowerName() +
std::to_string(pow_arg) +
((rtype == Typed::kInt32) ? "_i" : "_f");

Names named_args;
named_args.push_back(
InstBuilder::genNamedTyped("value", InstBuilder::genBasicTyped(t0)));
named_args.push_back(IB::genNamedTyped("value", IB::genBasicTyped(t0)));

if (pow_arg == 0) {
block->pushBackInst(InstBuilder::genRetInst(InstBuilder::genTypedNum(t0, 1.0)));
block->pushBackInst(IB::genRetInst(IB::genTypedNum(t0, 1.0)));
} else {
ValueInst* res = InstBuilder::genLoadFunArgsVar("value");
ValueInst* res = IB::genLoadFunArgsVar("value");
for (int i = 0; i < pow_arg - 1; i++) {
res = InstBuilder::genMul(res, InstBuilder::genLoadFunArgsVar("value"));
res = IB::genMul(res, IB::genLoadFunArgsVar("value"));
}
block->pushBackInst(InstBuilder::genRetInst(res));
block->pushBackInst(IB::genRetInst(res));
}

container->pushGlobalDeclare(InstBuilder::genDeclareFunInst(
container->pushGlobalDeclare(IB::genDeclareFunInst(
faust_power_name,
InstBuilder::genFunTyped(named_args, InstBuilder::genBasicTyped(rtype),
FunTyped::kLocal),
block));
IB::genFunTyped(named_args, IB::genBasicTyped(rtype), FunTyped::kLocal), block));

Values truncated_args;
truncated_args.push_back((*args.begin()));
return InstBuilder::genFunCallInst(faust_power_name, truncated_args);
return IB::genFunCallInst(faust_power_name, truncated_args);

} else {
// Both arguments forced to itfloat()
Expand Down
8 changes: 4 additions & 4 deletions compiler/extended/xtended.hh
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@ inline bool comparable(double x, double y)
// Casting operations
inline ValueInst* promote2real(int type, ValueInst* val)
{
return (type == kReal) ? val : InstBuilder::genCastRealInst(val);
return (type == kReal) ? val : IB::genCastRealInst(val);
}
inline ValueInst* promote2int(int type, ValueInst* val)
{
return (type == kInt) ? val : InstBuilder::genCastInt32Inst(val);
return (type == kInt) ? val : IB::genCastInt32Inst(val);
}

inline ValueInst* cast2real(int type, ValueInst* val)
{
return (type == kReal) ? InstBuilder::genCastRealInst(val) : val;
return (type == kReal) ? IB::genCastRealInst(val) : val;
}
inline ValueInst* cast2int(int type, ValueInst* val)
{
return (type == kInt) ? InstBuilder::genCastInt32Inst(val) : val;
return (type == kInt) ? IB::genCastInt32Inst(val) : val;
}

#endif
9 changes: 4 additions & 5 deletions compiler/generator/c/c_instructions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,15 @@ class CInstVisitor : public TextInstVisitor {
StoreVarInst* c99_init_inst = nullptr;

if (c99_declare_inst) {
InstBuilder::genLabelInst("/* C99 loop */")->accept(this);
IB::genLabelInst("/* C99 loop */")->accept(this);
*fOut << "{";
fTab++;
tab(fTab, *fOut);

// To generate C99 compatible loops...
c99_init_inst = InstBuilder::genStoreStackVar(c99_declare_inst->getName(),
c99_declare_inst->fValue);
c99_declare_inst = InstBuilder::genDecStackVar(c99_declare_inst->getName(),
InstBuilder::genInt32Typed());
c99_init_inst =
IB::genStoreStackVar(c99_declare_inst->getName(), c99_declare_inst->fValue);
c99_declare_inst = IB::genDecStackVar(c99_declare_inst->getName(), IB::genInt32Typed());
// C99 loop variable declared outside the loop
c99_declare_inst->accept(this);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/generator/cmajor/cmajor_code_container.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ struct TableSizeCloneVisitor : public BasicCloneVisitor {
for (const auto& it1 : inst->fArgs) {
cloned_args.push_back(it1->clone(this));
}
return InstBuilder::genFunCallInst(inst->fName + "_" + std::to_string(size->fNum),
cloned_args, inst->fMethod);
return IB::genFunCallInst(inst->fName + "_" + std::to_string(size->fNum), cloned_args,
inst->fMethod);
} else {
return BasicCloneVisitor::visit(inst);
}
Expand Down
Loading

0 comments on commit 4ad0d71

Please sign in to comment.