|
@@ -29,6 +29,10 @@ namespace zp
|
|
|
|
|
|
using Index = int;
|
|
|
using Cell = unsigned char;
|
|
|
+
|
|
|
+
|
|
|
+ // forward declaration
|
|
|
+ class IRVisitor;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -51,6 +55,7 @@ public:
|
|
|
struct zp::BlockInstruction
|
|
|
{
|
|
|
virtual ~BlockInstruction(void) = default;
|
|
|
+ virtual void accept(IRVisitor& v) = 0;
|
|
|
};
|
|
|
|
|
|
|
|
@@ -58,15 +63,17 @@ struct zp::UnionBlockInstruction :
|
|
|
public BlockInstruction
|
|
|
{
|
|
|
std::vector<std::unique_ptr<BlockInstruction>> content;
|
|
|
+ virtual void accept(IRVisitor& v);
|
|
|
};
|
|
|
|
|
|
|
|
|
struct zp::IOInstruction :
|
|
|
public BlockInstruction
|
|
|
{
|
|
|
- /// true on , false on .
|
|
|
- bool read;
|
|
|
- inline BlockInstruction(bool read) : read{read} {}
|
|
|
+ /// true on "," (reads) false on "." (writes)
|
|
|
+ bool isRead;
|
|
|
+ inline IOInstruction(bool isRead) : isRead{isRead} {}
|
|
|
+ virtual void accept(IRVisitor& v);
|
|
|
};
|
|
|
|
|
|
|
|
@@ -75,18 +82,21 @@ struct zp::SimpleBlockInstruction :
|
|
|
{
|
|
|
Index pointerMoved;
|
|
|
std::unordered_map<Index, Cell> added;
|
|
|
+ virtual void accept(IRVisitor& v);
|
|
|
};
|
|
|
|
|
|
|
|
|
struct zp::LinearLoopInstruction :
|
|
|
public BlockInstruction
|
|
|
{
|
|
|
+ virtual void accept(IRVisitor& v);
|
|
|
};
|
|
|
|
|
|
|
|
|
struct zp::LoopInstruction :
|
|
|
public UnionBlockInstruction
|
|
|
{
|
|
|
+ virtual void accept(IRVisitor& v);
|
|
|
};
|
|
|
|
|
|
|
|
@@ -98,8 +108,8 @@ public:
|
|
|
std::unique_ptr<BlockInstruction> visitInstructionBlock(InstructionBlock& ib) override;
|
|
|
std::unique_ptr<BlockInstruction> visitIOBlock(IOBlock& io) override;
|
|
|
std::unique_ptr<BlockInstruction> visitUnionBlock(UnionBlock& ub) override;
|
|
|
-
|
|
|
};
|
|
|
|
|
|
|
|
|
#endif /* ZP_OPTIMIZER_H */
|
|
|
+
|