diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-28 14:33:48 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-28 14:33:48 +0200 |
| commit | 46badbe70a36bb3cb5d86bd9f33aa5481c9709b9 (patch) | |
| tree | 33f3759845a25c51cea5d92177a3f7ebd269f984 /dev/LibCompiler/src | |
| parent | 0965112fb81ef3e04010197f68f743c98a7611ba (diff) | |
feat!: update the kernel codegen to output bit width and origin.
refactor!: refactor codebase, breaking changes.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler/src')
| -rw-r--r-- | dev/LibCompiler/src/Backend/Assembler32x0.cc | 20 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Backend/Assembler64x0.cc | 9 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Backend/AssemblerAMD64.cc | 6 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Backend/AssemblerARM64.cc | 6 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Backend/AssemblerPowerPC.cc | 6 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Frontend/CompilerCPlusPlusAMD64.cc (renamed from dev/LibCompiler/src/Frontend/CPlusPlusCompilerAMD64.cc) | 11 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Linkers/DynamicLinkerPEF.cc | 2 |
7 files changed, 30 insertions, 30 deletions
diff --git a/dev/LibCompiler/src/Backend/Assembler32x0.cc b/dev/LibCompiler/src/Backend/Assembler32x0.cc index 683b866..b7ff321 100644 --- a/dev/LibCompiler/src/Backend/Assembler32x0.cc +++ b/dev/LibCompiler/src/Backend/Assembler32x0.cc @@ -17,26 +17,15 @@ ///////////////////////////////////////////////////////////////////////////////////////// +#ifndef __ASM_NEED_32x0__ #define __ASM_NEED_32x0__ 1 +#endif #include <LibCompiler/AE.h> #include <LibCompiler/Backend/32x0.h> #include <LibCompiler/Frontend.h> #include <LibCompiler/PEF.h> - -///////////////////// - -// ANSI ESCAPE CODES - -///////////////////// - -#define kBlank "\e[0;30m" -#define kRed "\e[0;31m" -#define kWhite "\e[0;97m" -#define kYellow "\e[0;33m" - -#define kStdOut (std::cout << kWhite) -#define kStdErr (std::cout << kRed) +#include <LibCompiler/Util/CompilerUtils.h> ///////////////////////////////////////////////////////////////////////////////////////// @@ -45,5 +34,6 @@ ///////////////////////////////////////////////////////////////////////////////////////// LIBCOMPILER_MODULE(NEAssemblerMain32000) { - return 0; + LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler); + return EXIT_SUCCESS; } diff --git a/dev/LibCompiler/src/Backend/Assembler64x0.cc b/dev/LibCompiler/src/Backend/Assembler64x0.cc index fb96708..765bea2 100644 --- a/dev/LibCompiler/src/Backend/Assembler64x0.cc +++ b/dev/LibCompiler/src/Backend/Assembler64x0.cc @@ -17,13 +17,15 @@ ///////////////////////////////////////////////////////////////////////////////////////// +#ifndef __ASM_NEED_64x0__ #define __ASM_NEED_64x0__ 1 +#endif #include <LibCompiler/AE.h> #include <LibCompiler/Backend/64x0.h> #include <LibCompiler/Frontend.h> #include <LibCompiler/PEF.h> -#include <LibCompiler/Util/LCClUtils.h> +#include <LibCompiler/Util/CompilerUtils.h> #include <algorithm> #include <filesystem> #include <fstream> @@ -38,8 +40,7 @@ static char kOutputArch = LibCompiler::kPefArch64000; -/// @note The 64x0 is VLSIW, so we need to jump to 4 bytes. -constexpr auto k64x0IPAlignment = 0x4U; +constexpr auto k64x0IPAlignment = 0x1U; static std::size_t kCounter = 1UL; @@ -67,7 +68,7 @@ static bool asm_read_attributes(std::string line); ///////////////////////////////////////////////////////////////////////////////////////// LIBCOMPILER_MODULE(AssemblerMain64x0) { - ::signal(SIGSEGV, Detail::drvi_crash_handler); + LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler); for (size_t i = 1; i < argc; ++i) { if (argv[i][0] == '-') { diff --git a/dev/LibCompiler/src/Backend/AssemblerAMD64.cc b/dev/LibCompiler/src/Backend/AssemblerAMD64.cc index e9f3ad5..6551743 100644 --- a/dev/LibCompiler/src/Backend/AssemblerAMD64.cc +++ b/dev/LibCompiler/src/Backend/AssemblerAMD64.cc @@ -21,7 +21,9 @@ ///////////////////////////////////////////////////////////////////////////////////////// +#ifndef __ASM_NEED_AMD64__ #define __ASM_NEED_AMD64__ 1 +#endif #define kAssemblerPragmaSymStr "#" #define kAssemblerPragmaSym '#' @@ -74,7 +76,7 @@ static const std::string kUndefinedSymbol = ":UndefinedSymbol:"; // \brief forward decl. static bool asm_read_attributes(std::string line); -#include <LibCompiler/Util/LCAsmUtils.h> +#include <LibCompiler/Util/AsmUtils.h> ///////////////////////////////////////////////////////////////////////////////////////// @@ -85,7 +87,7 @@ static bool asm_read_attributes(std::string line); LIBCOMPILER_MODULE(AssemblerMainAMD64) { //////////////// CPU OPCODES BEGIN //////////////// - ::signal(SIGSEGV, Detail::drvi_crash_handler); + LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler); std::string opcodes_jump[kJumpLimit] = {"ja", "jae", "jb", "jbe", "jc", "je", "jg", "jge", "jl", "jle", "jna", "jnae", "jnb", "jnbe", "jnc", "jne", diff --git a/dev/LibCompiler/src/Backend/AssemblerARM64.cc b/dev/LibCompiler/src/Backend/AssemblerARM64.cc index 8fad6b5..142dcc7 100644 --- a/dev/LibCompiler/src/Backend/AssemblerARM64.cc +++ b/dev/LibCompiler/src/Backend/AssemblerARM64.cc @@ -15,14 +15,16 @@ ///////////////////////////////////////////////////////////////////////////////////////// +#ifndef __ASM_NEED_ARM64__ #define __ASM_NEED_ARM64__ 1 +#endif #include <LibCompiler/AE.h> #include <LibCompiler/Backend/Aarch64.h> #include <LibCompiler/ErrorID.h> #include <LibCompiler/Frontend.h> #include <LibCompiler/PEF.h> -#include <LibCompiler/Util/LCAsmUtils.h> +#include <LibCompiler/Util/AsmUtils.h> #include <LibCompiler/Version.h> #include <algorithm> #include <filesystem> @@ -71,7 +73,7 @@ static bool asm_read_attributes(std::string line); ///////////////////////////////////////////////////////////////////////////////////////// LIBCOMPILER_MODULE(AssemblerMainARM64) { - ::signal(SIGSEGV, Detail::drvi_crash_handler); + LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler); for (size_t i = 1; i < argc; ++i) { if (argv[i][0] == '-') { diff --git a/dev/LibCompiler/src/Backend/AssemblerPowerPC.cc b/dev/LibCompiler/src/Backend/AssemblerPowerPC.cc index 86a70b9..3134748 100644 --- a/dev/LibCompiler/src/Backend/AssemblerPowerPC.cc +++ b/dev/LibCompiler/src/Backend/AssemblerPowerPC.cc @@ -15,14 +15,16 @@ ///////////////////////////////////////////////////////////////////////////////////////// +#ifndef __ASM_NEED_PPC__ #define __ASM_NEED_PPC__ 1 +#endif #include <LibCompiler/AE.h> #include <LibCompiler/Backend/PowerPC.h> #include <LibCompiler/ErrorID.h> #include <LibCompiler/Frontend.h> #include <LibCompiler/PEF.h> -#include <LibCompiler/Util/LCAsmUtils.h> +#include <LibCompiler/Util/AsmUtils.h> #include <LibCompiler/Version.h> #include <algorithm> #include <filesystem> @@ -71,7 +73,7 @@ static bool asm_read_attributes(std::string line); ///////////////////////////////////////////////////////////////////////////////////////// LIBCOMPILER_MODULE(AssemblerMainPower64) { - ::signal(SIGSEGV, Detail::drvi_crash_handler); + LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler); for (size_t i = 1; i < argc; ++i) { if (argv[i][0] == '-') { diff --git a/dev/LibCompiler/src/Frontend/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/Frontend/CompilerCPlusPlusAMD64.cc index 217f86b..df9035d 100644 --- a/dev/LibCompiler/src/Frontend/CPlusPlusCompilerAMD64.cc +++ b/dev/LibCompiler/src/Frontend/CompilerCPlusPlusAMD64.cc @@ -9,7 +9,6 @@ /// BUGS: 1 -#include "LibCompiler/Defines.h" #define kPrintF printf #define kExitOK (EXIT_SUCCESS) @@ -20,7 +19,7 @@ #include <LibCompiler/Backend/X64.h> #include <LibCompiler/Frontend.h> #include <LibCompiler/UUID.h> -#include <LibCompiler/Util/LCClUtils.h> +#include <LibCompiler/Util/CompilerUtils.h> /* NeKernel C++ Compiler Driver */ /* This is part of the LibCompiler. */ @@ -126,7 +125,8 @@ class CompilerFrontendCPlusPlus final LC_COMPILER_FRONTEND { LIBCOMPILER_COPY_DEFAULT(CompilerFrontendCPlusPlus); - LibCompiler::SyntaxLeafList::SyntaxLeaf Compile(const LibCompiler::STLString text, LibCompiler::STLString file) override; + LibCompiler::SyntaxLeafList::SyntaxLeaf Compile(const LibCompiler::STLString text, + LibCompiler::STLString file) override; const char* Language() override; }; @@ -736,6 +736,9 @@ class AssemblyCPlusPlusInterface final LC_ASSEMBLY_INTERFACE { LibCompiler::STLString line_source; + out_fp << "#bits 64\n"; + out_fp << "#org " << kOrigin << "\n\n"; + while (std::getline(src_fp, line_source)) { out_fp << kCompilerFrontend->Compile(line_source, src).fUserValue; } @@ -817,7 +820,7 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) { kCompilerFrontend = new CompilerFrontendCPlusPlus(); kFactory.Mount(new AssemblyCPlusPlusInterface()); - ::signal(SIGSEGV, Detail::drvi_crash_handler); + LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler); for (auto index = 1UL; index < argc; ++index) { if (!argv[index]) break; diff --git a/dev/LibCompiler/src/Linkers/DynamicLinkerPEF.cc b/dev/LibCompiler/src/Linkers/DynamicLinkerPEF.cc index edfd47a..820b06d 100644 --- a/dev/LibCompiler/src/Linkers/DynamicLinkerPEF.cc +++ b/dev/LibCompiler/src/Linkers/DynamicLinkerPEF.cc @@ -35,7 +35,7 @@ #include <LibCompiler/AE.h> //! LibCompiler utils. -#include <LibCompiler/Util/LCClUtils.h> +#include <LibCompiler/Util/CompilerUtils.h> //! I/O stream from std c++ #include <iostream> |
