2018-08-26 00:16:37 +01:00
|
|
|
/* This file is part of the sirit project.
|
|
|
|
* Copyright (c) 2018 ReinUsesLisp
|
|
|
|
* This software may be used and distributed according to the terms of the GNU
|
2018-11-16 07:10:10 +00:00
|
|
|
* Lesser General Public License version 3 or any later version.
|
2018-08-26 00:16:37 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-11 06:26:21 +00:00
|
|
|
#include <optional>
|
2018-08-26 00:16:37 +01:00
|
|
|
#include "common_types.h"
|
|
|
|
#include "operand.h"
|
2018-10-03 04:32:45 +01:00
|
|
|
#include "sirit/sirit.h"
|
2018-08-26 00:16:37 +01:00
|
|
|
#include "stream.h"
|
|
|
|
|
|
|
|
namespace Sirit {
|
|
|
|
|
2018-08-26 00:34:06 +01:00
|
|
|
class Op : public Operand {
|
2019-03-11 06:26:21 +00:00
|
|
|
public:
|
|
|
|
explicit Op(spv::Op opcode, std::optional<u32> id = {}, Id result_type = nullptr);
|
2018-08-26 00:34:06 +01:00
|
|
|
~Op();
|
2018-08-26 00:16:37 +01:00
|
|
|
|
|
|
|
virtual void Fetch(Stream& stream) const;
|
|
|
|
virtual u16 GetWordCount() const;
|
|
|
|
|
|
|
|
virtual bool operator==(const Operand& other) const;
|
|
|
|
|
|
|
|
void Write(Stream& stream) const;
|
|
|
|
|
2018-10-23 08:52:07 +01:00
|
|
|
void Sink(Operand* operand);
|
2018-08-26 00:16:37 +01:00
|
|
|
|
2018-10-23 09:02:18 +01:00
|
|
|
void Sink(const std::vector<Operand*>& operands);
|
|
|
|
|
2018-10-28 16:44:12 +00:00
|
|
|
void Add(const Literal& literal);
|
|
|
|
|
|
|
|
void Add(const std::vector<Literal>& literals);
|
|
|
|
|
2018-08-26 00:16:37 +01:00
|
|
|
void Add(const Operand* operand);
|
|
|
|
|
|
|
|
void Add(u32 integer);
|
|
|
|
|
|
|
|
void Add(const std::string& string);
|
|
|
|
|
2018-11-01 01:20:49 +00:00
|
|
|
void Add(const std::vector<Id>& ids);
|
2018-10-03 04:32:45 +01:00
|
|
|
|
2019-03-11 06:26:21 +00:00
|
|
|
private:
|
2018-08-26 00:16:37 +01:00
|
|
|
u16 WordCount() const;
|
|
|
|
|
|
|
|
spv::Op opcode;
|
|
|
|
|
2018-11-01 01:20:49 +00:00
|
|
|
Id result_type;
|
2018-08-26 00:16:37 +01:00
|
|
|
|
2018-10-03 04:32:45 +01:00
|
|
|
std::optional<u32> id;
|
2018-08-26 00:16:37 +01:00
|
|
|
|
|
|
|
std::vector<const Operand*> operands;
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<Operand>> operand_store;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Sirit
|