Split jit::abi into isa & platform enums, rename arch/aarch64 -> arch/macos_aarch64 backend

This commit is contained in:
Nikita Lisitsa 2026-07-27 17:36:02 +03:00
parent 893aa5d979
commit 88b215e5cd
7 changed files with 57 additions and 26 deletions

View file

@ -3,11 +3,23 @@
namespace pslang::jit namespace pslang::jit
{ {
enum class abi enum class isa
{ {
itanium, x86_64,
msvc, aarch64,
armv8, };
enum class platform
{
linux,
windows,
macos,
};
struct abi
{
jit::isa isa;
jit::platform platform;
}; };
abi host_abi(); abi host_abi();

View file

@ -3,7 +3,7 @@
#include <pslang/jit/jit.hpp> #include <pslang/jit/jit.hpp>
#include <pslang/ir/compiler.hpp> #include <pslang/ir/compiler.hpp>
namespace pslang::jit::aarch64 namespace pslang::jit::macos_aarch64
{ {
void compile(program_context & pcontext, ir::module_context const & mcontext); void compile(program_context & pcontext, ir::module_context const & mcontext);

View file

@ -3,7 +3,7 @@
#include <vector> #include <vector>
#include <cstdint> #include <cstdint>
namespace pslang::jit::aarch64 namespace pslang::jit::macos_aarch64
{ {
struct instruction_builder struct instruction_builder

View file

@ -5,15 +5,27 @@ namespace pslang::jit
abi host_abi() abi host_abi()
{ {
#if defined(__x86_64__) abi result;
return abi::itanium;
#elif defined(__ARM64_ARCH_8__) #if defined(__x86_64__) || defined(_M_X64)
return abi::armv8; result.isa = isa::x86_64;
#elif defined(_M_AMD64) #elif defined(__aarch64__) || defined(_M_ARM64)
return abi::msvs; result.isa = isa::aarch64;
#else #else
#error Unknown host ABI #error Unknown host ISA
#endif #endif
#if defined(__linux__)
result.platform = platform::linux;
#elif defined(_WIN32) || defined(_WIN64)
result.platform = platform::windows;
#elif defined(__APPLE__)
result.platform = platform::macos;
#else
#error Unknown host platform
#endif
return result;
} }
} }

View file

@ -1,5 +1,5 @@
#include <pslang/jit/arch/aarch64/compiler.hpp> #include <pslang/jit/arch/macos_aarch64/compiler.hpp>
#include <pslang/jit/arch/aarch64/instruction_builder.hpp> #include <pslang/jit/arch/macos_aarch64/instruction_builder.hpp>
#include <pslang/ir/node.hpp> #include <pslang/ir/node.hpp>
#include <pslang/ir/compiler.hpp> #include <pslang/ir/compiler.hpp>
#include <pslang/ast/type.hpp> #include <pslang/ast/type.hpp>
@ -9,7 +9,7 @@
#include <sstream> #include <sstream>
namespace pslang::jit::aarch64 namespace pslang::jit::macos_aarch64
{ {
namespace namespace

View file

@ -1,8 +1,8 @@
#include <pslang/jit/arch/aarch64/instruction_builder.hpp> #include <pslang/jit/arch/macos_aarch64/instruction_builder.hpp>
#include <format> #include <format>
namespace pslang::jit::aarch64 namespace pslang::jit::macos_aarch64
{ {
template <typename T> template <typename T>

View file

@ -1,5 +1,5 @@
#include <pslang/jit/jit.hpp> #include <pslang/jit/jit.hpp>
#include <pslang/jit/arch/aarch64/compiler.hpp> #include <pslang/jit/arch/macos_aarch64/compiler.hpp>
#include <stdexcept> #include <stdexcept>
@ -8,14 +8,21 @@ namespace pslang::jit
void compile(program_context & pcontext, ir::module_context const & mcontext) void compile(program_context & pcontext, ir::module_context const & mcontext)
{ {
switch (pcontext.abi) switch (pcontext.abi.platform)
{ {
case abi::itanium: case platform::linux:
throw std::runtime_error("Itanium ABI JIT not implemented"); throw std::runtime_error("Linux JIT compilation not supported");
case abi::msvc: case platform::windows:
throw std::runtime_error("MSVC ABI JIT not implemented"); throw std::runtime_error("Windows JIT compilation not supported");
case abi::armv8: case platform::macos:
aarch64::compile(pcontext, mcontext); switch (pcontext.abi.isa)
{
case isa::x86_64:
throw std::runtime_error("macOS x86_64 JIT compilation not supported");
case isa::aarch64:
macos_aarch64::compile(pcontext, mcontext);
break;
}
break; break;
} }
} }