1
0
Fork 0
mirror of https://git.suyu.dev/suyu/sirit.git synced 2024-12-23 20:46:01 +00:00
sirit/src/op.h

53 lines
1.1 KiB
C
Raw Normal View History

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
* General Public License version 2 or any later version.
*/
#pragma once
#include "sirit/sirit.h"
#include "common_types.h"
#include "operand.h"
#include "stream.h"
namespace Sirit {
2018-08-26 00:34:06 +01:00
class Op : public Operand {
2018-08-26 00:16:37 +01:00
public:
2018-08-26 00:34:06 +01:00
explicit Op(spv::Op opcode, u32 id = UINT32_MAX, const Op* result_type = nullptr);
~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;
void Add(Operand* operand);
void Add(const Operand* operand);
void Add(u32 integer);
void Add(const std::string& string);
2018-08-26 00:34:06 +01:00
void Add(const std::vector<const Op*>& ids);
2018-08-26 00:16:37 +01:00
private:
u16 WordCount() const;
spv::Op opcode;
2018-08-26 00:34:06 +01:00
const Op* result_type;
2018-08-26 00:16:37 +01:00
u32 id;
std::vector<const Operand*> operands;
std::vector<std::unique_ptr<Operand>> operand_store;
};
} // namespace Sirit