From bb46b236ad72934469060706afe7cc3708cc299b Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss <113760121+Amlal-ElMahrouss@users.noreply.github.com> Date: Tue, 19 Mar 2024 21:03:14 +0100 Subject: Compiler(Secret): Major commit What is needed: - Finish AMD64 assembler. - Work on a C++ compiler. - Work on a installer wizard. --- Private/Doxyfile | 2 +- Private/Frontend/Compiler/compiler_command.d | 42 +++++++++------------------- Private/Frontend/Compiler/compiler_start.d | 12 ++++---- Private/Frontend/Compiler/makefile | 2 +- Private/Frontend/Compiler/man/mpcc.8 | 2 +- Private/Toolchain/bin/Source/hello_world.64x | 2 +- Private/Toolchain/cc.cc | 4 +-- Private/Toolchain/ccplus.cc | 18 ++++++------ Private/Tools/install.d | 2 +- Private/Tools/makefile | 2 +- ReadMe.md | 6 ++-- 11 files changed, 38 insertions(+), 56 deletions(-) diff --git a/Private/Doxyfile b/Private/Doxyfile index ebbad25..d6937c5 100644 --- a/Private/Doxyfile +++ b/Private/Doxyfile @@ -54,7 +54,7 @@ PROJECT_NUMBER = 1.9.1 # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = "MP-UX Compiler Collection" +PROJECT_BRIEF = "MultiProcessor Compiler Collection" # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 diff --git a/Private/Frontend/Compiler/compiler_command.d b/Private/Frontend/Compiler/compiler_command.d index ecc3e1e..ef84919 100644 --- a/Private/Frontend/Compiler/compiler_command.d +++ b/Private/Frontend/Compiler/compiler_command.d @@ -1,7 +1,7 @@ /* * ======================================================== * - * MP-UX C Compiler + * MultiProcessor C Compiler * Copyright Mahrouss Logic, all rights reserved. * * ======================================================== @@ -28,32 +28,16 @@ public class Platform { public static string getIncludePath() { - import core.stdc.stdlib; - import std.string; - import std.conv; - import std.path; - - string pathHome = expandTilde("~"); - pathHome ~= "/mp-ux/libc/"; - - return pathHome; + return "C:/SDK/Public/Kits/"; } public static string getKernelPath() { - import core.stdc.stdlib; - import std.string; - import std.conv; - import std.path; - - string pathHome = expandTilde("~"); - pathHome ~= "/mp-ux/mp-ux/"; - - return pathHome; + return "C:/SDK/Private/Kits/"; } } -public class CompileCommand +public class CompileCommandAMD64 { public void compile(string includePath, string[] files, bool is_lib, string output, bool compile_only) { @@ -67,23 +51,23 @@ public class CompileCommand import std.datetime; - string input = "/usr/local/bin/bin/cpp"; + string input = "bpp"; string[] arr_macros = CompilerMacroHelpers.getStandardMacros(); foreach (string macro_name; arr_macros) { - input ~= " --define "; + input ~= " -define "; input ~= macro_name; input ~= "1 "; input ~= " "; } - input ~= "--define __FILE__ " ~ file; + input ~= "-define __FILE__ " ~ file; input ~= " "; - input ~= "--define __DATE__ " ~ Clock.currTime(UTC()).toString(); + input ~= "-define __DATE__ " ~ Clock.currTime(UTC()).toString(); input ~= " "; - input ~= "--working-dir ./ --include-dir " ~ includePath ~ " " ~ file; + input ~= "-working-dir ./ -include-dir " ~ includePath ~ " " ~ file; mpcc_summon_executable(input); @@ -105,12 +89,12 @@ public class CompileCommand ext ~= ch; } - mpcc_summon_executable("/usr/local/bin/bin/ccplus --asm=masm -fmax-exceptions 10 --compiler=vanhalen " ~ + mpcc_summon_executable("ccplus -fmax-exceptions 10 " ~ file ~ ".pp"); - assembly_source ~= ".64x"; + assembly_source ~= ".s"; - mpcc_summon_executable("/usr/local/bin/bin/64asm " ~ assembly_source); + mpcc_summon_executable("i64asm " ~ assembly_source); } if (compile_only) @@ -147,6 +131,6 @@ public class CompileCommand output_object ~= " -o "; output_object ~= output; - mpcc_summon_executable("/usr/local/bin/bin/ld " ~ obj ~ output_object); + mpcc_summon_executable("link -amd64 " ~ obj ~ output_object); } } diff --git a/Private/Frontend/Compiler/compiler_start.d b/Private/Frontend/Compiler/compiler_start.d index 002bb16..300beac 100644 --- a/Private/Frontend/Compiler/compiler_start.d +++ b/Private/Frontend/Compiler/compiler_start.d @@ -1,7 +1,7 @@ /* * ======================================================== * - * MP-UX C Compiler + * MultiProcessor C Compiler * Copyright Mahrouss Logic, all rights reserved. * * ======================================================== @@ -24,8 +24,6 @@ void mpcc_summon_manual(string path) import std.file; string base = "man "; - base ~= "/usr/local/bin/man/"; - string extension = ".8"; core.stdc.stdlib.system(toStringz(base ~ path ~ extension)); @@ -38,7 +36,7 @@ void main(string[] args) bool shared_library = false; bool compile_only = false; bool kernel_driver = false; - string output_file = "a.out"; + string output_file = "Executable.exe"; size_t index = 0UL; string[255] args_list; @@ -55,7 +53,7 @@ void main(string[] args) } else if (arg == "-dialect") { - mpcc_summon_executable("/usr/local/bin/bin/ccplus --asm=masm --compiler=vanhalen --dialect"); + mpcc_summon_executable("ccplus --pdialect"); return; } else if (arg == "--help" || @@ -78,7 +76,7 @@ void main(string[] args) } else if (arg == "-shared") { - output_file = "a.lib"; + output_file = "Library.lib"; shared_library = true; continue; } @@ -103,7 +101,7 @@ void main(string[] args) return; } - auto compiler = new CompileCommand(); + auto compiler = new CompileCommandAMD64(); if (kernel_driver) compiler.compile(Platform.getKernelPath(), args_list, shared_library, output_file, compile_only); diff --git a/Private/Frontend/Compiler/makefile b/Private/Frontend/Compiler/makefile index d0eeb3b..8a03fd0 100644 --- a/Private/Frontend/Compiler/makefile +++ b/Private/Frontend/Compiler/makefile @@ -1,7 +1,7 @@ # # ======================================================== # - # MP-UX C Compiler + # MultiProcessor C Compiler # Copyright Mahrouss Logic, all rights reserved. # # ======================================================== diff --git a/Private/Frontend/Compiler/man/mpcc.8 b/Private/Frontend/Compiler/man/mpcc.8 index a573128..370a49a 100644 --- a/Private/Frontend/Compiler/man/mpcc.8 +++ b/Private/Frontend/Compiler/man/mpcc.8 @@ -1,6 +1,6 @@ .Dd Jan 21, 2024 .Dt mpcc 1.11 -.Os MP-UX +.Os MultiProcessor .Sh NAME .Nm mpcc diff --git a/Private/Toolchain/bin/Source/hello_world.64x b/Private/Toolchain/bin/Source/hello_world.64x index b352538..c218bee 100644 --- a/Private/Toolchain/bin/Source/hello_world.64x +++ b/Private/Toolchain/bin/Source/hello_world.64x @@ -1,5 +1,5 @@ # Path: Source/hello_world.cxx -# Language: RISC 64x0 MP-UX Assembly (Generated from C++) +# Language: RISC 64x0 MultiProcessor Assembly (Generated from C++) # Build Date: 2024-1-27 export .text _CppZ_MPUX_int@main diff --git a/Private/Toolchain/cc.cc b/Private/Toolchain/cc.cc index 8d084a4..e447db8 100644 --- a/Private/Toolchain/cc.cc +++ b/Private/Toolchain/cc.cc @@ -29,7 +29,7 @@ // TODO: support structs and ., -> /* C driver */ -/* This is part of MP-UX C SDK. */ +/* This is part of MultiProcessor C SDK. */ /* (c) Mahrouss Logic */ // @author Amlal El Mahrouss (amlel) @@ -1107,7 +1107,7 @@ class AssemblyMountpointCLang final : public CompilerKit::AssemblyMountpoint { (*kState.fOutputAssembly) << "# Path: " << src_file << "\n"; (*kState.fOutputAssembly) - << "# Language: MP-UX Assembly (Generated from C)\n"; + << "# Language: MultiProcessor Assembly (Generated from C)\n"; (*kState.fOutputAssembly) << "# Build Date: " << fmt << "\n\n"; ParserKit::SyntaxLeafList syntax; diff --git a/Private/Toolchain/ccplus.cc b/Private/Toolchain/ccplus.cc index a7b1ada..c52536e 100644 --- a/Private/Toolchain/ccplus.cc +++ b/Private/Toolchain/ccplus.cc @@ -29,7 +29,7 @@ #define kOk 0 /* Mahrouss Logic C++ driver */ -/* This is part of MP-UX C++ SDK. */ +/* This is part of MultiProcessor C++ SDK. */ /* (c) Mahrouss Logic */ // @author Amlal El Mahrouss (amlel) @@ -276,7 +276,8 @@ class AssemblyMountpointClang final : public CompilerKit::AssemblyMountpoint { (*kState.fOutputAssembly) << "# Language: AMD64 HCore Assembly (Generated from C++)\n"; (*kState.fOutputAssembly) << "# Build Date: " << fmt << "\n\n"; - (*kState.fOutputAssembly) << "@bits 64 " << "\n\n"; + (*kState.fOutputAssembly) << "@bits 64 " + << "\n\n"; ParserKit::SyntaxLeafList syntax; @@ -513,8 +514,7 @@ class AssemblyMountpointClang final : public CompilerKit::AssemblyMountpoint { ln[i] == '-' || ln[i] == '*' || ln[i] == '|' || ln[i] == '&' || ln[i] == '&' || ln[i] == '|' || ln[i] == ';') { - val.replace(val.find(val_reg), val_reg.size(), - "rcx"); + val.replace(val.find(val_reg), val_reg.size(), "rcx"); val_reg.clear(); ++reg_cnt; @@ -559,8 +559,8 @@ class AssemblyMountpointClang final : public CompilerKit::AssemblyMountpoint { ///////////////////////////////////////////////////////////////////////////////////////// -static void cxx_print_help() { - kSplashCxx(); +static void cxx_print_help() { + kSplashCxx(); kPrintF("%s", "No help available.\r\n"); kPrintF("%s", "www.el-mahrouss-logic.com"); } @@ -603,8 +603,8 @@ MPCC_MODULE(CompilerCPlusPlus) { kKeywords.emplace_back("double"); kKeywords.emplace_back("unsigned"); kKeywords.emplace_back("__attribute__"); - kKeywords.emplace_back("__pef_export"); - kKeywords.emplace_back("__pef_import"); + kKeywords.emplace_back("_Import"); + kKeywords.emplace_back("_Export"); kKeywords.emplace_back("namespace"); kKeywords.emplace_back("while"); kKeywords.emplace_back("sizeof"); @@ -708,7 +708,7 @@ MPCC_MODULE(CompilerCPlusPlus) { detail::print_error(argv_i + " is not a valid C++ source.\n", "ccplus"); } - return 1; + return 1; } if (kFactory.Compile(argv_i, kMachine) != kOk) return -1; diff --git a/Private/Tools/install.d b/Private/Tools/install.d index c121f72..48629fe 100644 --- a/Private/Tools/install.d +++ b/Private/Tools/install.d @@ -1,7 +1,7 @@ /* * ======================================================== * - * MP-UX C Compiler + * MultiProcessor C Compiler * Copyright Mahrouss Logic, all rights reserved. * * ======================================================== diff --git a/Private/Tools/makefile b/Private/Tools/makefile index e7e3cc7..07b2b6b 100644 --- a/Private/Tools/makefile +++ b/Private/Tools/makefile @@ -1,7 +1,7 @@ # # ======================================================== # - # MP-UX Tools + # MultiProcessor Tools # Copyright Mahrouss Logic, all rights reserved. # # ======================================================== diff --git a/ReadMe.md b/ReadMe.md index 8132de7..8f1165b 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,13 +1,13 @@ # MP-CC -## MP-UX Compiler Collection. +## MultiProcessor Compiler Collection. Start by cloning the repo: ``` -git clone git@github.com:Mahrouss-Logic/mp-cc.git +git clone git@gitlab.com:Mahrouss-Logic/mp-cc.git ``` -Then go to `Private/Toolchain/` And execute: +Then go to `Private/Toolchain/` and execute: ``` make all -- cgit v1.2.3