Jeff Saremi <jeffsaremi@xxxxxxxxx> writes: > Does anyone have an example of how to create a simple switch statement in Gimple? I'm really confused by the CASE_LABEL. > I know that to create a switch one can call gimple_build_switch() but then it requires one or more case labels (so far so good). But there seem to be no function that can create a case label. We have gimple_build_label() which may be the one however again i'm confused by the fact that this function takes an existing? label. Why would someone want to create a label for an existing label. A CASE_LABEL_EXPR contains a reference to an existing LABEL_DECL. A CASE_LABEL is part of a GENERIC SWITCH_EXPR or a GIMPLE GIMPLE_SWITCH. Either construct has a list of CASE_LABEL_EXPRs. Each CASE_LABEL_EXPR refers to a LABEL_DECL. The LABEL_DECL should be defined elsewhere in the function in front of whatever code should be executed for that case. In other words, a GIMPLE_SWITCH is a multi-way goto. To build a CASE_LABEL_EXPR, use build3. gimple_build_label takes a GENERIC LABEL_DECL and constructs a GIMPLE_LABEL. Ian