From ceaa66949432901fdd49c2778df3cb27299fcd90 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 18 May 2019 20:34:27 +0300 Subject: [PATCH] LLVM DSL: change array syntax again I probably misunderstand something. --- rpcs3/Emu/CPU/CPUTranslator.h | 55 +++++++++++++++-------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 38b5aad48a..d624c96d69 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -328,46 +328,39 @@ struct llvm_value_t : llvm_value_t } }; +// u32[4] : vector of 4 u32 elements +// u32[123][4] : array of 123 u32[4] vectors +// u32[123][1] : array of 123 u32 scalars template -struct llvm_value_t : llvm_value_t +struct llvm_value_t : llvm_value_t > 1), T, std::remove_extent_t>> { - static_assert(!llvm_value_t::is_vector, "llvm_value_t<> error: invalid multidimensional vector"); - static_assert(!llvm_value_t::is_pointer, "llvm_value_t<>: vector of pointers is not allowed"); - using type = T[N]; - using base = llvm_value_t; + using base = llvm_value_t > 1), T, std::remove_extent_t>>; using base::base; - static constexpr uint is_array = 0; - static constexpr uint is_vector = N; + static constexpr uint esize = std::is_array_v ? 0 : base::esize; + static constexpr bool is_int = !std::is_array_v && base::is_int; + static constexpr bool is_sint = !std::is_array_v && base::is_sint; + static constexpr bool is_uint = !std::is_array_v && base::is_uint; + static constexpr bool is_float = !std::is_array_v && base::is_float; + static constexpr uint is_array = std::is_array_v ? N : 0; + static constexpr uint is_vector = std::is_array_v ? 0 : N; static constexpr uint is_pointer = 0; static llvm::Type* get_type(llvm::LLVMContext& context) { - return llvm::VectorType::get(llvm_value_t::get_type(context), N); - } -}; - -// u32[4][123] : array of 123 u32[4] vectors -// u32[0][123] : array of 123 u32 scalars -template -struct llvm_value_t : llvm_value_t> -{ - using type = T[V][N]; - using base = llvm_value_t>; - using base::base; - - static constexpr bool is_int = false; - static constexpr bool is_sint = false; - static constexpr bool is_uint = false; - static constexpr bool is_float = false; - static constexpr uint is_array = N; - static constexpr uint is_vector = false; - static constexpr uint is_pointer = false; - - static llvm::Type* get_type(llvm::LLVMContext& context) - { - return llvm::ArrayType::get(base::get_type(context), N); + if constexpr (std::is_array_v) + { + return llvm::ArrayType::get(base::get_type(context), N); + } + else if constexpr (N > 1) + { + return llvm::VectorType::get(base::get_type(context), N); + } + else + { + return base::get_type(context); + } } };