******************************************************************************** To use the dynamic-compiler prototype, you need the macro definitions for the annotations: ******************************************************************************** #include "dyn.h" ******************************************************************************** To annotate a dynamic region: ******************************************************************************** Each dynamic region must be contained within a function. Only non-overlapping, non-nested, completely distinct dynamic regions are supported. Although control flow inside the regions may be as unstructured as you like, each region must have a single entry and a single exit. Begin the region with: DYN_BEGIN(region_name) or DYN_BEGIN_KEY(region_name, key_variable) where region_name is a unique name for the region and key_variable is a run-time constant that will take on a unique value that identifies which specialized version of the region to use Then, to specify run-time constants, add one or more: DYN_STATIC(rtconst_variable) where rtconst_variable is a run-time constant for the region Followed by: DYN_CODE; After which the code of the dynamic region follows. In that code, you may include: DYN_LOOP; which unrolls the innermost enclosing loop; only correct if the loop bound is a run-time constant (otherwise the stitcher can go into an infinite loop) End the region with: DYN_END; ******************************************************************************** Example of annotated code from sparse (spMultiply() from spUtils.c): ******************************************************************************** DYN_BEGIN(RegionMult); DYN_STATIC(Matrix); DYN_CODE; pExtOrder = &Matrix->IntToExtRowMap[Matrix->Size]; for (I = Matrix->Size; I > 0; I--) { DYN_LOOP; pElement = Matrix->FirstInRow[I]; Sum = 0.0; while (pElement != NULL) { DYN_LOOP; Sum += (pElement->Real) * (Vector[pElement->Col]); pElement = pElement->NextInRow; } RHS[*(pExtOrder--)] = Sum; } DYN_END; ******************************************************************************** Pointer Transitivity: ******************************************************************************** Objects pointed to by run-time constant pointers are assumed to be run-time constant. Thus, the DYN_STATIC annotation is transitive. If you want to break a chain of transitivity, use the DYN_DYNAMIC annotation. q = DYN_DYNAMIC(rtconst_pointer) prevents the BTA from deriving q as being a run-time constant based on rtconst_pointer (stops pointer-transitivity rule); typically this is used to access a dynamic field of a run-time-constant structure Example: DYN_STATIC(mystructptr) ... DYN_DYNAMIC(mystructptr)->dynamic_field ... Warning: Don't specify globals as run-time constants. Because both run-time constants and unresolved names are implemented as load-time constants, specifying globals as run-time constants can create problems for the BTA. Also, if you are having difficulties with the BTA, try to eliminate globals from your dynamic region. It might be erroneously deducing globals to be run-time constants (this bug _should_ be fixed, but we're not sure...).