Skip to content

Commit

Permalink
Correct NullDeclareVarInst implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Apr 9, 2024
1 parent 62a6065 commit d2818ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/generator/code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void CodeContainer::processFIR(void)
if (fIntControl->getSize() > 0 && fIntControl->fAccess == Address::kStruct) {
pushDeclare(InstBuilder::genDecStructVar("iControl", InstBuilder::genArrayTyped(Typed::kInt32, fIntControl->getSize())));
}
if (fRealControl->getSize() > 0 && fIntControl->fAccess == Address::kStruct) {
if (fRealControl->getSize() > 0 && fRealControl->fAccess == Address::kStruct) {
pushDeclare(InstBuilder::genDecStructVar("fControl", InstBuilder::genArrayTyped(itfloat(), fRealControl->getSize())));
}
}
Expand Down
6 changes: 6 additions & 0 deletions compiler/generator/fir/fir_instructions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ class FIRInstVisitor : public InstVisitor, public CStringTypeManager {
EndLine();
}

virtual void visit(NullDeclareVarInst* inst)
{
*fOut << "NullDeclareVarInst()";
EndLine();
}

// For Rust and Julia backends
virtual void visit(DeclareBufferIterators* inst)
{
Expand Down
12 changes: 9 additions & 3 deletions compiler/generator/instructions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ struct Address : public Printable {
kVolatile = 0x80,
kReference = 0x100, // Access by reference (for Rust backend)
kMutable = 0x200, // Mutable access (for Rust backend)
kConst = 0x400 // Const access
kConst = 0x400, // Const access
kNoAccess = 0x800 // Degenerated case used in NullDeclareVarInst
};

Address() {}
Expand Down Expand Up @@ -966,8 +967,13 @@ struct NullDeclareVarInst : public DeclareVarInst {
NullDeclareVarInst():DeclareVarInst()
{}

// Empty
void accept(InstVisitor* visitor) {}
void setAccess(Address::AccessType access) {}
Address::AccessType getAccess() const { return Address::kNoAccess; }

void setName(const std::string& name) {}
std::string getName() const { return "NullDeclareVarInst"; }

void accept(InstVisitor* visitor) { visitor->visit(this); }

StatementInst* clone(CloneVisitor* cloner) { return new NullStatementInst(); }
};
Expand Down

0 comments on commit d2818ac

Please sign in to comment.