/usr/src/gcc-6/debian/patches/mips-pr78176-add-mlxc1-sxc1.diff is in gcc-6-source 6.4.0-17ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | From fccc4b5408942b92bc00bc053f4da9af2109557c Mon Sep 17 00:00:00 2001
From: mpf <mpf@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 19 Jan 2017 16:05:59 +0000
Subject: [PATCH] MIPS: PR target/78176 add -mlxc1-sxc1.
gcc/
PR target/78176
* config.gcc (supported_defaults): Add lxc1-sxc1.
(with_lxc1_sxc1): Add validation.
(all_defaults): Add lxc1-sxc1.
* config/mips/mips.opt (mlxc1-sxc1): New option.
* gcc/config/mips/mips.h (OPTION_DEFAULT_SPECS): Add a default for
mlxc1-sxc1.
(TARGET_CPU_CPP_BUILTINS): Add builtin_define for
__mips_no_lxc1_sxc1.
(ISA_HAS_LXC1_SXC1): Gate with mips_lxc1_sxc1.
* gcc/doc/invoke.texi (-mlxc1-sxc1): Document the new option.
* doc/install.texi (--with-lxc1-sxc1): Document the new option.
gcc/testsuite/
* gcc.target/mips/lxc1-sxc1-1.c: New file.
* gcc.target/mips/lxc1-sxc1-2.c: Likewise.
* gcc.target/mips/mips.exp (mips_option_groups): Add ghost option
HAS_LXC1.
(mips_option_groups): Add -m[no-]lxc1-sxc1.
(mips-dg-init): Detect default -mno-lxc1-sxc1.
(mips-dg-options): Handle HAS_LXC1 arch upgrade/downgrade.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@244640 138bc75d-0d04-0410-961f-82ee72b054a4
---
gcc/ChangeLog | 15 ++++++++
gcc/config.gcc | 19 ++++++++-
gcc/config/mips/mips.h | 8 +++-
gcc/config/mips/mips.opt | 4 ++
gcc/doc/install.texi | 19 +++++++++
gcc/doc/invoke.texi | 6 +++
gcc/testsuite/ChangeLog | 11 ++++++
gcc/testsuite/gcc.target/mips/lxc1-sxc1-1.c | 60 +++++++++++++++++++++++++++++
gcc/testsuite/gcc.target/mips/lxc1-sxc1-2.c | 60 +++++++++++++++++++++++++++++
gcc/testsuite/gcc.target/mips/mips.exp | 12 +++++-
10 files changed, 209 insertions(+), 5 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/mips/lxc1-sxc1-1.c
create mode 100644 gcc/testsuite/gcc.target/mips/lxc1-sxc1-2.c
Index: b/src/gcc/config.gcc
===================================================================
--- a/src/gcc/config.gcc
+++ b/src/gcc/config.gcc
@@ -3976,7 +3976,7 @@ case "${target}" in
;;
mips*-*-*)
- supported_defaults="abi arch arch_32 arch_64 float fpu nan fp_32 odd_spreg_32 tune tune_32 tune_64 divide llsc mips-plt synci"
+ supported_defaults="abi arch arch_32 arch_64 float fpu nan fp_32 odd_spreg_32 tune tune_32 tune_64 divide llsc mips-plt synci lxc1-sxc1"
case ${with_float} in
"" | soft | hard)
@@ -4099,6 +4099,21 @@ case "${target}" in
exit 1
;;
esac
+
+ case ${with_lxc1_sxc1} in
+ yes)
+ with_lxc1_sxc1=lxc1-sxc1
+ ;;
+ no)
+ with_lxc1_sxc1=no-lxc1-sxc1
+ ;;
+ "")
+ ;;
+ *)
+ echo "Unknown lxc1-sxc1 type used in --with-lxc1-sxc1" 1>&2
+ exit 1
+ ;;
+ esac
;;
nds32*-*-*)
@@ -4532,7 +4547,7 @@ case ${target} in
esac
t=
-all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu nan fp_32 odd_spreg_32 divide llsc mips-plt synci tls"
+all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu nan fp_32 odd_spreg_32 divide llsc mips-plt synci tls lxc1-sxc1"
for option in $all_defaults
do
eval "val=\$with_"`echo $option | sed s/-/_/g`
Index: b/src/gcc/config/mips/mips.h
===================================================================
--- a/src/gcc/config/mips/mips.h
+++ b/src/gcc/config/mips/mips.h
@@ -619,6 +619,8 @@ struct mips_cpu_info {
\
if (TARGET_CACHE_BUILTIN) \
builtin_define ("__GCC_HAVE_BUILTIN_MIPS_CACHE"); \
+ if (!ISA_HAS_LXC1_SXC1) \
+ builtin_define ("__mips_no_lxc1_sxc1"); \
} \
while (0)
@@ -847,7 +849,8 @@ struct mips_cpu_info {
{"divide", "%{!mdivide-traps:%{!mdivide-breaks:-mdivide-%(VALUE)}}" }, \
{"llsc", "%{!mllsc:%{!mno-llsc:-m%(VALUE)}}" }, \
{"mips-plt", "%{!mplt:%{!mno-plt:-m%(VALUE)}}" }, \
- {"synci", "%{!msynci:%{!mno-synci:-m%(VALUE)}}" }
+ {"synci", "%{!msynci:%{!mno-synci:-m%(VALUE)}}" }, \
+ {"lxc1-sxc1", "%{!mlxc1-sxc1:%{!mno-lxc1-sxc1:-m%(VALUE)}}" } \
/* A spec that infers the:
-mnan=2008 setting from a -mips argument,
@@ -1011,7 +1014,8 @@ struct mips_cpu_info {
/* ISA has floating-point indexed load and store instructions
(LWXC1, LDXC1, SWXC1 and SDXC1). */
-#define ISA_HAS_LXC1_SXC1 ISA_HAS_FP4
+#define ISA_HAS_LXC1_SXC1 (ISA_HAS_FP4 \
+ && mips_lxc1_sxc1)
/* ISA has paired-single instructions. */
#define ISA_HAS_PAIRED_SINGLE ((ISA_MIPS64 \
Index: b/src/gcc/config/mips/mips.opt
===================================================================
--- a/src/gcc/config/mips/mips.opt
+++ b/src/gcc/config/mips/mips.opt
@@ -384,6 +384,10 @@ mlra
Target Report Var(mips_lra_flag) Init(1) Save
Use LRA instead of reload.
+mlxc1-sxc1
+Target Report Var(mips_lxc1_sxc1) Init(1)
+Use lwxc1/swxc1/ldxc1/sdxc1 instructions where applicable.
+
mtune=
Target RejectNegative Joined Var(mips_tune_option) ToLower Enum(mips_arch_opt_value)
-mtune=PROCESSOR Optimize the output for PROCESSOR.
Index: b/src/gcc/testsuite/gcc.target/mips/lxc1-sxc1-1.c
===================================================================
--- /dev/null
+++ b/src/gcc/testsuite/gcc.target/mips/lxc1-sxc1-1.c
@@ -0,0 +1,60 @@
+/* { dg-options "(HAS_LXC1) -mno-lxc1-sxc1" } */
+/* { dg-final { scan-assembler-not "\tldxc1\t" } } */
+/* { dg-final { scan-assembler-not "\tsdxc1\t" } } */
+
+#ifndef __mips_no_lxc1_sxc1
+#error missing definition of __mips_no_lxc1_sxc1
+#endif
+
+double ldexp(double x, int exp);
+
+typedef struct
+{
+ double** rows;
+} d_mat_struct;
+
+typedef d_mat_struct d_mat_t[1];
+
+#define d_mat_entry(mat,i,j) (*((mat)->rows[i] + (j)))
+
+double __attribute__((noinline))
+ldxc1_test (int kappa, int zeros, double ctt, int* expo, d_mat_t r, double* s)
+{
+ int kappa2 = kappa;
+ double tmp = 0.0;
+
+ do
+ {
+ kappa--;
+ if (kappa > zeros + 1)
+ {
+ tmp = d_mat_entry(r, kappa - 1, kappa - 1) * ctt;
+ tmp = ldexp(tmp, (expo[kappa - 1] - expo[kappa2]));
+ }
+ }
+ while ((kappa >= zeros + 2) && (s[kappa - 1] <= tmp));
+
+ return tmp;
+}
+
+#define SIZE 20
+
+int main(void)
+{
+ int kappa = SIZE - 1;
+ int zeros = 1;
+ double ctt = 2;
+
+ int expo[SIZE] = {0};
+ double s[SIZE] = {0};
+ double rows_data[SIZE][SIZE] = {0};
+ double* rows[SIZE];
+
+ for (int i = 0; i < SIZE; i++)
+ rows[i] = rows_data[i];
+
+ d_mat_t r = { rows };
+
+ ldxc1_test(kappa, zeros, ctt, expo, r, s);
+ return 0;
+}
Index: b/src/gcc/testsuite/gcc.target/mips/lxc1-sxc1-2.c
===================================================================
--- /dev/null
+++ b/src/gcc/testsuite/gcc.target/mips/lxc1-sxc1-2.c
@@ -0,0 +1,60 @@
+/* { dg-options "(HAS_LXC1) -mlxc1-sxc1" } */
+/* { dg-skip-if "code quality test" { *-*-* } { "-O0" } { "" } } */
+/* { dg-final { scan-assembler "\tldxc1\t" } } */
+
+#ifdef __mips_no_lxc1_sxc1
+#error unexpected definition of __mips_no_lxc1_sxc1
+#endif
+
+double ldexp(double x, int exp);
+
+typedef struct
+{
+ double** rows;
+} d_mat_struct;
+
+typedef d_mat_struct d_mat_t[1];
+
+#define d_mat_entry(mat,i,j) (*((mat)->rows[i] + (j)))
+
+double __attribute__((noinline))
+ldxc1_test (int kappa, int zeros, double ctt, int* expo, d_mat_t r, double* s)
+{
+ int kappa2 = kappa;
+ double tmp = 0.0;
+
+ do
+ {
+ kappa--;
+ if (kappa > zeros + 1)
+ {
+ tmp = d_mat_entry(r, kappa - 1, kappa - 1) * ctt;
+ tmp = ldexp(tmp, (expo[kappa - 1] - expo[kappa2]));
+ }
+ }
+ while ((kappa >= zeros + 2) && (s[kappa - 1] <= tmp));
+
+ return tmp;
+}
+
+#define SIZE 20
+
+int main(void)
+{
+ int kappa = SIZE - 1;
+ int zeros = 1;
+ double ctt = 2;
+
+ int expo[SIZE] = {0};
+ double s[SIZE] = {0};
+ double rows_data[SIZE][SIZE] = {0};
+ double* rows[SIZE];
+
+ for (int i = 0; i < SIZE; i++)
+ rows[i] = rows_data[i];
+
+ d_mat_t r = { rows };
+
+ ldxc1_test(kappa, zeros, ctt, expo, r, s);
+ return 0;
+}
Index: b/src/gcc/testsuite/gcc.target/mips/mips.exp
===================================================================
--- a/src/gcc/testsuite/gcc.target/mips/mips.exp
+++ b/src/gcc/testsuite/gcc.target/mips/mips.exp
@@ -258,6 +258,7 @@ set mips_option_groups {
madd "HAS_MADD"
maddps "HAS_MADDPS"
lsa "(|!)HAS_LSA"
+ lxc1 "HAS_LXC1"
section_start "-Wl,--section-start=.*"
frame-header "-mframe-header-opt|-mno-frame-header-opt"
stack-protector "-fstack-protector"
@@ -281,6 +282,7 @@ foreach option {
gpopt
local-sdata
long-calls
+ lxc1-sxc1
paired-single
plt
shared
@@ -814,6 +816,12 @@ proc mips-dg-init {} {
"-mno-smartmips",
#endif
+ #ifdef __mips_no_lxc1_sxc1
+ "-mno-lxc1-sxc1",
+ #else
+ "-mlxc1-sxc1"
+ #endif
+
#ifdef __mips_synci
"-msynci",
#else
@@ -1122,8 +1130,9 @@ proc mips-dg-options { args } {
# We need MIPS IV or higher for:
#
#
- } elseif { $isa < 3
- && [mips_have_test_option_p options "HAS_MOVN"] } {
+ } elseif { $isa < 4
++ && ([mips_have_test_option_p options "HAS_LXC1"]
++ || [mips_have_test_option_p options "HAS_MOVN"]) } {
mips_make_test_option options "-mips4"
# We need MIPS III or higher for:
#
@@ -1164,6 +1173,7 @@ proc mips-dg-options { args } {
|| [mips_have_test_option_p options "-mfp32"]
|| [mips_have_test_option_p options "-mfix-r10000"]
|| [mips_have_test_option_p options "NOT_HAS_DMUL"]
+ || [mips_have_test_option_p options "HAS_LXC1"]
|| [mips_have_test_option_p options "HAS_MOVN"]
|| [mips_have_test_option_p options "HAS_MADD"]
|| [mips_have_test_option_p options "-mpaired-single"]
|