]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. index:: GIMPLE Exception Handling | |
7 | ||
8 | .. _gimple-exception-handling: | |
9 | ||
10 | Exception Handling | |
11 | ****************** | |
12 | ||
13 | Other exception handling constructs are represented using | |
14 | ``GIMPLE_TRY_CATCH``. ``GIMPLE_TRY_CATCH`` has two operands. The | |
15 | first operand is a sequence of statements to execute. If executing | |
16 | these statements does not throw an exception, then the second operand | |
17 | is ignored. Otherwise, if an exception is thrown, then the second | |
18 | operand of the ``GIMPLE_TRY_CATCH`` is checked. The second | |
19 | operand may have the following forms: | |
20 | ||
21 | * A sequence of statements to execute. When an exception occurs, | |
22 | these statements are executed, and then the exception is rethrown. | |
23 | ||
24 | * A sequence of ``GIMPLE_CATCH`` statements. Each | |
25 | ``GIMPLE_CATCH`` has a list of applicable exception types and | |
26 | handler code. If the thrown exception matches one of the caught | |
27 | types, the associated handler code is executed. If the handler | |
28 | code falls off the bottom, execution continues after the original | |
29 | ``GIMPLE_TRY_CATCH``. | |
30 | ||
31 | * A ``GIMPLE_EH_FILTER`` statement. This has a list of | |
32 | permitted exception types, and code to handle a match failure. If the | |
33 | thrown exception does not match one of the allowed types, the | |
34 | associated match failure code is executed. If the thrown exception | |
35 | does match, it continues unwinding the stack looking for the next | |
36 | handler. | |
37 | ||
38 | Currently throwing an exception is not directly represented in | |
39 | GIMPLE, since it is implemented by calling a function. At some | |
40 | point in the future we will want to add some way to express that | |
41 | the call will throw an exception of a known type. | |
42 | ||
43 | Just before running the optimizers, the compiler lowers the | |
44 | high-level EH constructs above into a set of ``goto`` s, magic | |
45 | labels, and EH regions. Continuing to unwind at the end of a | |
3ed1b4ce | 46 | cleanup is represented with a ``GIMPLE_RESX``. |