Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:28

0001 //===- HardwareLoops.h ------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 /// \file
0009 ///
0010 /// Defines an IR pass for the creation of hardware loops.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CODEGEN_HARDWARELOOPS_H
0015 #define LLVM_CODEGEN_HARDWARELOOPS_H
0016 
0017 #include "llvm/IR/PassManager.h"
0018 
0019 namespace llvm {
0020 
0021 struct HardwareLoopOptions {
0022   std::optional<unsigned> Decrement;
0023   std::optional<unsigned> Bitwidth;
0024   std::optional<bool> Force;
0025   std::optional<bool> ForcePhi;
0026   std::optional<bool> ForceNested;
0027   std::optional<bool> ForceGuard;
0028 
0029   HardwareLoopOptions &setDecrement(unsigned Count) {
0030     Decrement = Count;
0031     return *this;
0032   }
0033   HardwareLoopOptions &setCounterBitwidth(unsigned Width) {
0034     Bitwidth = Width;
0035     return *this;
0036   }
0037   HardwareLoopOptions &setForce(bool Force) {
0038     this->Force = Force;
0039     return *this;
0040   }
0041   HardwareLoopOptions &setForcePhi(bool Force) {
0042     ForcePhi = Force;
0043     return *this;
0044   }
0045   HardwareLoopOptions &setForceNested(bool Force) {
0046     ForceNested = Force;
0047     return *this;
0048   }
0049   HardwareLoopOptions &setForceGuard(bool Force) {
0050     ForceGuard = Force;
0051     return *this;
0052   }
0053   bool getForcePhi() const {
0054     return ForcePhi.has_value() && ForcePhi.value();
0055   }
0056   bool getForceNested() const {
0057     return ForceNested.has_value() && ForceNested.value();
0058   }
0059   bool getForceGuard() const {
0060     return ForceGuard.has_value() && ForceGuard.value();
0061   }
0062 };
0063 
0064 class HardwareLoopsPass : public PassInfoMixin<HardwareLoopsPass> {
0065   HardwareLoopOptions Opts;
0066 
0067 public:
0068   explicit HardwareLoopsPass(HardwareLoopOptions Opts = {})
0069     : Opts(Opts) { }
0070 
0071   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0072 };
0073 
0074 } // end namespace llvm
0075 
0076 #endif // LLVM_CODEGEN_HARDWARELOOPS_H