From cd86adaf41d871b835d14b4a83d9e72a91d570e0 Mon Sep 17 00:00:00 2001 From: Wang Qing Date: Wed, 14 Sep 2022 13:31:37 +0000 Subject: [PATCH] loongarch: Add ASSERT() breakpoint support on loongarch architecture. Bug: dawn:1506 Change-Id: Icff59529676c1f2ad3b9e1779577cad467866797 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/102146 Reviewed-by: Austin Eng Reviewed-by: Corentin Wallez Reviewed-by: Loko Kung Kokoro: Kokoro Commit-Queue: Corentin Wallez --- src/dawn/common/Assert.cpp | 2 ++ src/dawn/common/Platform.h | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/dawn/common/Assert.cpp b/src/dawn/common/Assert.cpp index ecc92dfc83..1793bacca8 100644 --- a/src/dawn/common/Assert.cpp +++ b/src/dawn/common/Assert.cpp @@ -27,6 +27,8 @@ void BreakPoint() { __asm__ __volatile__("bkpt 0"); #elif DAWN_PLATFORM_IS(ARM64) __asm__ __volatile__("brk 0"); +#elif DAWN_PLATFORM_IS(LOONGARCH) + __asm__ __volatile__("break"); #elif DAWN_PLATFORM_IS(RISCV) __asm__ __volatile__("ebreak"); #elif DAWN_PLATFORM_IS(MIPS) diff --git a/src/dawn/common/Platform.h b/src/dawn/common/Platform.h index 39d5eb4102..e49fc4ff1e 100644 --- a/src/dawn/common/Platform.h +++ b/src/dawn/common/Platform.h @@ -84,6 +84,9 @@ // - ARM // - ARM32 // - ARM64 +// - LOONGARCH +// - LOONGARCH32 +// - LOONGARCH64 // - RISCV // - RISCV32 // - RISCV64 @@ -108,6 +111,14 @@ #define DAWN_PLATFORM_IS_ARM 1 #define DAWN_PLATFORM_IS_ARM64 1 +#elif defined(__loongarch__) +#define DAWN_PLATFORM_IS_LOONGARCH 1 +#if _LOONGARCH_SIM == _ABILP32 +#define DAWN_PLATFORM_IS_LOONGARCH32 1 +#else +#define DAWN_PLATFORM_IS_LOONGARCH64 1 +#endif + #elif defined(__riscv) #define DAWN_PLATFORM_IS_RISCV 1 #if __riscv_xlen == 32 @@ -144,13 +155,14 @@ // - 32_BIT #if defined(DAWN_PLATFORM_IS_X86_64) || defined(DAWN_PLATFORM_IS_ARM64) || \ defined(DAWN_PLATFORM_IS_RISCV64) || defined(DAWN_PLATFORM_IS_MIPS64) || \ - defined(DAWN_PLATFORM_IS_S390X) || defined(DAWN_PLATFORM_IS_PPC64) + defined(DAWN_PLATFORM_IS_S390X) || defined(DAWN_PLATFORM_IS_PPC64) || \ + defined(DAWN_PLATFORM_IS_LOONGARCH64) #define DAWN_PLATFORM_IS_64_BIT 1 static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8"); #elif defined(DAWN_PLATFORM_IS_I386) || defined(DAWN_PLATFORM_IS_ARM32) || \ defined(DAWN_PLATFORM_IS_RISCV32) || defined(DAWN_PLATFORM_IS_MIPS32) || \ defined(DAWN_PLATFORM_IS_S390) || defined(DAWN_PLATFORM_IS_PPC32) || \ - defined(DAWN_PLATFORM_IS_EMSCRIPTEN) + defined(DAWN_PLATFORM_IS_EMSCRIPTEN) || defined(DAWN_PLATFORM_IS_LOONGARCH32) #define DAWN_PLATFORM_IS_32_BIT 1 static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4"); #else @@ -216,6 +228,16 @@ static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4"); #define DAWN_PLATFORM_IS_ARM64 0 #endif +#if !defined(DAWN_PLATFORM_IS_LOONGARCH) +#define DAWN_PLATFORM_IS_LOONGARCH 0 +#endif +#if !defined(DAWN_PLATFORM_IS_LOONGARCH32) +#define DAWN_PLATFORM_IS_LOONGARCH32 0 +#endif +#if !defined(DAWN_PLATFORM_IS_LOONGARCH64) +#define DAWN_PLATFORM_IS_LOONGARCH64 0 +#endif + #if !defined(DAWN_PLATFORM_IS_RISCV) #define DAWN_PLATFORM_IS_RISCV 0 #endif