Modifying a ParserState Node

Hi all,

I want to modify a ParserState node in a new pass in frontend. I used preorder in IR::ParserState by using Transform. For example, for one node I have
state parse_udp { packet.extract<udp_t>(hdr.udp); accept;}
and I want to change it to
state parse_tcp {packet.extract<tcp_t>(hdr.tcp); accept;}
so I checked ParserState class, we have node->name which is parse_udp in my example and I try to change it to parse_tcp by
node->name = new IR::ParserValueSet::ID (“parse_tcp”); or
node->name = new IR::ID(“parse_tcp”);
But I have some errors. Could you give me some hints?
Also, in ParserState class I could not find any methods or variables related to packet.extract<udp_t>(hdr.udp). please let me know how I can access to that.

This sounds like you are asking about internals of the open source p4c compiler implementation, and how to change them. I suspect that creating an issue on the repository GitHub - p4lang/p4c: P4_16 reference compiler is a better way to get attention from p4c developers on such questions, rather than asking here.

1 Like

Thank you, I created an issue.