brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · d95bd2e Raw
55 lines · cpp
1//===- TGTimer.cpp - TableGen Timer implementation --------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// Implement the tablegen timer class.10//11//===----------------------------------------------------------------------===//12 13#include "llvm/TableGen/TGTimer.h"14using namespace llvm;15 16// These functions implement the phase timing facility. Starting a timer17// when one is already running stops the running one.18void TGTimer::startTimer(StringRef Name) {19  if (!TimingGroup)20    return;21  if (LastTimer && LastTimer->isRunning()) {22    LastTimer->stopTimer();23    if (BackendTimer) {24      LastTimer->clear();25      BackendTimer = false;26    }27  }28 29  LastTimer = std::make_unique<Timer>("", Name, *TimingGroup);30  LastTimer->startTimer();31}32 33void TGTimer::stopTimer() {34  if (!TimingGroup)35    return;36 37  assert(LastTimer && "No phase timer was started");38  LastTimer->stopTimer();39}40 41void TGTimer::startBackendTimer(StringRef Name) {42  if (!TimingGroup)43    return;44 45  startTimer(Name);46  BackendTimer = true;47}48 49void TGTimer::stopBackendTimer() {50  if (!TimingGroup || !BackendTimer)51    return;52  stopTimer();53  BackendTimer = false;54}55