mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Immediate.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <concepts>
6
#include <cstdint>
7
#include <format>
8
#include <memory>
9
#include <string>
10
11
#include "
mini-llvm/utils/Compiler.h
"
12
13
namespace
mini_llvm::mir
{
14
15
class
MINI_LLVM_EXPORT
Immediate
{
16
public
:
17
virtual
~Immediate
() =
default
;
18
19
Immediate
(
const
Immediate
&) =
delete
;
20
Immediate
&
operator=
(
const
Immediate
&) =
delete
;
21
22
Immediate
(
Immediate
&&) =
delete
;
23
Immediate
&
operator=
(
Immediate
&&) =
delete
;
24
25
virtual
int64_t
value
()
const
= 0;
26
virtual
std::unique_ptr<Immediate>
clone
()
const
= 0;
27
28
std::string
format
()
const
{
29
return
std::to_string(
value
());
30
}
31
32
protected
:
33
Immediate
() =
default
;
34
};
35
36
}
// namespace mini_llvm::mir
37
38
template
<
typename
ImmediateT>
39
requires
std::derived_from<ImmediateT, mini_llvm::mir::Immediate>
40
struct
std::formatter<ImmediateT> {
41
constexpr
auto
parse
(std::format_parse_context &ctx) {
42
return
ctx.begin();
43
}
44
45
template
<
typename
FormatContext>
46
auto
format
(
const
ImmediateT &imm, FormatContext &ctx)
const
{
47
return
std::format_to(ctx.out(),
"{}"
, imm.format());
48
}
49
};
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
mini_llvm::mir::Immediate::operator=
Immediate & operator=(const Immediate &)=delete
mini_llvm::mir::Immediate::Immediate
Immediate()=default
mini_llvm::mir::Immediate::Immediate
Immediate(const Immediate &)=delete
mini_llvm::mir::Immediate::value
virtual int64_t value() const =0
mini_llvm::mir::Immediate::Immediate
Immediate(Immediate &&)=delete
mini_llvm::mir::Immediate::format
std::string format() const
Definition
Immediate.h:28
mini_llvm::mir::Immediate::~Immediate
virtual ~Immediate()=default
mini_llvm::mir::Immediate::operator=
Immediate & operator=(Immediate &&)=delete
mini_llvm::mir::Immediate::clone
virtual std::unique_ptr< Immediate > clone() const =0
mini_llvm::mir
Definition
BasicBlock.h:22
std::formatter< ImmediateT >::format
auto format(const ImmediateT &imm, FormatContext &ctx) const
Definition
Immediate.h:46
std::formatter< ImmediateT >::parse
constexpr auto parse(std::format_parse_context &ctx)
Definition
Immediate.h:41
include
mini-llvm
mir
Immediate.h
Generated by
1.17.0