18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef ARCH_PERF_REGS_H
38c2ecf20Sopenharmony_ci#define ARCH_PERF_REGS_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <stdlib.h>
68c2ecf20Sopenharmony_ci#include <linux/types.h>
78c2ecf20Sopenharmony_ci#include <asm/perf_regs.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define PERF_REGS_MAX PERF_REG_LOONGARCH_MAX
108c2ecf20Sopenharmony_ci#define PERF_REG_IP PERF_REG_LOONGARCH_PC
118c2ecf20Sopenharmony_ci#define PERF_REG_SP PERF_REG_LOONGARCH_R3
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define PERF_REGS_MASK ((1ULL << PERF_REG_LOONGARCH_MAX) - 1)
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistatic inline const char *__perf_reg_name(int id)
168c2ecf20Sopenharmony_ci{
178c2ecf20Sopenharmony_ci	switch (id) {
188c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_PC:
198c2ecf20Sopenharmony_ci		return "PC";
208c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R1:
218c2ecf20Sopenharmony_ci		return "$1";
228c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R2:
238c2ecf20Sopenharmony_ci		return "$2";
248c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R3:
258c2ecf20Sopenharmony_ci		return "$3";
268c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R4:
278c2ecf20Sopenharmony_ci		return "$4";
288c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R5:
298c2ecf20Sopenharmony_ci		return "$5";
308c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R6:
318c2ecf20Sopenharmony_ci		return "$6";
328c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R7:
338c2ecf20Sopenharmony_ci		return "$7";
348c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R8:
358c2ecf20Sopenharmony_ci		return "$8";
368c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R9:
378c2ecf20Sopenharmony_ci		return "$9";
388c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R10:
398c2ecf20Sopenharmony_ci		return "$10";
408c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R11:
418c2ecf20Sopenharmony_ci		return "$11";
428c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R12:
438c2ecf20Sopenharmony_ci		return "$12";
448c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R13:
458c2ecf20Sopenharmony_ci		return "$13";
468c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R14:
478c2ecf20Sopenharmony_ci		return "$14";
488c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R15:
498c2ecf20Sopenharmony_ci		return "$15";
508c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R16:
518c2ecf20Sopenharmony_ci		return "$16";
528c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R17:
538c2ecf20Sopenharmony_ci		return "$17";
548c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R18:
558c2ecf20Sopenharmony_ci		return "$18";
568c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R19:
578c2ecf20Sopenharmony_ci		return "$19";
588c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R20:
598c2ecf20Sopenharmony_ci		return "$20";
608c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R21:
618c2ecf20Sopenharmony_ci		return "$21";
628c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R22:
638c2ecf20Sopenharmony_ci		return "$22";
648c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R23:
658c2ecf20Sopenharmony_ci		return "$23";
668c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R24:
678c2ecf20Sopenharmony_ci		return "$24";
688c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R25:
698c2ecf20Sopenharmony_ci		return "$25";
708c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R26:
718c2ecf20Sopenharmony_ci		return "$26";
728c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R27:
738c2ecf20Sopenharmony_ci		return "$27";
748c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R28:
758c2ecf20Sopenharmony_ci		return "$28";
768c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R29:
778c2ecf20Sopenharmony_ci		return "$29";
788c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R30:
798c2ecf20Sopenharmony_ci		return "$30";
808c2ecf20Sopenharmony_ci	case PERF_REG_LOONGARCH_R31:
818c2ecf20Sopenharmony_ci		return "$31";
828c2ecf20Sopenharmony_ci	default:
838c2ecf20Sopenharmony_ci		break;
848c2ecf20Sopenharmony_ci	}
858c2ecf20Sopenharmony_ci	return NULL;
868c2ecf20Sopenharmony_ci}
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#endif /* ARCH_PERF_REGS_H */
89