mini-llvm 0.1.0
Loading...
Searching...
No Matches
Operand.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <concepts>
6#include <format>
7#include <string>
8
10
11namespace mini_llvm::mc {
12
14public:
15 virtual ~Operand() = default;
16
17 Operand() = default;
18
19 Operand(const Operand &) = delete;
20 Operand &operator=(const Operand &) = delete;
21
22 Operand(Operand &&) = delete;
23 Operand &operator=(Operand &&) = delete;
24
25 virtual std::string format() const = 0;
26};
27
28} // namespace mini_llvm::mc
29
30template <typename OperandT>
31 requires std::derived_from<OperandT, mini_llvm::mc::Operand>
32struct std::formatter<OperandT> {
33 constexpr auto parse(std::format_parse_context &ctx) {
34 return ctx.begin();
35 }
36
37 template <typename FormatContext>
38 auto format(const OperandT &operand, FormatContext &ctx) const {
39 return std::format_to(ctx.out(), "{}", operand.format());
40 }
41};
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Operand & operator=(Operand &&)=delete
virtual std::string format() const =0
Operand & operator=(const Operand &)=delete
Operand(const Operand &)=delete
Operand(Operand &&)=delete
virtual ~Operand()=default
Definition Directive.h:8
auto format(const OperandT &operand, FormatContext &ctx) const
Definition Operand.h:38
constexpr auto parse(std::format_parse_context &ctx)
Definition Operand.h:33