| author | |
| committer | |
| log | a3854d042e0d05a87ae9f0b71d12474c8d0e57ec |
| tree | 7f0a97f024aea3eb3d1f6775acd9439075aebe0f |
| parent | 07f0de6a8a9a152cfbd76e458d99d992b59e9e06 |
| signature | Commit is signed but in an unrecognized format. |
llvm is giving me `error: couldn't allocate output register for
constraint '{a0}'` which is a bug that needs to be fixed upstream.9 files changed, 388 insertions(+), 10 deletions(-)
src/target.cpp+2-2| ... | @@ -1320,6 +1320,8 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) { | ... | @@ -1320,6 +1320,8 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) { |
| 1320 | case ZigLLVM_aarch64: | 1320 | case ZigLLVM_aarch64: |
| 1321 | case ZigLLVM_aarch64_be: | 1321 | case ZigLLVM_aarch64_be: |
| 1322 | case ZigLLVM_aarch64_32: | 1322 | case ZigLLVM_aarch64_32: |
| 1323 | case ZigLLVM_riscv32: | ||
| 1324 | case ZigLLVM_riscv64: | ||
| 1323 | return "sp"; | 1325 | return "sp"; |
| 1324 | 1326 | ||
| 1325 | case ZigLLVM_arm: | 1327 | case ZigLLVM_arm: |
| ... | @@ -1350,8 +1352,6 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) { | ... | @@ -1350,8 +1352,6 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) { |
| 1350 | case ZigLLVM_r600: | 1352 | case ZigLLVM_r600: |
| 1351 | case ZigLLVM_renderscript32: | 1353 | case ZigLLVM_renderscript32: |
| 1352 | case ZigLLVM_renderscript64: | 1354 | case ZigLLVM_renderscript64: |
| 1353 | case ZigLLVM_riscv32: | ||
| 1354 | case ZigLLVM_riscv64: | ||
| 1355 | case ZigLLVM_shave: | 1355 | case ZigLLVM_shave: |
| 1356 | case ZigLLVM_sparc: | 1356 | case ZigLLVM_sparc: |
| 1357 | case ZigLLVM_sparcel: | 1357 | case ZigLLVM_sparcel: |
std/os/bits/linux.zig+1| ... | @@ -7,6 +7,7 @@ pub usingnamespace @import("linux/errno.zig"); | ... | @@ -7,6 +7,7 @@ pub usingnamespace @import("linux/errno.zig"); |
| 7 | pub usingnamespace switch (builtin.arch) { | 7 | pub usingnamespace switch (builtin.arch) { |
| 8 | .x86_64 => @import("linux/x86_64.zig"), | 8 | .x86_64 => @import("linux/x86_64.zig"), |
| 9 | .aarch64 => @import("linux/arm64.zig"), | 9 | .aarch64 => @import("linux/arm64.zig"), |
| 10 | .riscv64 => @import("linux/riscv64.zig"), | ||
| 10 | else => struct {}, | 11 | else => struct {}, |
| 11 | }; | 12 | }; |
| 12 | 13 |
std/os/bits/linux/riscv64.zig created+279| ... | @@ -0,0 +1,279 @@ | ||
| 1 | // riscv64-specific declarations that are intended to be imported into the POSIX namespace. | ||
| 2 | |||
| 3 | pub const SYS_io_setup = 0; | ||
| 4 | pub const SYS_io_destroy = 1; | ||
| 5 | pub const SYS_io_submit = 2; | ||
| 6 | pub const SYS_io_cancel = 3; | ||
| 7 | pub const SYS_io_getevents = 4; | ||
| 8 | pub const SYS_setxattr = 5; | ||
| 9 | pub const SYS_lsetxattr = 6; | ||
| 10 | pub const SYS_fsetxattr = 7; | ||
| 11 | pub const SYS_getxattr = 8; | ||
| 12 | pub const SYS_lgetxattr = 9; | ||
| 13 | pub const SYS_fgetxattr = 10; | ||
| 14 | pub const SYS_listxattr = 11; | ||
| 15 | pub const SYS_llistxattr = 12; | ||
| 16 | pub const SYS_flistxattr = 13; | ||
| 17 | pub const SYS_removexattr = 14; | ||
| 18 | pub const SYS_lremovexattr = 15; | ||
| 19 | pub const SYS_fremovexattr = 16; | ||
| 20 | pub const SYS_getcwd = 17; | ||
| 21 | pub const SYS_lookup_dcookie = 18; | ||
| 22 | pub const SYS_eventfd2 = 19; | ||
| 23 | pub const SYS_epoll_create1 = 20; | ||
| 24 | pub const SYS_epoll_ctl = 21; | ||
| 25 | pub const SYS_epoll_pwait = 22; | ||
| 26 | pub const SYS_dup = 23; | ||
| 27 | pub const SYS_dup3 = 24; | ||
| 28 | pub const SYS_fcntl = 25; | ||
| 29 | pub const SYS_inotify_init1 = 26; | ||
| 30 | pub const SYS_inotify_add_watch = 27; | ||
| 31 | pub const SYS_inotify_rm_watch = 28; | ||
| 32 | pub const SYS_ioctl = 29; | ||
| 33 | pub const SYS_ioprio_set = 30; | ||
| 34 | pub const SYS_ioprio_get = 31; | ||
| 35 | pub const SYS_flock = 32; | ||
| 36 | pub const SYS_mknodat = 33; | ||
| 37 | pub const SYS_mkdirat = 34; | ||
| 38 | pub const SYS_unlinkat = 35; | ||
| 39 | pub const SYS_symlinkat = 36; | ||
| 40 | pub const SYS_linkat = 37; | ||
| 41 | pub const SYS_umount2 = 39; | ||
| 42 | pub const SYS_mount = 40; | ||
| 43 | pub const SYS_pivot_root = 41; | ||
| 44 | pub const SYS_nfsservctl = 42; | ||
| 45 | pub const SYS_statfs = 43; | ||
| 46 | pub const SYS_fstatfs = 44; | ||
| 47 | pub const SYS_truncate = 45; | ||
| 48 | pub const SYS_ftruncate = 46; | ||
| 49 | pub const SYS_fallocate = 47; | ||
| 50 | pub const SYS_faccessat = 48; | ||
| 51 | pub const SYS_chdir = 49; | ||
| 52 | pub const SYS_fchdir = 50; | ||
| 53 | pub const SYS_chroot = 51; | ||
| 54 | pub const SYS_fchmod = 52; | ||
| 55 | pub const SYS_fchmodat = 53; | ||
| 56 | pub const SYS_fchownat = 54; | ||
| 57 | pub const SYS_fchown = 55; | ||
| 58 | pub const SYS_openat = 56; | ||
| 59 | pub const SYS_close = 57; | ||
| 60 | pub const SYS_vhangup = 58; | ||
| 61 | pub const SYS_pipe2 = 59; | ||
| 62 | pub const SYS_quotactl = 60; | ||
| 63 | pub const SYS_getdents64 = 61; | ||
| 64 | pub const SYS_lseek = 62; | ||
| 65 | pub const SYS_read = 63; | ||
| 66 | pub const SYS_write = 64; | ||
| 67 | pub const SYS_readv = 65; | ||
| 68 | pub const SYS_writev = 66; | ||
| 69 | pub const SYS_pread64 = 67; | ||
| 70 | pub const SYS_pwrite64 = 68; | ||
| 71 | pub const SYS_preadv = 69; | ||
| 72 | pub const SYS_pwritev = 70; | ||
| 73 | pub const SYS_sendfile = 71; | ||
| 74 | pub const SYS_pselect6 = 72; | ||
| 75 | pub const SYS_ppoll = 73; | ||
| 76 | pub const SYS_signalfd4 = 74; | ||
| 77 | pub const SYS_vmsplice = 75; | ||
| 78 | pub const SYS_splice = 76; | ||
| 79 | pub const SYS_tee = 77; | ||
| 80 | pub const SYS_readlinkat = 78; | ||
| 81 | pub const SYS_fstatat = 79; | ||
| 82 | pub const SYS_fstat = 80; | ||
| 83 | pub const SYS_sync = 81; | ||
| 84 | pub const SYS_fsync = 82; | ||
| 85 | pub const SYS_fdatasync = 83; | ||
| 86 | pub const SYS_sync_file_range = 84; | ||
| 87 | pub const SYS_timerfd_create = 85; | ||
| 88 | pub const SYS_timerfd_settime = 86; | ||
| 89 | pub const SYS_timerfd_gettime = 87; | ||
| 90 | pub const SYS_utimensat = 88; | ||
| 91 | pub const SYS_acct = 89; | ||
| 92 | pub const SYS_capget = 90; | ||
| 93 | pub const SYS_capset = 91; | ||
| 94 | pub const SYS_personality = 92; | ||
| 95 | pub const SYS_exit = 93; | ||
| 96 | pub const SYS_exit_group = 94; | ||
| 97 | pub const SYS_waitid = 95; | ||
| 98 | pub const SYS_set_tid_address = 96; | ||
| 99 | pub const SYS_unshare = 97; | ||
| 100 | pub const SYS_futex = 98; | ||
| 101 | pub const SYS_set_robust_list = 99; | ||
| 102 | pub const SYS_get_robust_list = 100; | ||
| 103 | pub const SYS_nanosleep = 101; | ||
| 104 | pub const SYS_getitimer = 102; | ||
| 105 | pub const SYS_setitimer = 103; | ||
| 106 | pub const SYS_kexec_load = 104; | ||
| 107 | pub const SYS_init_module = 105; | ||
| 108 | pub const SYS_delete_module = 106; | ||
| 109 | pub const SYS_timer_create = 107; | ||
| 110 | pub const SYS_timer_gettime = 108; | ||
| 111 | pub const SYS_timer_getoverrun = 109; | ||
| 112 | pub const SYS_timer_settime = 110; | ||
| 113 | pub const SYS_timer_delete = 111; | ||
| 114 | pub const SYS_clock_settime = 112; | ||
| 115 | pub const SYS_clock_gettime = 113; | ||
| 116 | pub const SYS_clock_getres = 114; | ||
| 117 | pub const SYS_clock_nanosleep = 115; | ||
| 118 | pub const SYS_syslog = 116; | ||
| 119 | pub const SYS_ptrace = 117; | ||
| 120 | pub const SYS_sched_setparam = 118; | ||
| 121 | pub const SYS_sched_setscheduler = 119; | ||
| 122 | pub const SYS_sched_getscheduler = 120; | ||
| 123 | pub const SYS_sched_getparam = 121; | ||
| 124 | pub const SYS_sched_setaffinity = 122; | ||
| 125 | pub const SYS_sched_getaffinity = 123; | ||
| 126 | pub const SYS_sched_yield = 124; | ||
| 127 | pub const SYS_sched_get_priority_max = 125; | ||
| 128 | pub const SYS_sched_get_priority_min = 126; | ||
| 129 | pub const SYS_sched_rr_get_interval = 127; | ||
| 130 | pub const SYS_restart_syscall = 128; | ||
| 131 | pub const SYS_kill = 129; | ||
| 132 | pub const SYS_tkill = 130; | ||
| 133 | pub const SYS_tgkill = 131; | ||
| 134 | pub const SYS_sigaltstack = 132; | ||
| 135 | pub const SYS_rt_sigsuspend = 133; | ||
| 136 | pub const SYS_rt_sigaction = 134; | ||
| 137 | pub const SYS_rt_sigprocmask = 135; | ||
| 138 | pub const SYS_rt_sigpending = 136; | ||
| 139 | pub const SYS_rt_sigtimedwait = 137; | ||
| 140 | pub const SYS_rt_sigqueueinfo = 138; | ||
| 141 | pub const SYS_rt_sigreturn = 139; | ||
| 142 | pub const SYS_setpriority = 140; | ||
| 143 | pub const SYS_getpriority = 141; | ||
| 144 | pub const SYS_reboot = 142; | ||
| 145 | pub const SYS_setregid = 143; | ||
| 146 | pub const SYS_setgid = 144; | ||
| 147 | pub const SYS_setreuid = 145; | ||
| 148 | pub const SYS_setuid = 146; | ||
| 149 | pub const SYS_setresuid = 147; | ||
| 150 | pub const SYS_getresuid = 148; | ||
| 151 | pub const SYS_setresgid = 149; | ||
| 152 | pub const SYS_getresgid = 150; | ||
| 153 | pub const SYS_setfsuid = 151; | ||
| 154 | pub const SYS_setfsgid = 152; | ||
| 155 | pub const SYS_times = 153; | ||
| 156 | pub const SYS_setpgid = 154; | ||
| 157 | pub const SYS_getpgid = 155; | ||
| 158 | pub const SYS_getsid = 156; | ||
| 159 | pub const SYS_setsid = 157; | ||
| 160 | pub const SYS_getgroups = 158; | ||
| 161 | pub const SYS_setgroups = 159; | ||
| 162 | pub const SYS_uname = 160; | ||
| 163 | pub const SYS_sethostname = 161; | ||
| 164 | pub const SYS_setdomainname = 162; | ||
| 165 | pub const SYS_getrlimit = 163; | ||
| 166 | pub const SYS_setrlimit = 164; | ||
| 167 | pub const SYS_getrusage = 165; | ||
| 168 | pub const SYS_umask = 166; | ||
| 169 | pub const SYS_prctl = 167; | ||
| 170 | pub const SYS_getcpu = 168; | ||
| 171 | pub const SYS_gettimeofday = 169; | ||
| 172 | pub const SYS_settimeofday = 170; | ||
| 173 | pub const SYS_adjtimex = 171; | ||
| 174 | pub const SYS_getpid = 172; | ||
| 175 | pub const SYS_getppid = 173; | ||
| 176 | pub const SYS_getuid = 174; | ||
| 177 | pub const SYS_geteuid = 175; | ||
| 178 | pub const SYS_getgid = 176; | ||
| 179 | pub const SYS_getegid = 177; | ||
| 180 | pub const SYS_gettid = 178; | ||
| 181 | pub const SYS_sysinfo = 179; | ||
| 182 | pub const SYS_mq_open = 180; | ||
| 183 | pub const SYS_mq_unlink = 181; | ||
| 184 | pub const SYS_mq_timedsend = 182; | ||
| 185 | pub const SYS_mq_timedreceive = 183; | ||
| 186 | pub const SYS_mq_notify = 184; | ||
| 187 | pub const SYS_mq_getsetattr = 185; | ||
| 188 | pub const SYS_msgget = 186; | ||
| 189 | pub const SYS_msgctl = 187; | ||
| 190 | pub const SYS_msgrcv = 188; | ||
| 191 | pub const SYS_msgsnd = 189; | ||
| 192 | pub const SYS_semget = 190; | ||
| 193 | pub const SYS_semctl = 191; | ||
| 194 | pub const SYS_semtimedop = 192; | ||
| 195 | pub const SYS_semop = 193; | ||
| 196 | pub const SYS_shmget = 194; | ||
| 197 | pub const SYS_shmctl = 195; | ||
| 198 | pub const SYS_shmat = 196; | ||
| 199 | pub const SYS_shmdt = 197; | ||
| 200 | pub const SYS_socket = 198; | ||
| 201 | pub const SYS_socketpair = 199; | ||
| 202 | pub const SYS_bind = 200; | ||
| 203 | pub const SYS_listen = 201; | ||
| 204 | pub const SYS_accept = 202; | ||
| 205 | pub const SYS_connect = 203; | ||
| 206 | pub const SYS_getsockname = 204; | ||
| 207 | pub const SYS_getpeername = 205; | ||
| 208 | pub const SYS_sendto = 206; | ||
| 209 | pub const SYS_recvfrom = 207; | ||
| 210 | pub const SYS_setsockopt = 208; | ||
| 211 | pub const SYS_getsockopt = 209; | ||
| 212 | pub const SYS_shutdown = 210; | ||
| 213 | pub const SYS_sendmsg = 211; | ||
| 214 | pub const SYS_recvmsg = 212; | ||
| 215 | pub const SYS_readahead = 213; | ||
| 216 | pub const SYS_brk = 214; | ||
| 217 | pub const SYS_munmap = 215; | ||
| 218 | pub const SYS_mremap = 216; | ||
| 219 | pub const SYS_add_key = 217; | ||
| 220 | pub const SYS_request_key = 218; | ||
| 221 | pub const SYS_keyctl = 219; | ||
| 222 | pub const SYS_clone = 220; | ||
| 223 | pub const SYS_execve = 221; | ||
| 224 | pub const SYS_mmap = 222; | ||
| 225 | pub const SYS_fadvise64 = 223; | ||
| 226 | pub const SYS_swapon = 224; | ||
| 227 | pub const SYS_swapoff = 225; | ||
| 228 | pub const SYS_mprotect = 226; | ||
| 229 | pub const SYS_msync = 227; | ||
| 230 | pub const SYS_mlock = 228; | ||
| 231 | pub const SYS_munlock = 229; | ||
| 232 | pub const SYS_mlockall = 230; | ||
| 233 | pub const SYS_munlockall = 231; | ||
| 234 | pub const SYS_mincore = 232; | ||
| 235 | pub const SYS_madvise = 233; | ||
| 236 | pub const SYS_remap_file_pages = 234; | ||
| 237 | pub const SYS_mbind = 235; | ||
| 238 | pub const SYS_get_mempolicy = 236; | ||
| 239 | pub const SYS_set_mempolicy = 237; | ||
| 240 | pub const SYS_migrate_pages = 238; | ||
| 241 | pub const SYS_move_pages = 239; | ||
| 242 | pub const SYS_rt_tgsigqueueinfo = 240; | ||
| 243 | pub const SYS_perf_event_open = 241; | ||
| 244 | pub const SYS_accept4 = 242; | ||
| 245 | pub const SYS_recvmmsg = 243; | ||
| 246 | pub const SYS_arch_specific_syscall = 244; | ||
| 247 | pub const SYS_wait4 = 260; | ||
| 248 | pub const SYS_prlimit64 = 261; | ||
| 249 | pub const SYS_fanotify_init = 262; | ||
| 250 | pub const SYS_fanotify_mark = 263; | ||
| 251 | pub const SYS_name_to_handle_at = 264; | ||
| 252 | pub const SYS_open_by_handle_at = 265; | ||
| 253 | pub const SYS_clock_adjtime = 266; | ||
| 254 | pub const SYS_syncfs = 267; | ||
| 255 | pub const SYS_setns = 268; | ||
| 256 | pub const SYS_sendmmsg = 269; | ||
| 257 | pub const SYS_process_vm_readv = 270; | ||
| 258 | pub const SYS_process_vm_writev = 271; | ||
| 259 | pub const SYS_kcmp = 272; | ||
| 260 | pub const SYS_finit_module = 273; | ||
| 261 | pub const SYS_sched_setattr = 274; | ||
| 262 | pub const SYS_sched_getattr = 275; | ||
| 263 | pub const SYS_renameat2 = 276; | ||
| 264 | pub const SYS_seccomp = 277; | ||
| 265 | pub const SYS_getrandom = 278; | ||
| 266 | pub const SYS_memfd_create = 279; | ||
| 267 | pub const SYS_bpf = 280; | ||
| 268 | pub const SYS_execveat = 281; | ||
| 269 | pub const SYS_userfaultfd = 282; | ||
| 270 | pub const SYS_membarrier = 283; | ||
| 271 | pub const SYS_mlock2 = 284; | ||
| 272 | pub const SYS_copy_file_range = 285; | ||
| 273 | pub const SYS_preadv2 = 286; | ||
| 274 | pub const SYS_pwritev2 = 287; | ||
| 275 | pub const SYS_pkey_mprotect = 288; | ||
| 276 | pub const SYS_pkey_alloc = 289; | ||
| 277 | pub const SYS_pkey_free = 290; | ||
| 278 | pub const SYS_sysriscv = 244; | ||
| 279 | pub const SYS_riscv_flush_icache = SYS_sysriscv + 15; | ||
std/os/linux.zig+1| ... | @@ -17,6 +17,7 @@ pub const is_the_target = builtin.os == .linux; | ... | @@ -17,6 +17,7 @@ pub const is_the_target = builtin.os == .linux; |
| 17 | pub usingnamespace switch (builtin.arch) { | 17 | pub usingnamespace switch (builtin.arch) { |
| 18 | .x86_64 => @import("linux/x86_64.zig"), | 18 | .x86_64 => @import("linux/x86_64.zig"), |
| 19 | .aarch64 => @import("linux/arm64.zig"), | 19 | .aarch64 => @import("linux/arm64.zig"), |
| 20 | .riscv64 => @import("linux/riscv64.zig"), | ||
| 20 | else => struct {}, | 21 | else => struct {}, |
| 21 | }; | 22 | }; |
| 22 | pub usingnamespace @import("bits.zig"); | 23 | pub usingnamespace @import("bits.zig"); |
std/os/linux/arm64.zig+7| ... | @@ -2,6 +2,7 @@ pub fn syscall0(number: usize) usize { | ... | @@ -2,6 +2,7 @@ pub fn syscall0(number: usize) usize { |
| 2 | return asm volatile ("svc #0" | 2 | return asm volatile ("svc #0" |
| 3 | : [ret] "={x0}" (-> usize) | 3 | : [ret] "={x0}" (-> usize) |
| 4 | : [number] "{x8}" (number) | 4 | : [number] "{x8}" (number) |
| 5 | : "memory" | ||
| 5 | ); | 6 | ); |
| 6 | } | 7 | } |
| 7 | 8 | ||
| ... | @@ -10,6 +11,7 @@ pub fn syscall1(number: usize, arg1: usize) usize { | ... | @@ -10,6 +11,7 @@ pub fn syscall1(number: usize, arg1: usize) usize { |
| 10 | : [ret] "={x0}" (-> usize) | 11 | : [ret] "={x0}" (-> usize) |
| 11 | : [number] "{x8}" (number), | 12 | : [number] "{x8}" (number), |
| 12 | [arg1] "{x0}" (arg1) | 13 | [arg1] "{x0}" (arg1) |
| 14 | : "memory" | ||
| 13 | ); | 15 | ); |
| 14 | } | 16 | } |
| 15 | 17 | ||
| ... | @@ -19,6 +21,7 @@ pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { | ... | @@ -19,6 +21,7 @@ pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { |
| 19 | : [number] "{x8}" (number), | 21 | : [number] "{x8}" (number), |
| 20 | [arg1] "{x0}" (arg1), | 22 | [arg1] "{x0}" (arg1), |
| 21 | [arg2] "{x1}" (arg2) | 23 | [arg2] "{x1}" (arg2) |
| 24 | : "memory" | ||
| 22 | ); | 25 | ); |
| 23 | } | 26 | } |
| 24 | 27 | ||
| ... | @@ -29,6 +32,7 @@ pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { | ... | @@ -29,6 +32,7 @@ pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { |
| 29 | [arg1] "{x0}" (arg1), | 32 | [arg1] "{x0}" (arg1), |
| 30 | [arg2] "{x1}" (arg2), | 33 | [arg2] "{x1}" (arg2), |
| 31 | [arg3] "{x2}" (arg3) | 34 | [arg3] "{x2}" (arg3) |
| 35 | : "memory" | ||
| 32 | ); | 36 | ); |
| 33 | } | 37 | } |
| 34 | 38 | ||
| ... | @@ -40,6 +44,7 @@ pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz | ... | @@ -40,6 +44,7 @@ pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz |
| 40 | [arg2] "{x1}" (arg2), | 44 | [arg2] "{x1}" (arg2), |
| 41 | [arg3] "{x2}" (arg3), | 45 | [arg3] "{x2}" (arg3), |
| 42 | [arg4] "{x3}" (arg4) | 46 | [arg4] "{x3}" (arg4) |
| 47 | : "memory" | ||
| 43 | ); | 48 | ); |
| 44 | } | 49 | } |
| 45 | 50 | ||
| ... | @@ -52,6 +57,7 @@ pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz | ... | @@ -52,6 +57,7 @@ pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz |
| 52 | [arg3] "{x2}" (arg3), | 57 | [arg3] "{x2}" (arg3), |
| 53 | [arg4] "{x3}" (arg4), | 58 | [arg4] "{x3}" (arg4), |
| 54 | [arg5] "{x4}" (arg5) | 59 | [arg5] "{x4}" (arg5) |
| 60 | : "memory" | ||
| 55 | ); | 61 | ); |
| 56 | } | 62 | } |
| 57 | 63 | ||
| ... | @@ -73,6 +79,7 @@ pub fn syscall6( | ... | @@ -73,6 +79,7 @@ pub fn syscall6( |
| 73 | [arg4] "{x3}" (arg4), | 79 | [arg4] "{x3}" (arg4), |
| 74 | [arg5] "{x4}" (arg5), | 80 | [arg5] "{x4}" (arg5), |
| 75 | [arg6] "{x5}" (arg6) | 81 | [arg6] "{x5}" (arg6) |
| 82 | : "memory" | ||
| 76 | ); | 83 | ); |
| 77 | } | 84 | } |
| 78 | 85 |
std/os/linux/riscv64.zig created+78| ... | @@ -0,0 +1,78 @@ | ||
| 1 | pub fn syscall0(number: usize) usize { | ||
| 2 | return asm volatile ("ecall" | ||
| 3 | : [ret] "={a0}" (-> usize) | ||
| 4 | : [number] "{a7}" (number) | ||
| 5 | : "memory" | ||
| 6 | ); | ||
| 7 | } | ||
| 8 | |||
| 9 | pub fn syscall1(number: usize, arg1: usize) usize { | ||
| 10 | return asm volatile ("ecall" | ||
| 11 | : [ret] "={a0}" (-> usize) | ||
| 12 | : [number] "{a7}" (number), | ||
| 13 | [arg1] "{a0}" (arg1) | ||
| 14 | ); | ||
| 15 | } | ||
| 16 | |||
| 17 | pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { | ||
| 18 | return asm volatile ("ecall" | ||
| 19 | : [ret] "={a0}" (-> usize) | ||
| 20 | : [number] "{a7}" (number), | ||
| 21 | [arg1] "{a0}" (arg1), | ||
| 22 | [arg2] "{a1}" (arg2) | ||
| 23 | ); | ||
| 24 | } | ||
| 25 | |||
| 26 | pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { | ||
| 27 | return asm volatile ("ecall" | ||
| 28 | : [ret] "={a0}" (-> usize) | ||
| 29 | : [number] "{a7}" (number), | ||
| 30 | [arg1] "{a0}" (arg1), | ||
| 31 | [arg2] "{a1}" (arg2), | ||
| 32 | [arg3] "{a2}" (arg3) | ||
| 33 | ); | ||
| 34 | } | ||
| 35 | |||
| 36 | pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { | ||
| 37 | return asm volatile ("ecall" | ||
| 38 | : [ret] "={a0}" (-> usize) | ||
| 39 | : [number] "{a7}" (number), | ||
| 40 | [arg1] "{a0}" (arg1), | ||
| 41 | [arg2] "{a1}" (arg2), | ||
| 42 | [arg3] "{a2}" (arg3), | ||
| 43 | [arg4] "{a3}" (arg4) | ||
| 44 | ); | ||
| 45 | } | ||
| 46 | |||
| 47 | pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { | ||
| 48 | return asm volatile ("ecall" | ||
| 49 | : [ret] "={a0}" (-> usize) | ||
| 50 | : [number] "{a7}" (number), | ||
| 51 | [arg1] "{a0}" (arg1), | ||
| 52 | [arg2] "{a1}" (arg2), | ||
| 53 | [arg3] "{a2}" (arg3), | ||
| 54 | [arg4] "{a3}" (arg4), | ||
| 55 | [arg5] "{a4}" (arg5) | ||
| 56 | ); | ||
| 57 | } | ||
| 58 | |||
| 59 | pub fn syscall6( | ||
| 60 | number: usize, | ||
| 61 | arg1: usize, | ||
| 62 | arg2: usize, | ||
| 63 | arg3: usize, | ||
| 64 | arg4: usize, | ||
| 65 | arg5: usize, | ||
| 66 | arg6: usize, | ||
| 67 | ) usize { | ||
| 68 | return asm volatile ("ecall" | ||
| 69 | : [ret] "={a0}" (-> usize) | ||
| 70 | : [number] "{a7}" (number), | ||
| 71 | [arg1] "{a0}" (arg1), | ||
| 72 | [arg2] "{a1}" (arg2), | ||
| 73 | [arg3] "{a2}" (arg3), | ||
| 74 | [arg4] "{a3}" (arg4), | ||
| 75 | [arg5] "{a4}" (arg5), | ||
| 76 | [arg6] "{a5}" (arg6) | ||
| 77 | ); | ||
| 78 | } | ||
std/os/linux/tls.zig+8-1| ... | @@ -47,7 +47,7 @@ const TLSVariant = enum { | ... | @@ -47,7 +47,7 @@ const TLSVariant = enum { |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | const tls_variant = switch (builtin.arch) { | 49 | const tls_variant = switch (builtin.arch) { |
| 50 | .arm, .armeb, .aarch64, .aarch64_be => TLSVariant.VariantI, | 50 | .arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64 => TLSVariant.VariantI, |
| 51 | .x86_64, .i386 => TLSVariant.VariantII, | 51 | .x86_64, .i386 => TLSVariant.VariantII, |
| 52 | else => @compileError("undefined tls_variant for this architecture"), | 52 | else => @compileError("undefined tls_variant for this architecture"), |
| 53 | }; | 53 | }; |
| ... | @@ -118,6 +118,13 @@ pub fn setThreadPointer(addr: usize) void { | ... | @@ -118,6 +118,13 @@ pub fn setThreadPointer(addr: usize) void { |
| 118 | : [addr] "r" (addr) | 118 | : [addr] "r" (addr) |
| 119 | ); | 119 | ); |
| 120 | }, | 120 | }, |
| 121 | .riscv64 => { | ||
| 122 | asm volatile ( | ||
| 123 | \\ mv tp, %[addr] | ||
| 124 | : | ||
| 125 | : [addr] "r" (addr) | ||
| 126 | ); | ||
| 127 | }, | ||
| 121 | else => @compileError("Unsupported architecture"), | 128 | else => @compileError("Unsupported architecture"), |
| 122 | } | 129 | } |
| 123 | } | 130 | } |
std/os/linux/x86_64.zig+7-7| ... | @@ -4,7 +4,7 @@ pub fn syscall0(number: usize) usize { | ... | @@ -4,7 +4,7 @@ pub fn syscall0(number: usize) usize { |
| 4 | return asm volatile ("syscall" | 4 | return asm volatile ("syscall" |
| 5 | : [ret] "={rax}" (-> usize) | 5 | : [ret] "={rax}" (-> usize) |
| 6 | : [number] "{rax}" (number) | 6 | : [number] "{rax}" (number) |
| 7 | : "rcx", "r11" | 7 | : "rcx", "r11", "memory" |
| 8 | ); | 8 | ); |
| 9 | } | 9 | } |
| 10 | 10 | ||
| ... | @@ -13,7 +13,7 @@ pub fn syscall1(number: usize, arg1: usize) usize { | ... | @@ -13,7 +13,7 @@ pub fn syscall1(number: usize, arg1: usize) usize { |
| 13 | : [ret] "={rax}" (-> usize) | 13 | : [ret] "={rax}" (-> usize) |
| 14 | : [number] "{rax}" (number), | 14 | : [number] "{rax}" (number), |
| 15 | [arg1] "{rdi}" (arg1) | 15 | [arg1] "{rdi}" (arg1) |
| 16 | : "rcx", "r11" | 16 | : "rcx", "r11", "memory" |
| 17 | ); | 17 | ); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| ... | @@ -23,7 +23,7 @@ pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { | ... | @@ -23,7 +23,7 @@ pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize { |
| 23 | : [number] "{rax}" (number), | 23 | : [number] "{rax}" (number), |
| 24 | [arg1] "{rdi}" (arg1), | 24 | [arg1] "{rdi}" (arg1), |
| 25 | [arg2] "{rsi}" (arg2) | 25 | [arg2] "{rsi}" (arg2) |
| 26 | : "rcx", "r11" | 26 | : "rcx", "r11", "memory" |
| 27 | ); | 27 | ); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| ... | @@ -34,7 +34,7 @@ pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { | ... | @@ -34,7 +34,7 @@ pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize { |
| 34 | [arg1] "{rdi}" (arg1), | 34 | [arg1] "{rdi}" (arg1), |
| 35 | [arg2] "{rsi}" (arg2), | 35 | [arg2] "{rsi}" (arg2), |
| 36 | [arg3] "{rdx}" (arg3) | 36 | [arg3] "{rdx}" (arg3) |
| 37 | : "rcx", "r11" | 37 | : "rcx", "r11", "memory" |
| 38 | ); | 38 | ); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| ... | @@ -46,7 +46,7 @@ pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz | ... | @@ -46,7 +46,7 @@ pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz |
| 46 | [arg2] "{rsi}" (arg2), | 46 | [arg2] "{rsi}" (arg2), |
| 47 | [arg3] "{rdx}" (arg3), | 47 | [arg3] "{rdx}" (arg3), |
| 48 | [arg4] "{r10}" (arg4) | 48 | [arg4] "{r10}" (arg4) |
| 49 | : "rcx", "r11" | 49 | : "rcx", "r11", "memory" |
| 50 | ); | 50 | ); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| ... | @@ -59,7 +59,7 @@ pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz | ... | @@ -59,7 +59,7 @@ pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz |
| 59 | [arg3] "{rdx}" (arg3), | 59 | [arg3] "{rdx}" (arg3), |
| 60 | [arg4] "{r10}" (arg4), | 60 | [arg4] "{r10}" (arg4), |
| 61 | [arg5] "{r8}" (arg5) | 61 | [arg5] "{r8}" (arg5) |
| 62 | : "rcx", "r11" | 62 | : "rcx", "r11", "memory" |
| 63 | ); | 63 | ); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| ... | @@ -81,7 +81,7 @@ pub fn syscall6( | ... | @@ -81,7 +81,7 @@ pub fn syscall6( |
| 81 | [arg4] "{r10}" (arg4), | 81 | [arg4] "{r10}" (arg4), |
| 82 | [arg5] "{r8}" (arg5), | 82 | [arg5] "{r8}" (arg5), |
| 83 | [arg6] "{r9}" (arg6) | 83 | [arg6] "{r9}" (arg6) |
| 84 | : "rcx", "r11" | 84 | : "rcx", "r11", "memory" |
| 85 | ); | 85 | ); |
| 86 | } | 86 | } |
| 87 | 87 |
std/special/start.zig+5| ... | @@ -59,6 +59,11 @@ nakedcc fn _start() noreturn { | ... | @@ -59,6 +59,11 @@ nakedcc fn _start() noreturn { |
| 59 | : [argc] "=r" (-> [*]usize) | 59 | : [argc] "=r" (-> [*]usize) |
| 60 | ); | 60 | ); |
| 61 | }, | 61 | }, |
| 62 | .riscv64 => { | ||
| 63 | argc_ptr = asm ("mov %[argc], sp" | ||
| 64 | : [argc] "=r" (-> [*]usize) | ||
| 65 | ); | ||
| 66 | }, | ||
| 62 | else => @compileError("unsupported arch"), | 67 | else => @compileError("unsupported arch"), |
| 63 | } | 68 | } |
| 64 | // If LLVM inlines stack variables into _start, they will overwrite | 69 | // If LLVM inlines stack variables into _start, they will overwrite |