Skip to content

Conversation

@kfcripps
Copy link
Contributor

@kfcripps kfcripps commented Sep 3, 2025

Reduces the following parser code:

    state state_1 {
        transition select(packet.lookahead<bit<16>>()) {
                0x21 : state_3;
                0x21 : state_2;
                default : accept;
        }
    }

to:

    state state_1 {
        transition select(packet.lookahead<bit<16>>()) {
                0x21 : state_3;
                default : accept;
        }
    }

and reduces the following parser code:

    state state_1 {
        transition select(packet.lookahead<bit<16>>()) {
                0x21 : state_3;
                0x22 : state_2;
                default : state_3;
        }
    }

to:

    state state_1 {
        transition select(packet.lookahead<bit<16>>()) {
                0x22 : state_2;
                default : state_3;
        }
    }

@kfcripps kfcripps added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Sep 3, 2025
@kfcripps kfcripps marked this pull request as draft September 4, 2025 12:24
@kfcripps kfcripps force-pushed the simplify-select-cases branch from 465a4ce to 6aaa0e4 Compare September 17, 2025 23:39
Signed-off-by: kfcripps <kyle@pensando.io>
Signed-off-by: Kyle Cripps <kyle@pensando.io>
@kfcripps kfcripps force-pushed the simplify-select-cases branch from 6aaa0e4 to 902b6c2 Compare November 19, 2025 01:03

bool isCompileTimeConstant(const IR::Expression *expr, const TypeMap *typeMap) {
if (expr->is<IR::Constant>()) return true;
if (expr->is<IR::BoolLiteral>()) return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be checking for an actual constant, not a compile-time constant (compile-time constants also include directionless parameters that will be bound to a constant in an instantiation), so seems misnamed. perhaps just isConstant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Topics concerning the core segments of the compiler (frontend, midend, parser)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants