From 2be81a3bfa839e51b9719567236acaff70babd62 Mon Sep 17 00:00:00 2001 From: "Kristian H. Kristensen" Date: Mon, 3 Feb 2020 11:48:18 -0800 Subject: [PATCH] nir: Make unroll pragma work on clang Part-of: --- src/compiler/nir/nir_range_analysis.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index d38bcc0b040..fdce434054c 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -219,9 +219,18 @@ analyze_constant(const struct nir_alu_instr *instr, unsigned src, #define _______ unknown +#if defined(__clang__) +/* clang wants _Pragma("unroll X") */ +#define pragma_unroll_5 _Pragma("unroll 5") +#define pragma_unroll_7 _Pragma("unroll 7") +/* gcc wants _Pragma("GCC unroll X") */ +#elif defined(__GNUC__) +#define pragma_unroll_5 _Pragma("GCC unroll 5") +#define pragma_unroll_7 _Pragma("GCC unroll 7") +#else /* MSVC doesn't have C99's _Pragma() */ -#ifdef _MSC_VER -#define _Pragma(x) +#define pragma_unroll_5 +#define pragma_unroll_7 #endif @@ -231,9 +240,9 @@ analyze_constant(const struct nir_alu_instr *instr, unsigned src, static bool first = true; \ if (first) { \ first = false; \ - _Pragma("GCC unroll 7") \ + pragma_unroll_7 \ for (unsigned r = 0; r < ARRAY_SIZE(t); r++) { \ - _Pragma("GCC unroll 7") \ + pragma_unroll_7 \ for (unsigned c = 0; c < ARRAY_SIZE(t[0]); c++) \ assert(t[r][c] == t[c][r]); \ } \ @@ -245,7 +254,7 @@ analyze_constant(const struct nir_alu_instr *instr, unsigned src, static bool first = true; \ if (first) { \ first = false; \ - _Pragma("GCC unroll 7") \ + pragma_unroll_7 \ for (unsigned r = 0; r < ARRAY_SIZE(t); r++) \ assert(t[r][r] == r); \ } \ @@ -279,12 +288,12 @@ union_ranges(enum ssa_ranges a, enum ssa_ranges b) static bool first = true; \ if (first) { \ first = false; \ - _Pragma("GCC unroll 7") \ + pragma_unroll_7 \ for (unsigned i = 0; i < last_range; i++) { \ enum ssa_ranges col_range = t[i][unknown + 1]; \ enum ssa_ranges row_range = t[unknown + 1][i]; \ \ - _Pragma("GCC unroll 5") \ + pragma_unroll_5 \ for (unsigned j = unknown + 2; j < last_range; j++) { \ col_range = union_ranges(col_range, t[i][j]); \ row_range = union_ranges(row_range, t[j][i]); \ @@ -313,7 +322,7 @@ union_ranges(enum ssa_ranges a, enum ssa_ranges b) static bool first = true; \ if (first) { \ first = false; \ - _Pragma("GCC unroll 7") \ + pragma_unroll_7 \ for (unsigned i = 0; i < last_range; i++) { \ assert(union_ranges(t[i][lt_zero], t[i][eq_zero]) == t[i][le_zero]); \ assert(union_ranges(t[i][gt_zero], t[i][eq_zero]) == t[i][ge_zero]); \ @@ -348,7 +357,7 @@ union_ranges(enum ssa_ranges a, enum ssa_ranges b) static bool first = true; \ if (first) { \ first = false; \ - _Pragma("GCC unroll 7") \ + pragma_unroll_7 \ for (unsigned i = 0; i < last_range; i++) { \ assert(union_ranges(t[i][lt_zero], t[i][ge_zero]) == \ t[i][unknown]); \ -- 2.30.2