TPDE
Loading...
Searching...
No Matches
Assembler.hpp
1// SPDX-FileCopyrightText: 2025 Contributors to TPDE <https://tpde.org>
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4#pragma once
5
6#include "IRAdaptor.hpp"
7#include "base.hpp"
8
9#ifdef ARG
10 #error ARG is used as a temporary preprocessor macro
11#endif
12
13#define ARG(x) std::declval<x>()
14
15namespace tpde {
16
17template <typename T, IRAdaptor Adaptor>
18concept Assembler = requires(T a) {
19 /// We need to be able to reference function and data objects
20 typename T::SymRef;
21
22 /// For referencing local symbols we use a Label construct
23 typename T::Label;
24
25 /// Initialize
26 /// args: generate_object
27 { T(ARG(bool)) };
28
29 /// Create a (pending) label
30 { a.label_create() } -> std::same_as<typename T::Label>;
31 { a.label_is_pending(ARG(typename T::Label)) } -> std::convertible_to<bool>;
32 { a.label_offset(ARG(typename T::Label)) } -> std::convertible_to<u32>;
33 { a.label_place(ARG(typename T::Label)) };
34
35 /// Predefine a function symbol
36 /// args: func_link_name, local, weak
37 {
38 a.sym_predef_func(ARG(std::string_view), ARG(bool), ARG(bool))
39 } -> std::same_as<typename T::SymRef>;
40
41 /// Add an undefined symbol
42 /// args: name, local, weak
43 { a.sym_add_undef(ARG(std::string_view), ARG(bool), ARG(bool)) };
44};
45
46} // namespace tpde
47
48#undef ARG