llvm/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h

//===-- LinuxPTraceDefines_arm64sve.h ------------------------- -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H
#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H

#include <cstdint>

namespace lldb_private {
namespace sve {

/*
 * The SVE architecture leaves space for future expansion of the
 * vector length beyond its initial architectural limit of 2048 bits
 * (16 quadwords).
 *
 * See <Linux kernel source tree>/Documentation/arm64/sve.rst for a description
 * of the vl/vq terminology.
 */

const uint16_t vq_bytes =; /* number of bytes per quadword */

const uint16_t vq_min =;
const uint16_t vq_max =;

const uint16_t vl_min =;
const uint16_t vl_max =;

const uint16_t num_of_zregs =;
const uint16_t num_of_pregs =;

inline uint16_t vl_valid(uint16_t vl) {}

inline uint16_t vq_from_vl(uint16_t vl) {}
inline uint16_t vl_from_vq(uint16_t vq) {}

/* A new signal frame record sve_context encodes the SVE Registers on signal
 * delivery. sve_context struct definition may be included in asm/sigcontext.h.
 * We define sve_context_size which will be used by LLDB sve helper functions.
 * More information on sve_context can be found in Linux kernel source tree at
 * Documentation/arm64/sve.rst.
 */

const uint16_t sve_context_size =;

/*
 * If the SVE registers are currently live for the thread at signal delivery,
 * sve_context.head.size >=
 * SigContextSize(vq_from_vl(sve_context.vl))
 * and the register data may be accessed using the Sig*() functions.
 *
 * If sve_context.head.size <
 * SigContextSize(vq_from_vl(sve_context.vl)),
 * the SVE registers were not live for the thread and no register data
 * is included: in this case, the Sig*() functions should not be
 * used except for this check.
 *
 * The same convention applies when returning from a signal: a caller
 * will need to remove or resize the sve_context block if it wants to
 * make the SVE registers live when they were previously non-live or
 * vice-versa.  This may require the caller to allocate fresh
 * memory and/or move other context blocks in the signal frame.
 *
 * Changing the vector length during signal return is not permitted:
 * sve_context.vl must equal the thread's current vector length when
 * doing a sigreturn.
 *
 *
 * Note: for all these functions, the "vq" argument denotes the SVE
 * vector length in quadwords (i.e., units of 128 bits).
 *
 * The correct way to obtain vq is to use vq_from_vl(vl).  The
 * result is valid if and only if vl_valid(vl) is true.  This is
 * guaranteed for a struct sve_context written by the kernel.
 *
 *
 * Additional functions describe the contents and layout of the payload.
 * For each, Sig*Offset(args) is the start offset relative to
 * the start of struct sve_context, and Sig*Size(args) is the
 * size in bytes:
 *
 *	x	type				description
 *	-	----				-----------
 *	REGS					the entire SVE context
 *
 *	ZREGS	__uint128_t[num_of_zregs][vq]	all Z-registers
 *	ZREG	__uint128_t[vq]			individual Z-register Zn
 *
 *	PREGS	uint16_t[num_of_pregs][vq]	all P-registers
 *	PREG	uint16_t[vq]			individual P-register Pn
 *
 *	FFR	uint16_t[vq]			first-fault status register
 *
 * Additional data might be appended in the future.
 */

inline uint16_t SigZRegSize(uint16_t vq) {}
inline uint16_t SigPRegSize(uint16_t vq) {}
inline uint16_t SigFFRSize(uint16_t vq) {}

inline uint32_t SigRegsOffset() {}

inline uint32_t SigZRegsOffset() {}

inline uint32_t SigZRegOffset(uint16_t vq, uint16_t n) {}

inline uint32_t SigZRegsSize(uint16_t vq) {}

inline uint32_t SigPRegsOffset(uint16_t vq) {}

inline uint32_t SigPRegOffset(uint16_t vq, uint16_t n) {}

inline uint32_t SigpRegsSize(uint16_t vq) {}

inline uint32_t SigFFROffset(uint16_t vq) {}

inline uint32_t SigRegsSize(uint16_t vq) {}

inline uint32_t SVESigContextSize(uint16_t vq) {}

struct user_sve_header {};

user_za_header;

/* Definitions for user_sve_header.flags: */
const uint16_t ptrace_regs_mask =;
const uint16_t ptrace_regs_fpsimd =;
const uint16_t ptrace_regs_sve =;

/*
 * The remainder of the SVE state follows struct user_sve_header.  The
 * total size of the SVE state (including header) depends on the
 * metadata in the header:  PTraceSize(vq, flags) gives the total size
 * of the state in bytes, including the header.
 *
 * Refer to <asm/sigcontext.h> for details of how to pass the correct
 * "vq" argument to these macros.
 */

/* Offset from the start of struct user_sve_header to the register data */
inline uint16_t PTraceRegsOffset() {}

/*
 * The register data content and layout depends on the value of the
 * flags field.
 */

/*
 * (flags & ptrace_regs_mask) == ptrace_regs_fpsimd case:
 *
 * The payload starts at offset PTraceFPSIMDOffset, and is of type
 * struct user_fpsimd_state.  Additional data might be appended in the
 * future: use PTraceFPSIMDSize(vq, flags) to compute the total size.
 * PTraceFPSIMDSize(vq, flags) will never be less than
 * sizeof(struct user_fpsimd_state).
 */

const uint32_t ptrace_fpsimd_offset =;

/* Return size of struct user_fpsimd_state from asm/ptrace.h */
inline uint32_t PTraceFPSIMDSize(uint16_t vq, uint16_t flags) {}

/*
 * (flags & ptrace_regs_mask) == ptrace_regs_sve case:
 *
 * The payload starts at offset PTraceSVEOffset, and is of size
 * PTraceSVESize(vq, flags).
 *
 * Additional functions describe the contents and layout of the payload.
 * For each, PTrace*X*Offset(args) is the start offset relative to
 * the start of struct user_sve_header, and PTrace*X*Size(args) is
 * the size in bytes:
 *
 *	x	type				description
 *	-	----				-----------
 *	ZREGS		\
 *	ZREG		|
 *	PREGS		| refer to <asm/sigcontext.h>
 *	PREG		|
 *	FFR		/
 *
 *	FPSR	uint32_t			FPSR
 *	FPCR	uint32_t			FPCR
 *
 * Additional data might be appended in the future.
 */

inline uint32_t PTraceZRegSize(uint16_t vq) {}

inline uint32_t PTracePRegSize(uint16_t vq) {}

inline uint32_t PTraceFFRSize(uint16_t vq) {}

const uint32_t fpsr_size =;
const uint32_t fpcr_size =;

inline uint32_t SigToPTrace(uint32_t offset) {}

const uint32_t ptrace_sve_offset =;

inline uint32_t PTraceZRegsOffset(uint16_t vq) {}

inline uint32_t PTraceZRegOffset(uint16_t vq, uint16_t n) {}

inline uint32_t PTraceZRegsSize(uint16_t vq) {}

inline uint32_t PTracePRegsOffset(uint16_t vq) {}

inline uint32_t PTracePRegOffset(uint16_t vq, uint16_t n) {}

inline uint32_t PTracePRegsSize(uint16_t vq) {}

inline uint32_t PTraceFFROffset(uint16_t vq) {}

inline uint32_t PTraceFPSROffset(uint16_t vq) {}

inline uint32_t PTraceFPCROffset(uint16_t vq) {}

/*
 * Any future extension appended after FPCR must be aligned to the next
 * 128-bit boundary.
 */

inline uint32_t PTraceSVESize(uint16_t vq, uint16_t flags) {}

inline uint32_t PTraceSize(uint16_t vq, uint16_t flags) {}

} // namespace SVE
} // namespace lldb_private

#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H