Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add arm64 backend to FunctionParameters2 branch #14

Merged
merged 6 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/arrays.cal
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ include "std/io.cal"
include "std/array.cal"

let Array myArray
[u16 1 2 3 4 5] myArray a<
[u16 1 2 3 4 5] &myArray a<

0 myArray a@ printdec 10 printch
1 myArray a@ printdec 10 printch
0 &myArray a@ printdec 10 printch
1 &myArray a@ printdec 10 printch

100 2 myArray a!
2 myArray a@ printdec 10 printch
100 2 &myArray a!
2 &myArray a@ printdec 10 printch
4 changes: 2 additions & 2 deletions examples/compare_strings.cal
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ let Array str2

&str1 &str2 a= printdec new_line

"Hi" str2 a<
"Hi" &str2 a<
&str1 &str2 a= printdec new_line

"Greetings" str1 a<
"Greetings" &str1 a<
&str1 &str2 a= printdec new_line

&str1 "Greetings" a= printdec new_line
4 changes: 0 additions & 4 deletions examples/literals.cal
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
include "cores/select.cal"
include "std/io.cal"

func new_line begin
13 printch 10 printch
end

# Hexadecimal - prints 16
0x10 printdec new_line

Expand Down
2 changes: 1 addition & 1 deletion examples/variables.cal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let cell myGlobal
func myFunc begin
let cell myVar
'A' -> myVar
myVa printch
myVar printch
end

myFunc
Expand Down
24 changes: 16 additions & 8 deletions examples/version.cal
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
include "cores/select.cal"
include "std/io.cal"

# will execute on RM86 backend
# Print a different message for each core

version RM86
"Hello, RM86!\n" printstr
end

# will execute on Linux86 backend
version Linux86
"Hello, Linux86!\n" printstr
version x86_64
"Hello, x86_64!\n" printstr
end

version arm64
"Hello, arm64!\n" printstr
end

version UXN
"Hello, Uxn!\n" printstr
end

# won't execute unless you set the Foo version
# Specify arbitrary versions to use them as compile-time flags
version Foo
"Hello, Foo!\n" printstr
"Foo is enabled :D\n" printstr
end

# will execute because Foo isn't set
# This one will run by default unless you set Foo
version not Foo
"Hello, not Foo!\n" printstr
"Foo is not enabled :(\n" printstr
end
2 changes: 1 addition & 1 deletion examples/writeFile.cal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if &file @ -2 = then
end

let Array str
"meow\n" str a<
"meow\n" &str a<

&file
&str Array.elements + @
Expand Down
24 changes: 23 additions & 1 deletion source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import std.stdio;
import std.string;
import std.process;
import std.algorithm;
import callisto.error;
import callisto.compiler;
import callisto.language;
import callisto.codeRemover;
import callisto.preprocessor;
import callisto.backends.lua;
import callisto.backends.uxn;
import callisto.backends.rm86;
import callisto.backends.arm64;
import callisto.backends.x86_64;

const static string usage = "
Expand Down Expand Up @@ -45,6 +47,7 @@ Flags:
Backends and their operating systems:
rm86 - Real mode x86, for bare-metal, dos
x86_64 - 64-bit x86, for bare-metal, linux
arm64 - 64-bit ARM, for linux
uxn - Varvara/Uxn
lua - Lua, uses subset CallistoScript

Expand Down Expand Up @@ -73,7 +76,7 @@ int main(string[] args) {
bool optimise;
string[] versions;
bool runFinal = true;
CompilerBackend backend = new BackendX86_64();
CompilerBackend backend;
bool doDebug;
bool debugParser;
bool exportSymbols;
Expand All @@ -85,6 +88,17 @@ int main(string[] args) {
bool assemblyLines;
string os = "DEFAULT";

// choose default backend
version (X86_64) {
backend = new BackendX86_64();
}
else version (AArch64) {
backend = new BackendARM64();
}
else {
WarnNoInfo("No default backend for your system");
}

for (size_t i = 1; i < args.length; ++ i) {
if (args[i][0] == '-') {
switch (args[i]) {
Expand Down Expand Up @@ -162,6 +176,10 @@ int main(string[] args) {
backend = new BackendX86_64();
break;
}
case "arm64": {
backend = new BackendARM64();
break;
}
case "uxn": {
backend = new BackendUXN();
break;
Expand Down Expand Up @@ -285,6 +303,10 @@ int main(string[] args) {
}
}

if (backend is null) {
ErrorNoInfo("No backend selected");
}

if (os == "DEFAULT") {
os = backend.defaultOS;
}
Expand Down
Loading
Loading