1 // Copyright (c) 2018 Google LLC.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef LIBSPIRV_OPT_LOOP_UTILS_H_
16 #define LIBSPIRV_OPT_LOOP_UTILS_H_
27 // Set of basic loop transformation.
30 LoopUtils(ir::IRContext* context, ir::Loop* loop)
31 : context_(context), loop_(loop) {}
33 // The converts the current loop to loop closed SSA form.
34 // In the loop closed SSA, all loop exiting values go through a dedicated Phi
35 // instruction. For instance:
56 // This makes some loop transformations (such as loop unswitch) simpler
57 // (removes the needs to take care of exiting variables).
58 void MakeLoopClosedSSA();
60 // Create dedicate exit basic block. This ensure all exit basic blocks has the
61 // loop as sole predecessors.
62 // By construction, structured control flow already has a dedicated exit
64 // Preserves: CFG, def/use and instruction to block mapping.
65 void CreateLoopDedicatedExits();
68 ir::IRContext* context_;
73 } // namespace spvtools
75 #endif // LIBSPIRV_OPT_LOOP_UTILS_H_