Hi Paul, Just a few additional comments, mostly typos and a little cleanup.
>gcc/ > * config/mips/mips-protos.h > (mips_loongson_ext2_prefetch_cookie): New prototype. > * config/mips/mips.c (mips_loongson_ext2_prefetch_cookie): New. > (mips_option_override): Enable TARGET_LOONGSON_EXT when > TARGET_LOONGSON_EXT2 is true. > * config/mips/mips.h (TARGET_CPU_CPP_BUILTINS): Define > __mips_loongson_ext2, __mips_loongson_ext_rev=2. > (ISA_HAS_CTZ_CTO): New, ture if TARGET_LOONGSON_EXT2. typo: true > (ISA_HAS_PREFETCH): Include TARGET_LOONGSON_EXT and > TARGET_LOONGSON_EXT2. > (ASM_SPEC): Add mloongson-ext2 and mno-loongson-ext2. > (define_insn "ctz<mode>2"): New insn pattern. > (define_insn "prefetch"): Include TARGET_LOONGSON_EXT2. > (define_insn "prefetch_indexed_<mode>"): Include > TARGET_LOONGSON_EXT and TARGET_LOONGSON_EXT2. > * config/mips/mips.opt (-mloongson-ext2): Add option. > * gcc/doc/invoke.texi (-mloongson-ext2): Document. > >gcc/testsuite/ > * gcc.target/mips/loongson-ctz.c: New test. > * gcc.target/mips/loongson-dctz.c: Likewise. > * gcc.target/mips/mips.exp (mips_option_groups): Add > -mloongson-ext2 option. >--- > gcc/config/mips/mips-protos.h | 1 + > gcc/config/mips/mips.c | 28 +++++++++++++++ > gcc/config/mips/mips.h | 15 +++++++- > gcc/config/mips/mips.md | 47 ++++++++++++++++++++++-- > gcc/config/mips/mips.opt | 4 ++ > gcc/doc/invoke.texi | 7 ++++ > gcc/testsuite/gcc.target/mips/loongson-ctz.c | 11 ++++++ > gcc/testsuite/gcc.target/mips/loongson-dctz.c | 11 ++++++ > gcc/testsuite/gcc.target/mips/mips.exp | 1 + > 9 files changed, 120 insertions(+), 5 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/mips/loongson-ctz.c > create mode 100644 gcc/testsuite/gcc.target/mips/loongson-dctz.c > >diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c >index b579c3c..1c20750 100644 >--- a/gcc/config/mips/mips.c >+++ b/gcc/config/mips/mips.c >@@ -20171,6 +20187,18 @@ mips_option_override (void) > if (TARGET_LOONGSON_MMI && !TARGET_HARD_FLOAT_ABI) > error ("%<-mloongson-mmi%> must be used with %<-mhard-float%>"); > >+ /* If TARGET_LOONGSON_EXT2, enable TARGET_LOONGSON_EXT. */ >+ if (TARGET_LOONGSON_EXT2) >+ { >+ /* Make sure that when TARGET_LOONGSON_EXT2 is true, TARGET_LOONGSON_EXT >+ is true. If a user explicitly says -mloongson-ext2 -mno-loongson-ext >+ then that is an error. */ >+ if (!TARGET_LOONGSON_EXT >+ && !((target_flags_explicit & MASK_LOONGSON_EXT) == 0)) Bit of a brain twister, how about: (target_flags_explicit & MASK_LOONGSON_EXT) != 0 >diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h >index 7237c8d..beeb4bc 100644 >--- a/gcc/config/mips/mips.h >+++ b/gcc/config/mips/mips.h >@@ -1134,6 +1141,9 @@ struct mips_cpu_info { > /* ISA has count leading zeroes/ones instruction (not implemented). */ > #define ISA_HAS_CLZ_CLO (mips_isa_rev >= 1 && !TARGET_MIPS16) > >+/* ISA has count tailing zeroes/ones instruction. */ typo: trailing >diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md >index 4b7a627..8358218 100644 >--- a/gcc/config/mips/mips.md >+++ b/gcc/config/mips/mips.md >@@ -7136,13 +7153,20 @@ > (match_operand 2 "const_int_operand" "n"))] > "ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS" > { >- if (TARGET_LOONGSON_2EF || TARGET_LOONGSON_EXT) >+ if (TARGET_LOONGSON_2EF || TARGET_LOONGSON_EXT || TARGET_LOONGSON_EXT2) > { >- /* Loongson 2[ef] and Loongson 3a use load to $0 for prefetching. */ >+ /* Loongson ext2 implementation pref insnstructions. */ typo: instructions. >+ if (TARGET_LOONGSON_EXT2) >+ { >+ operands[1] = mips_loongson_ext2_prefetch_cookie (operands[1], >+ operands[2]); >+ return "pref\t%1, %a0"; >+ } It's not a big deal but it would be cleaner to hoist this above the 2EF/EXT block as it is totally independent. Same for the prefx case. >@@ -7156,6 +7180,21 @@ > (match_operand 3 "const_int_operand" "n"))] > "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" > { >+ if (TARGET_LOONGSON_EXT || TARGET_LOONGSON_EXT2) >+ { >+ /* Loongson ext2 implementation pref insnstructions. */ typo: instructions. >+ if (TARGET_LOONGSON_EXT2) >+ { >+ operands[2] = mips_loongson_ext2_prefetch_cookie (operands[2], >+ operands[3]); >+ return "prefx\t%2,%1(%0)"; >+ } >diff --git a/gcc/testsuite/gcc.target/mips/loongson-ctz.c >b/gcc/testsuite/gcc.target/mips/loongson-ctz.c >new file mode 100644 >index 0000000..8df66a0 >--- /dev/null >+++ b/gcc/testsuite/gcc.target/mips/loongson-ctz.c >@@ -0,0 +1,11 @@ >+/* Test cases for Loongson EXT2 instrutions. */ typo: instructions. >diff --git a/gcc/testsuite/gcc.target/mips/loongson-dctz.c >b/gcc/testsuite/gcc.target/mips/loongson-dctz.c >new file mode 100644 >index 0000000..8c47433 >--- /dev/null >+++ b/gcc/testsuite/gcc.target/mips/loongson-dctz.c >@@ -0,0 +1,11 @@ >+/* Test cases for Loongson EXT2 instrutions. */ typo: instructions. With those changes this is OK to commit. For the record... after some minor fixes that we discussed off-thread, the following are all good to go too. You should post the final patches that you commit for the list though. https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00912.html https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00909.html https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00910.html https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00914.html https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00911.html https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00913.html Thanks, Matthew