2018-08-25 23:16:37 +00: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-08-27 02:28:39 +00:00
|
|
|
* Lesser General Public License version 2.1 or any later version.
|
2018-08-25 23:16:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common_types.h"
|
|
|
|
#include "operand.h"
|
2018-10-03 03:32:45 +00:00
|
|
|
#include "sirit/sirit.h"
|
2018-08-25 23:16:37 +00:00
|
|
|
#include "stream.h"
|
2018-10-03 03:32:45 +00:00
|
|
|
#include <optional>
|
2018-08-25 23:16:37 +00:00
|
|
|
|
|
|
|
namespace Sirit {
|
|
|
|
|
2018-08-25 23:34:06 +00:00
|
|
|
class Op : public Operand {
|
2018-10-03 03:32:45 +00:00
|
|
|
public:
|
|
|
|
explicit Op(spv::Op opcode, std::optional<u32> id = {},
|
|
|
|
Ref result_type = nullptr);
|
2018-08-25 23:34:06 +00:00
|
|
|
~Op();
|
2018-08-25 23:16:37 +00:00
|
|
|
|
|
|
|
virtual void Fetch(Stream& stream) const;
|
|
|
|
virtual u16 GetWordCount() const;
|
|
|
|
|
|
|
|
virtual bool operator==(const Operand& other) const;
|
|
|
|
|
|
|
|
void Write(Stream& stream) const;
|
|
|
|
|
|
|
|
void Add(Operand* operand);
|
|
|
|
|
|
|
|
void Add(const Operand* operand);
|
|
|
|
|
|
|
|
void Add(u32 integer);
|
|
|
|
|
|
|
|
void Add(const std::string& string);
|
|
|
|
|
2018-08-28 07:01:21 +00:00
|
|
|
void Add(const std::vector<Ref>& ids);
|
2018-10-03 03:32:45 +00:00
|
|
|
|
2018-10-23 07:45:56 +00:00
|
|
|
void Add(const std::vector<Operand*>& operands);
|
|
|
|
|
2018-10-03 03:32:45 +00:00
|
|
|
private:
|
2018-08-25 23:16:37 +00:00
|
|
|
u16 WordCount() const;
|
|
|
|
|
|
|
|
spv::Op opcode;
|
|
|
|
|
2018-08-28 07:01:21 +00:00
|
|
|
Ref result_type;
|
2018-08-25 23:16:37 +00:00
|
|
|
|
2018-10-03 03:32:45 +00:00
|
|
|
std::optional<u32> id;
|
2018-08-25 23:16:37 +00:00
|
|
|
|
|
|
|
std::vector<const Operand*> operands;
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<Operand>> operand_store;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Sirit
|