//===-- HexagonHardwareLoops.cpp - Identify and generate hardware loops ---===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This pass identifies loops where we can generate the Hexagon hardware// loop instruction. The hardware loop can perform loop branches with a// zero-cycle overhead.//// The pattern that defines the induction variable can changed depending on// prior optimizations. For example, the IndVarSimplify phase run by 'opt'// normalizes induction variables, and the Loop Strength Reduction pass// run by 'llc' may also make changes to the induction variable.// The pattern detected by this phase is due to running Strength Reduction.//// Criteria for hardware loops:// - Countable loops (w/ ind. var for a trip count)// - Assumes loops are normalized by IndVarSimplify// - Try inner-most loops first// - No nested hardware loops.// - No function calls in loops.////===----------------------------------------------------------------------===//#define DEBUG_TYPE "hwloops"#include"llvm/ADT/SmallSet.h"#include"llvm/ADT/Statistic.h"#include"llvm/CodeGen/MachineDominators.h"#include"llvm/CodeGen/MachineFunction.h"#include"llvm/CodeGen/MachineFunctionPass.h"#include"llvm/CodeGen/MachineInstrBuilder.h"#include"llvm/CodeGen/MachineLoopInfo.h"#include"llvm/CodeGen/MachineRegisterInfo.h"#include"llvm/PassSupport.h"#include"llvm/Support/CommandLine.h"#include"llvm/Support/Debug.h"#include<