I am new to P4. I want to change IR in the front-end e.g. changing node number. I made a new pass (class) in frontend.cpp by inheriting Visitor to change IR by this pass. Also, I found this code in compiler design slides for changing Visitor but I am not sure about the way of using it for changing IR. I would be very grateful if you can give me some hints. Thank you in advance.
const IR::Node* node;
IR::Visitor v1, v2;
const IR::Node* intermediate = node->apply(v1);
const IR::Node* final = intermediate->apply(v2);