1695SN/A/*
214205Sandreas.sandberg@arm.com * Copyright (c) 2019 Arm Limited
314205Sandreas.sandberg@arm.com * All rights reserved.
414205Sandreas.sandberg@arm.com *
514205Sandreas.sandberg@arm.com * The license below extends only to copyright in the software and shall
614205Sandreas.sandberg@arm.com * not be construed as granting a license to any other intellectual
714205Sandreas.sandberg@arm.com * property including but not limited to intellectual property relating
814205Sandreas.sandberg@arm.com * to a hardware implementation of the functionality of the software
914205Sandreas.sandberg@arm.com * licensed hereunder.  You may use the software subject to the license
1014205Sandreas.sandberg@arm.com * terms below provided that you ensure that this notice is replicated
1114205Sandreas.sandberg@arm.com * unmodified and in its entirety in all distributions of the software,
1214205Sandreas.sandberg@arm.com * modified or unmodified, in source code or in binary form.
1314205Sandreas.sandberg@arm.com *
141762SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
15695SN/A * All rights reserved.
16695SN/A *
17695SN/A * Redistribution and use in source and binary forms, with or without
18695SN/A * modification, are permitted provided that the following conditions are
19695SN/A * met: redistributions of source code must retain the above copyright
20695SN/A * notice, this list of conditions and the following disclaimer;
21695SN/A * redistributions in binary form must reproduce the above copyright
22695SN/A * notice, this list of conditions and the following disclaimer in the
23695SN/A * documentation and/or other materials provided with the distribution;
24695SN/A * neither the name of the copyright holders nor the names of its
25695SN/A * contributors may be used to endorse or promote products derived from
26695SN/A * this software without specific prior written permission.
27695SN/A *
28695SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29695SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30695SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31695SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32695SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33695SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34695SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35695SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36695SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37695SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38695SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392665Ssaidi@eecs.umich.edu *
402665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert
41695SN/A */
42695SN/A
43695SN/A#ifndef __BASE_STATS_TEXT_HH__
44695SN/A#define __BASE_STATS_TEXT_HH__
45695SN/A
46695SN/A#include <iosfwd>
4714205Sandreas.sandberg@arm.com#include <stack>
48695SN/A#include <string>
49695SN/A
508229Snate@binkert.org#include "base/stats/output.hh"
519554Sandreas.hansson@arm.com#include "base/stats/types.hh"
524078Sbinkertn@umich.edu#include "base/output.hh"
53695SN/A
54729SN/Anamespace Stats {
55695SN/A
56695SN/Aclass Text : public Output
57695SN/A{
58695SN/A  protected:
59695SN/A    bool mystream;
60695SN/A    std::ostream *stream;
61695SN/A
6214205Sandreas.sandberg@arm.com    // Object/group path
6314205Sandreas.sandberg@arm.com    std::stack<std::string> path;
6414205Sandreas.sandberg@arm.com
65695SN/A  protected:
665886Snate@binkert.org    bool noOutput(const Info &info);
67695SN/A
68695SN/A  public:
69695SN/A    bool descriptions;
70695SN/A
71695SN/A  public:
72695SN/A    Text();
73695SN/A    Text(std::ostream &stream);
74695SN/A    Text(const std::string &file);
75695SN/A    ~Text();
76695SN/A
77695SN/A    void open(std::ostream &stream);
78695SN/A    void open(const std::string &file);
7914205Sandreas.sandberg@arm.com    std::string statName(const std::string &name) const;
80695SN/A
81695SN/A    // Implement Visit
8214205Sandreas.sandberg@arm.com    void visit(const ScalarInfo &info) override;
8314205Sandreas.sandberg@arm.com    void visit(const VectorInfo &info) override;
8414205Sandreas.sandberg@arm.com    void visit(const DistInfo &info) override;
8514205Sandreas.sandberg@arm.com    void visit(const VectorDistInfo &info) override;
8614205Sandreas.sandberg@arm.com    void visit(const Vector2dInfo &info) override;
8714205Sandreas.sandberg@arm.com    void visit(const FormulaInfo &info) override;
8814205Sandreas.sandberg@arm.com    void visit(const SparseHistInfo &info) override;
8914205Sandreas.sandberg@arm.com
9014205Sandreas.sandberg@arm.com    // Group handling
9114205Sandreas.sandberg@arm.com    void beginGroup(const char *name) override;
9214205Sandreas.sandberg@arm.com    void endGroup() override;
93695SN/A
94695SN/A    // Implement Output
9514205Sandreas.sandberg@arm.com    bool valid() const override;
9614205Sandreas.sandberg@arm.com    void begin() override;
9714205Sandreas.sandberg@arm.com    void end() override;
98695SN/A};
99695SN/A
1009554Sandreas.hansson@arm.comstd::string ValueToString(Result value, int precision);
1019554Sandreas.hansson@arm.com
1028296Snate@binkert.orgOutput *initText(const std::string &filename, bool desc);
1034078Sbinkertn@umich.edu
1047811Ssteve.reinhardt@amd.com} // namespace Stats
105695SN/A
106695SN/A#endif // __BASE_STATS_TEXT_HH__
107