summaryrefslogtreecommitdiffhomepage
path: root/include/ocl/simd/simd.hpp
blob: 92bb7133c75d40092f8ab7447035efb0f2f00d7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * File: simd/simd.hpp
 * Purpose: SIMD C++ library.
 * Author: Amlal El Mahrouss (amlal@nekernel.org)
 * Copyright 2025, Amlal El Mahrouss, licensed under the BSL 1.0 license.
 */

#pragma once

#include <core/config.hpp>

/// @author Amlal El Mahrouss
/// @brief Basic SIMD processor.

namespace ocl::simd
{
	template <typename backend_type>
	class real_type
	{
	private:
		backend_type backend_;

		enum opcode
		{
			bad = 0,
			add,
			mul,
			div,
			invalid = 0xfff,
		};

	public:
		real_type()			 = default;
		virtual ~real_type() = default;

		real_type& operator=(const real_type&) = delete;
		real_type(const real_type&)			   = delete;

		typename backend_type::register_type& call(const opcode& op, typename backend_type::register_type& lhs, typename backend_type::register_type& rhs)
		{
			switch (op)
			{
			case add:
				return backend_.add(lhs, rhs);
			case mul:
				return backend_.mul(lhs, rhs);
			case div:
				return backend_.div(lhs, rhs);
			default:
				break;
			}

			return backend_.is_bad();
		}

		std::basic_string<char> isa()
		{
			return backend_.isa();
		}
	};
} // namespace ocl::simd