diff options
author | Kristian H. Kristensen <[email protected]> | 2020-02-03 11:48:18 -0800 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-02-04 06:03:52 +0000 |
commit | 2be81a3bfa839e51b9719567236acaff70babd62 (patch) | |
tree | 9074a18d2fa13cb0186d9f824bf8852d8390ca39 | |
parent | de856c6170fbfd57f480c04069feb2fac0099060 (diff) |
nir: Make unroll pragma work on clang
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3686>
-rw-r--r-- | src/compiler/nir/nir_range_analysis.c | 27 |
1 files 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]); \ |