
This new analysis returns a hierarchical view of the convergence regions in the given function. This will allow our passes to query which basic block belongs to which convergence region, and structurize the code in consequence. Definition ---------- A convergence region is a CFG with: - a single entry node. - one or multiple exit nodes (different from LLVM's regions). - one back-edge - zero or more subregions. Excluding sub-regions nodes, the nodes of a region can only reference a single convergence token. A subregion uses a different convergence token. Algorithm --------- This algorithm assumes all loops are in the Simplify form. Create an initial convergence region for the whole function. - the convergence token is the function entry token. - the entry is the function entrypoint. - Exits are all the basic blocks terminating with a return instruction. Take the function CFG, and process it in DAG order (ignoring back-edges). If a basic block is a loop header: - Create a new region. - The parent region is the parent's loop region if any, otherwise, the top level region. - The region blocks are all the blocks belonging to this loop. - For each loop exit: - visit the rest of the CFG in DAG order (ignore back-edges). - if the region's convergence token is found, add all the blocks dominated by the exit from which the token is reachable to the region. - continue the algorithm with the loop headers successors.
39 lines
1.5 KiB
C++
39 lines
1.5 KiB
C++
//===-- SPIRV.h - Top-level interface for SPIR-V representation -*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIB_TARGET_SPIRV_SPIRV_H
|
|
#define LLVM_LIB_TARGET_SPIRV_SPIRV_H
|
|
|
|
#include "MCTargetDesc/SPIRVMCTargetDesc.h"
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
namespace llvm {
|
|
class SPIRVTargetMachine;
|
|
class SPIRVSubtarget;
|
|
class InstructionSelector;
|
|
class RegisterBankInfo;
|
|
|
|
ModulePass *createSPIRVPrepareFunctionsPass(const SPIRVTargetMachine &TM);
|
|
FunctionPass *createSPIRVStripConvergenceIntrinsicsPass();
|
|
FunctionPass *createSPIRVRegularizerPass();
|
|
FunctionPass *createSPIRVPreLegalizerPass();
|
|
FunctionPass *createSPIRVEmitIntrinsicsPass(SPIRVTargetMachine *TM);
|
|
InstructionSelector *
|
|
createSPIRVInstructionSelector(const SPIRVTargetMachine &TM,
|
|
const SPIRVSubtarget &Subtarget,
|
|
const RegisterBankInfo &RBI);
|
|
|
|
void initializeSPIRVModuleAnalysisPass(PassRegistry &);
|
|
void initializeSPIRVConvergenceRegionAnalysisWrapperPassPass(PassRegistry &);
|
|
void initializeSPIRVPreLegalizerPass(PassRegistry &);
|
|
void initializeSPIRVEmitIntrinsicsPass(PassRegistry &);
|
|
} // namespace llvm
|
|
|
|
#endif // LLVM_LIB_TARGET_SPIRV_SPIRV_H
|