Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:36

0001 //===- llvm/TableGen/TGTimer.h - Class for TableGen Timer -------*- 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 //
0009 // This file defines the TableGen timer class. It's a thin wrapper around timer
0010 // support in llvm/Support/Timer.h.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_TABLEGEN_TGTIMER_H
0015 #define LLVM_TABLEGEN_TGTIMER_H
0016 
0017 #include "llvm/ADT/StringRef.h"
0018 #include "llvm/Support/Timer.h"
0019 #include <memory>
0020 
0021 namespace llvm {
0022 
0023 // Timer related functionality f or TableGen backends.
0024 class TGTimer {
0025 private:
0026   std::unique_ptr<TimerGroup> TimingGroup;
0027   std::unique_ptr<Timer> LastTimer;
0028   bool BackendTimer = false; // Is last timer special backend overall timer?
0029 
0030 public:
0031   TGTimer() = default;
0032   ~TGTimer() = default;
0033 
0034   /// Start phase timing; called if the --time-phases option is specified.
0035   void startPhaseTiming() {
0036     TimingGroup =
0037         std::make_unique<TimerGroup>("TableGen", "TableGen Phase Timing");
0038   }
0039 
0040   /// Start timing a phase. Automatically stops any previous phase timer.
0041   void startTimer(StringRef Name);
0042 
0043   /// Stop timing a phase.
0044   void stopTimer();
0045 
0046   /// Start timing the overall backend. If the backend itself starts a timer,
0047   /// then this timer is cleared.
0048   void startBackendTimer(StringRef Name);
0049 
0050   /// Stop timing the overall backend.
0051   void stopBackendTimer();
0052 
0053   /// Stop phase timing and print the report.
0054   void stopPhaseTiming() { TimingGroup.reset(); }
0055 };
0056 
0057 } // end namespace llvm
0058 
0059 #endif // LLVM_TABLEGEN_TGTIMER_H