Aarch64 JIT: check function pointer support
This commit is contained in:
parent
30b88d4add
commit
c7e0232b15
5 changed files with 25 additions and 10 deletions
|
|
@ -173,9 +173,10 @@ int main(int argc, char ** argv)
|
||||||
|
|
||||||
{
|
{
|
||||||
// TODO: remove, testing-only code; should execute entry point instead
|
// TODO: remove, testing-only code; should execute entry point instead
|
||||||
auto offset = pcontext.symbols.at("foo");
|
auto offset = pcontext.symbols.at("add_or_sub");
|
||||||
auto fptr = (uint32_t(*)(uint32_t))(executable.data.get() + offset);
|
using type = std::uint32_t(*)(std::uint32_t);
|
||||||
auto x = fptr(10u);
|
auto fptr = (type(*)(bool))(executable.data.get() + offset);
|
||||||
|
auto x = fptr(false)(10u);
|
||||||
std::cout << "Result: " << std::boolalpha << x << std::endl;
|
std::cout << "Result: " << std::boolalpha << x << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
func foo(x : u32) -> u32:
|
func add1(x : u32) -> u32:
|
||||||
if x == 0u:
|
return x + 1u
|
||||||
return 42u
|
|
||||||
return 1u + bar(x - 1u)
|
|
||||||
|
|
||||||
func bar(x : u32) -> u32:
|
func sub1(x : u32) -> u32:
|
||||||
return foo(x)
|
return x - 1u
|
||||||
|
|
||||||
|
func add_or_sub(add : bool) -> (u32 -> u32):
|
||||||
|
if add:
|
||||||
|
return add1
|
||||||
|
else:
|
||||||
|
return sub1
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ namespace pslang::types
|
||||||
bool is_floating_point_type(type const & type);
|
bool is_floating_point_type(type const & type);
|
||||||
bool is_numeric_type(type const & type);
|
bool is_numeric_type(type const & type);
|
||||||
bool is_builtin_type(type const & type);
|
bool is_builtin_type(type const & type);
|
||||||
|
bool is_function_type(type const & type);
|
||||||
|
|
||||||
std::size_t builtin_type_size(type const & type);
|
std::size_t builtin_type_size(type const & type);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,13 @@ namespace pslang::types
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_function_type(type const & type)
|
||||||
|
{
|
||||||
|
if (std::get_if<function_type>(&type))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::size_t builtin_type_size(type const & type)
|
std::size_t builtin_type_size(type const & type)
|
||||||
{
|
{
|
||||||
if (std::get_if<unit_type>(&type))
|
if (std::get_if<unit_type>(&type))
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@ Future plans:
|
||||||
* Extension functions: operator overloading, destructors, iterators & for loop, move assignment (replaces built-in copy)
|
* Extension functions: operator overloading, destructors, iterators & for loop, move assignment (replaces built-in copy)
|
||||||
* Metaprogramming: assigning types to variables (of type `type`), functions can take `type` as regular arguments and return `type`, all type computations are compile-time only
|
* Metaprogramming: assigning types to variables (of type `type`), functions can take `type` as regular arguments and return `type`, all type computations are compile-time only
|
||||||
|
|
||||||
|
Aarch64 compiler:
|
||||||
|
* Struct values
|
||||||
|
|
||||||
Backlog:
|
Backlog:
|
||||||
* Mutually recursive functions
|
|
||||||
* Mutually recursive structs (relevant only with pointers)
|
* Mutually recursive structs (relevant only with pointers)
|
||||||
* Empty array expression
|
* Empty array expression
|
||||||
* Calling functions as methods
|
* Calling functions as methods
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue