summaryrefslogtreecommitdiffstats
path: root/vendor/psm/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/psm/src')
-rw-r--r--vendor/psm/src/arch/aarch_aapcs64.s7
-rw-r--r--vendor/psm/src/arch/loongarch64.s63
-rw-r--r--vendor/psm/src/arch/powerpc64_aix.s137
-rw-r--r--vendor/psm/src/arch/riscv.s5
-rw-r--r--vendor/psm/src/arch/riscv64.s5
-rw-r--r--vendor/psm/src/lib.rs2
6 files changed, 212 insertions, 7 deletions
diff --git a/vendor/psm/src/arch/aarch_aapcs64.s b/vendor/psm/src/arch/aarch_aapcs64.s
index 55917f329..06a6245c2 100644
--- a/vendor/psm/src/arch/aarch_aapcs64.s
+++ b/vendor/psm/src/arch/aarch_aapcs64.s
@@ -9,6 +9,13 @@
#define FUNCTION(fnname) _##fnname
#define SIZE(fnname,endlabel)
+#elif CFG_TARGET_OS_windows
+
+#define GLOBL(fnname) .globl fnname
+#define TYPE(fnname)
+#define FUNCTION(fnname) fnname
+#define SIZE(fnname,endlabel)
+
#else
#define GLOBL(fnname) .globl fnname
diff --git a/vendor/psm/src/arch/loongarch64.s b/vendor/psm/src/arch/loongarch64.s
new file mode 100644
index 000000000..3fc654963
--- /dev/null
+++ b/vendor/psm/src/arch/loongarch64.s
@@ -0,0 +1,63 @@
+#include "psm.h"
+
+.text
+.globl rust_psm_stack_direction
+.align 2
+.type rust_psm_stack_direction,@function
+rust_psm_stack_direction:
+/* extern "C" fn() -> u8 */
+.cfi_startproc
+ li.w $r4, STACK_DIRECTION_DESCENDING
+ jr $r1
+.rust_psm_stack_direction_end:
+.size rust_psm_stack_direction,.rust_psm_stack_direction_end-rust_psm_stack_direction
+.cfi_endproc
+
+
+.globl rust_psm_stack_pointer
+.align 2
+.type rust_psm_stack_pointer,@function
+rust_psm_stack_pointer:
+/* extern "C" fn() -> *mut u8 */
+.cfi_startproc
+ move $r4, $r3
+ jr $r1
+.rust_psm_stack_pointer_end:
+.size rust_psm_stack_pointer,.rust_psm_stack_pointer_end-rust_psm_stack_pointer
+.cfi_endproc
+
+
+.globl rust_psm_replace_stack
+.align 2
+.type rust_psm_replace_stack,@function
+rust_psm_replace_stack:
+/* extern "C" fn(r4: usize, r5: extern "C" fn(usize), r6: *mut u8) */
+.cfi_startproc
+ move $r3, $r6
+ jr $r5
+.rust_psm_replace_stack_end:
+.size rust_psm_replace_stack,.rust_psm_replace_stack_end-rust_psm_replace_stack
+.cfi_endproc
+
+
+.globl rust_psm_on_stack
+.align 2
+.type rust_psm_on_stack,@function
+rust_psm_on_stack:
+/* extern "C" fn(r4: usize, r5: usize, r6: extern "C" fn(usize, usize), r7: *mut u8) */
+.cfi_startproc
+ st.d $r1, $r7, -8
+ st.d $r3, $r7, -16
+ addi.d $r3, $r7, -16
+ .cfi_def_cfa 3, 16
+ .cfi_offset 1, -8
+ .cfi_offset 3, -16
+ jirl $r1, $r6, 0
+ ld.d $r1, $r3, 8
+ .cfi_restore 1
+ ld.d $r3, $r3, 0
+ .cfi_restore 3
+ jr $r1
+.rust_psm_on_stack_end:
+.size rust_psm_on_stack,.rust_psm_on_stack_end-rust_psm_on_stack
+.cfi_endproc
diff --git a/vendor/psm/src/arch/powerpc64_aix.s b/vendor/psm/src/arch/powerpc64_aix.s
new file mode 100644
index 000000000..eed866004
--- /dev/null
+++ b/vendor/psm/src/arch/powerpc64_aix.s
@@ -0,0 +1,137 @@
+.csect .text[PR],2
+.file "powerpc64_aix.s"
+
+.globl rust_psm_stack_direction[DS]
+.globl .rust_psm_stack_direction
+.align 4
+.csect rust_psm_stack_direction[DS],3
+.vbyte 8, .rust_psm_stack_direction
+.vbyte 8, TOC[TC0]
+.vbyte 8, 0
+.csect .text[PR],2
+.rust_psm_stack_direction:
+# extern "C" fn() -> u8
+ li 3, 2
+ blr
+L..rust_psm_stack_direction_end:
+# Following bytes form the traceback table on AIX.
+# For specification, see https://www.ibm.com/docs/en/aix/7.2?topic=processor-traceback-tables.
+# For implementation, see https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp,
+# `PPCAIXAsmPrinter::emitTracebackTable`.
+.vbyte 4, 0x00000000 # Traceback table begin, for unwinder to search the table.
+.byte 0x00 # Version = 0
+.byte 0x09 # Language = CPlusPlus, since rust is using C++-like LSDA.
+.byte 0x20 # -IsGlobaLinkage, -IsOutOfLineEpilogOrPrologue
+ # +HasTraceBackTableOffset, -IsInternalProcedure
+ # -HasControlledStorage, -IsTOCless
+ # -IsFloatingPointPresent
+ # -IsFloatingPointOperationLogOrAbortEnabled
+.byte 0x40 # -IsInterruptHandler, +IsFunctionNamePresent, -IsAllocaUsed
+ # OnConditionDirective = 0, -IsCRSaved, -IsLRSaved
+.byte 0x80 # +IsBackChainStored, -IsFixup, NumOfFPRsSaved = 0
+.byte 0x00 # -HasExtensionTable, -HasVectorInfo, NumOfGPRsSaved = 0
+.byte 0x00 # NumberOfFixedParms = 0
+.byte 0x01 # NumberOfFPParms = 0, +HasParmsOnStack
+.vbyte 4, L..rust_psm_stack_direction_end-.rust_psm_stack_direction #Function size
+.vbyte 2, 0x0018 # Function name len = 24
+.byte "rust_psm_stack_direction" # Function Name
+
+.globl rust_psm_stack_pointer[DS]
+.globl .rust_psm_stack_pointer
+.align 4
+.csect rust_psm_stack_pointer[DS],3
+.vbyte 8, .rust_psm_stack_pointer
+.vbyte 8, TOC[TC0]
+.vbyte 8, 0
+.csect .text[PR],2
+.rust_psm_stack_pointer:
+# extern "C" fn() -> *mut u8
+ mr 3, 1
+ blr
+L..rust_psm_stack_pointer_end:
+.vbyte 4, 0x00000000
+.byte 0x00
+.byte 0x09
+.byte 0x20
+.byte 0x40
+.byte 0x80
+.byte 0x00
+.byte 0x00
+.byte 0x01
+.vbyte 4, L..rust_psm_stack_pointer_end-.rust_psm_stack_pointer
+.vbyte 2, 0x0016
+.byte "rust_psm_stack_pointer"
+
+.globl rust_psm_replace_stack[DS]
+.globl .rust_psm_replace_stack
+.align 4
+.csect rust_psm_replace_stack[DS],3
+.vbyte 8, .rust_psm_replace_stack
+.vbyte 8, TOC[TC0]
+.vbyte 8, 0
+.csect .text[PR],2
+.rust_psm_replace_stack:
+# extern "C" fn(3: usize, 4: extern "C" fn(usize), 5: *mut u8)
+ # Load the function pointer and toc pointer from TOC and make the call.
+ ld 2, 8(4)
+ ld 4, 0(4)
+ addi 5, 5, -48
+ mr 1, 5
+ mtctr 4
+ bctr
+L..rust_psm_replace_stack_end:
+.vbyte 4, 0x00000000
+.byte 0x00
+.byte 0x09
+.byte 0x20
+.byte 0x40
+.byte 0x80
+.byte 0x00
+.byte 0x03
+.byte 0x01
+.vbyte 4, 0x00000000 # Parameter type = i, i, i
+.vbyte 4, L..rust_psm_replace_stack_end-.rust_psm_replace_stack
+.vbyte 2, 0x0016
+.byte "rust_psm_replace_stack"
+
+.globl rust_psm_on_stack[DS]
+.globl .rust_psm_on_stack
+.align 4
+.csect rust_psm_on_stack[DS],3
+.vbyte 8, .rust_psm_on_stack
+.vbyte 8, TOC[TC0]
+.vbyte 8, 0
+.csect .text[PR],2
+.rust_psm_on_stack:
+# extern "C" fn(3: usize, 4: usize, 5: extern "C" fn(usize, usize), 6: *mut u8)
+ mflr 0
+ std 2, -72(6)
+ std 0, -8(6)
+ sub 6, 6, 1
+ addi 6, 6, -112
+ stdux 1, 1, 6
+ ld 2, 8(5)
+ ld 5, 0(5)
+ mtctr 5
+ bctrl
+ ld 2, 40(1)
+ ld 0, 104(1)
+ mtlr 0
+ ld 1, 0(1)
+ blr
+L..rust_psm_on_stack_end:
+.vbyte 4, 0x00000000
+.byte 0x00
+.byte 0x09
+.byte 0x20
+.byte 0x41
+.byte 0x80
+.byte 0x00
+.byte 0x04
+.byte 0x01
+.vbyte 4, 0x00000000 # Parameter type = i, i, i, i
+.vbyte 4, L..rust_psm_on_stack_end-.rust_psm_on_stack
+.vbyte 2, 0x0011
+.byte "rust_psm_on_stack"
+
+.toc
diff --git a/vendor/psm/src/arch/riscv.s b/vendor/psm/src/arch/riscv.s
index 4972993c9..f74779f02 100644
--- a/vendor/psm/src/arch/riscv.s
+++ b/vendor/psm/src/arch/riscv.s
@@ -48,11 +48,10 @@ rust_psm_on_stack:
.cfi_startproc
sw x1, -12(x13)
sw x2, -16(x13)
- .cfi_def_cfa x13, 0
+ addi x2, x13, -16
+ .cfi_def_cfa x2, 16
.cfi_offset x1, -12
.cfi_offset x2, -16
- addi x2, x13, -16
- .cfi_def_cfa x2, -16
jalr x1, x12, 0
lw x1, 4(x2)
.cfi_restore x1
diff --git a/vendor/psm/src/arch/riscv64.s b/vendor/psm/src/arch/riscv64.s
index 1b275ec27..279f735e3 100644
--- a/vendor/psm/src/arch/riscv64.s
+++ b/vendor/psm/src/arch/riscv64.s
@@ -48,11 +48,10 @@ rust_psm_on_stack:
.cfi_startproc
sd x1, -8(x13)
sd x2, -16(x13)
- .cfi_def_cfa x13, 0
+ addi x2, x13, -16
+ .cfi_def_cfa x2, 16
.cfi_offset x1, -8
.cfi_offset x2, -16
- addi x2, x13, -16
- .cfi_def_cfa x2, -16
jalr x1, x12, 0
ld x1, 8(x2)
.cfi_restore x1
diff --git a/vendor/psm/src/lib.rs b/vendor/psm/src/lib.rs
index 61ab9a85b..b9050c833 100644
--- a/vendor/psm/src/lib.rs
+++ b/vendor/psm/src/lib.rs
@@ -56,7 +56,7 @@ macro_rules! extern_item {
// NB: this could be nicer across multiple blocks but we cannot do it because of
// https://github.com/rust-lang/rust/issues/65847
extern_item! { {
- #![link(name="psm_s")]
+ #![cfg_attr(asm, link(name="psm_s"))]
#[cfg(asm)]
fn rust_psm_stack_direction() -> u8;