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
{
enum class abi
enum class isa
{
itanium,
msvc,
armv8,
x86_64,
aarch64,
};
enum class platform
{
linux,
windows,
macos,
};
struct abi
{
jit::isa isa;
jit::platform platform;
};
abi host_abi();

View file

@ -3,7 +3,7 @@
#include <pslang/jit/jit.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);

View file

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

View file

@ -5,15 +5,27 @@ namespace pslang::jit
abi host_abi()
{
#if defined(__x86_64__)
return abi::itanium;
#elif defined(__ARM64_ARCH_8__)
return abi::armv8;
#elif defined(_M_AMD64)
return abi::msvs;
abi result;
#if defined(__x86_64__) || defined(_M_X64)
result.isa = isa::x86_64;
#elif defined(__aarch64__) || defined(_M_ARM64)
result.isa = isa::aarch64;
#else
#error Unknown host ABI
#error Unknown host ISA
#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/aarch64/instruction_builder.hpp>
#include <pslang/jit/arch/macos_aarch64/compiler.hpp>
#include <pslang/jit/arch/macos_aarch64/instruction_builder.hpp>
#include <pslang/ir/node.hpp>
#include <pslang/ir/compiler.hpp>
#include <pslang/ast/type.hpp>
@ -9,7 +9,7 @@
#include <sstream>
namespace pslang::jit::aarch64
namespace pslang::jit::macos_aarch64
{
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>
namespace pslang::jit::aarch64
namespace pslang::jit::macos_aarch64
{
template <typename T>

View file

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