restracturing to platform

This commit is contained in:
veclav talica 2023-09-22 22:09:48 +05:00
parent 95e4d54042
commit 55c5f2dcf6
7 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
zig build-obj ./src/main.zig -fno-PIE -fno-PIC -fno-stack-check zig build-obj ./src/platform/cosmopolitan/main.zig -fno-PIE -fno-PIC -fno-stack-check --mod nmvm::src/nmvm.zig --deps nmvm
ld.bfd main.o -o zig-out/bin/nmvm.com.dbg -T extern/cosmopolitan/ape.lds extern/cosmopolitan/crt.o extern/cosmopolitan/ape-copy-self.o \ ld.bfd main.o -o zig-out/bin/nmvm.com.dbg -T extern/cosmopolitan/ape.lds extern/cosmopolitan/crt.o extern/cosmopolitan/ape-copy-self.o \
extern/cosmopolitan/cosmopolitan.a -z common-page-size=0x1000 -z max-page-size=0x1000 --gc-sections extern/cosmopolitan/cosmopolitan.a -z common-page-size=0x1000 -z max-page-size=0x1000 --gc-sections

View File

@ -4,4 +4,4 @@ cd ./extern
./get.sh ./get.sh
cd ../ cd ../
zig translate-c ./extern/cosmopolitan/cosmopolitan.h > ./src/cosmopolitan/cosmopolitan.zig zig translate-c ./extern/cosmopolitan/cosmopolitan.h > ./src/platform/cosmopolitan/cosmopolitan.zig

View File

@ -1,2 +1,2 @@
pub usingnamespace @import("x86-64/jedino-jedro.zig"); pub usingnamespace @import("x86-64/jedino-jedro.zig");
pub usingnamespace @import("x86-64/ve-sistema.zig"); pub usingnamespace @import("x86-64/zov/ve-sistema.zig");

View File

@ -1,12 +1,16 @@
//! ve sistema (.ve-sistema:x86-64) //! .zov.ve-sistema:x86-64
//! //!
//! Provides entry opcodes for System V calling convention, optimized for specific prototypes. //! Provides entry opcodes for System V calling convention, optimized for specific prototypes.
//! //!
// https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf // https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf
// todo: Provide opcode that would dynamically dispatch based on marshaled C prototypes,
// which will be sufficient for rare prototypes sporadically used, so to not bloat
// the binary with all possible permutations or ask for them on comptime, which is unreasonable.
const std = @import("std"); const std = @import("std");
const tolmac = @import("../../tolmac.zig"); const tolmac = @import("../../../tolmac.zig");
/// Used for stack parameter passing. /// Used for stack parameter passing.
pub const WordLimit = 128; pub const WordLimit = 128;
@ -111,8 +115,8 @@ pub fn generateOpZovSysvFromPrototype(prototype: anytype) !*const fn () callconv
; ;
var integer_allocation: usize = 0; var integer_allocation: usize = 0;
const IntegerAllocations = [_][]const u8{ "rdi", "rsi", "rdx", "rcx", "r8", "r9", "stack" }; const IntegerAllocations = [_][]const u8{ "rdi", "rsi", "rdx", "rcx", "r8", "r9" };
// var sse_allocation: enum { xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, stack } = .xmm0; // var sse_allocation: enum { xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 } = .xmm0;
var class_buffer = [_]Class{.void} ** ClassBufferLimit; var class_buffer = [_]Class{.void} ** ClassBufferLimit;

1
src/nmvm.zig Normal file
View File

@ -0,0 +1 @@
pub const tolmac = @import("tolmac.zig");

View File

@ -1,5 +1,5 @@
const tolmac = @import("tolmac.zig"); const tolmac = @import("nmvm").tolmac;
const cosmo = @import("cosmopolitan/cosmopolitan.zig"); const cosmo = @import("cosmopolitan.zig");
fn printInt3(int: u64, other: u32, another: u16) callconv(.SysV) void { fn printInt3(int: u64, other: u32, another: u16) callconv(.SysV) void {
@setAlignStack(16); @setAlignStack(16);
@ -57,5 +57,5 @@ fn cosmopolitanMain(argc: c_int, argv: [*][*:0]u8) callconv(.SysV) c_int {
} }
test { test {
_ = @import("tolmac.zig"); _ = @import("nmvm").tolmac;
} }