blob: 06d9f82756d430e74ac387adfc64048c901a9904 [file] [log] [blame]
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +01001/*
2 * Copyright (c) 2023 Arm Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010025#ifndef CKW_PROTOTYPE_INCLUDE_CKW_OPERANDBASE_H
26#define CKW_PROTOTYPE_INCLUDE_CKW_OPERANDBASE_H
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010027
Nikolaj Jensen5ff48022023-06-27 14:13:24 +010028#include "ckw/types/DataType.h"
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010029#include <string>
30
31namespace ckw
32{
33namespace prototype
34{
35class IGpuKernelWriter;
Nikolaj Jensenacea4072023-07-03 09:44:42 +010036
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010037class Operand;
38} // namespace prototype
39
40/** The base class for all operands. */
41class OperandBase
42{
43public:
44 /** Constructor
45 *
46 * @param[in] name The name of the operand.
47 */
48 explicit OperandBase(const ::std::string &name);
49
50 /** Destructor */
51 virtual ~OperandBase();
52
53 /** (Internal use only) Create the implementation operand.
54 *
55 * @param[in] writer The implementation kernel writer.
56 */
57 virtual prototype::Operand create_impl_operand(prototype::IGpuKernelWriter *writer) const = 0;
58
59 /** Get the name of the operand. */
60 const ::std::string &name() const;
61
62 /** Set the name of the operand. */
63 OperandBase &name(const ::std::string &name);
64
65 /** Get the data type of the operand. */
66 virtual DataType data_type() const = 0;
67
68 /** Get whether the operand is compile-time constant. */
69 virtual bool is_constant() const = 0;
70
71private:
72 ::std::string _name;
73};
74
75} // namespace ckw
76
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010077#endif // CKW_PROTOTYPE_INCLUDE_CKW_OPERANDBASE_H