From 3999578cc522eb57d65c00c9293ca88cfbd901c2 Mon Sep 17 00:00:00 2001 From: Monk Chiang Date: Sun, 11 Mar 2018 07:48:48 +0000 Subject: [PATCH] [NDS32] Add intrinsic function for ffb, ffmism and flmism. gcc/ * config/nds32/constants.md (unspec_element): Add UNSPEC_FFB, UNSPEC_FFMISM and UNSPEC_FLMISM. * config/nds32/nds32-intrinsic.c (bdesc_2arg): Add builtin description for ffb, ffmism and flmism. * config/nds32/nds32-intrinsic.md (unspec_ffb): Define new pattern. (unspec_ffmism): Ditto. (unspec_flmism): Ditto. (nds32_expand_builtin_impl): Check if string extension is available. * config/nds32/nds32.h (nds32_builtins): Add NDS32_BUILTIN_FFB, NDS32_BUILTIN_FFMISM and NDS32_BUILTIN_FLMISM. Co-Authored-By: Chung-Ju Wu Co-Authored-By: Kito Cheng From-SVN: r258424 --- gcc/ChangeLog | 15 +++++++++++++ gcc/config/nds32/constants.md | 3 +++ gcc/config/nds32/nds32-intrinsic.c | 20 +++++++++++++++++ gcc/config/nds32/nds32-intrinsic.md | 34 +++++++++++++++++++++++++++++ gcc/config/nds32/nds32.h | 3 +++ 5 files changed, 75 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c84ccbe190..0cdc24fdbc5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2018-03-11 Monk Chiang + Kito Cheng + Chung-Ju Wu + + * config/nds32/constants.md (unspec_element): Add UNSPEC_FFB, + UNSPEC_FFMISM and UNSPEC_FLMISM. + * config/nds32/nds32-intrinsic.c (bdesc_2arg): Add builtin description + for ffb, ffmism and flmism. + * config/nds32/nds32-intrinsic.md (unspec_ffb): Define new pattern. + (unspec_ffmism): Ditto. + (unspec_flmism): Ditto. + (nds32_expand_builtin_impl): Check if string extension is available. + * config/nds32/nds32.h (nds32_builtins): Add NDS32_BUILTIN_FFB, + NDS32_BUILTIN_FFMISM and NDS32_BUILTIN_FLMISM. + 2018-03-10 Vladimir Makarov Reverting patch: diff --git a/gcc/config/nds32/constants.md b/gcc/config/nds32/constants.md index 803534bb4ad..482e39ecfba 100644 --- a/gcc/config/nds32/constants.md +++ b/gcc/config/nds32/constants.md @@ -32,6 +32,9 @@ ;; The unpec operation index. (define_c_enum "unspec_element" [ + UNSPEC_FFB + UNSPEC_FFMISM + UNSPEC_FLMISM UNSPEC_UALOAD_HW UNSPEC_UALOAD_W UNSPEC_UALOAD_DW diff --git a/gcc/config/nds32/nds32-intrinsic.c b/gcc/config/nds32/nds32-intrinsic.c index bf51154c8ca..636b1d1139f 100644 --- a/gcc/config/nds32/nds32-intrinsic.c +++ b/gcc/config/nds32/nds32-intrinsic.c @@ -257,6 +257,9 @@ static struct builtin_description bdesc_1argimm[] = /* Intrinsics that take two arguments. */ static struct builtin_description bdesc_2arg[] = { + NDS32_BUILTIN(unspec_ffb, "ffb", FFB) + NDS32_BUILTIN(unspec_ffmism, "ffmsim", FFMISM) + NDS32_BUILTIN(unspec_flmism, "flmism", FLMISM) NDS32_NO_TARGET_BUILTIN(unspec_volatile_mtsr, "mtsr", MTSR) NDS32_NO_TARGET_BUILTIN(unspec_volatile_mtusr, "mtusr", MTUSR) NDS32_NO_TARGET_BUILTIN(unaligned_store_hw, "unaligned_store_hw", UASTORE_HW) @@ -277,6 +280,23 @@ nds32_expand_builtin_impl (tree exp, unsigned i; struct builtin_description *d; + switch (fcode) + { + /* String Extension */ + case NDS32_BUILTIN_FFB: + case NDS32_BUILTIN_FFMISM: + case NDS32_BUILTIN_FLMISM: + if (!TARGET_EXT_STRING) + { + error ("don't support string extension instructions"); + return NULL_RTX; + } + break; + + default: + break; + } + /* Since there are no result and operands, we can simply emit this rtx. */ switch (fcode) { diff --git a/gcc/config/nds32/nds32-intrinsic.md b/gcc/config/nds32/nds32-intrinsic.md index a4a32ceea95..5a07f89fa55 100644 --- a/gcc/config/nds32/nds32-intrinsic.md +++ b/gcc/config/nds32/nds32-intrinsic.md @@ -94,6 +94,40 @@ [(set_attr "type" "misc")] ) +;; String Extension + +(define_insn "unspec_ffb" + [(set (match_operand:SI 0 "register_operand" "=r, r") + (unspec:SI [(match_operand:SI 1 "register_operand" "r, r") + (match_operand:SI 2 "nonmemory_operand" "Iu08, r")] UNSPEC_FFB))] + "" + "@ + ffbi\t%0, %1, %2 + ffb\t%0, %1, %2" + [(set_attr "type" "alu") + (set_attr "length" "4")] +) + +(define_insn "unspec_ffmism" + [(set (match_operand:SI 0 "register_operand" "=r") + (unspec:SI [(match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "register_operand" "r")] UNSPEC_FFMISM))] + "" + "ffmism\t%0, %1, %2" + [(set_attr "type" "alu") + (set_attr "length" "4")] +) + +(define_insn "unspec_flmism" + [(set (match_operand:SI 0 "register_operand" "=r") + (unspec:SI [(match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "register_operand" "r")] UNSPEC_FLMISM))] + "" + "flmism\t%0, %1, %2" + [(set_attr "type" "alu") + (set_attr "length" "4")] +) + ;;Unaligned Load/Store (define_expand "unaligned_load_hw" diff --git a/gcc/config/nds32/nds32.h b/gcc/config/nds32/nds32.h index 6e67165ae11..1c812f77579 100644 --- a/gcc/config/nds32/nds32.h +++ b/gcc/config/nds32/nds32.h @@ -346,6 +346,9 @@ enum nds32_builtins NDS32_BUILTIN_MTUSR, NDS32_BUILTIN_SETGIE_EN, NDS32_BUILTIN_SETGIE_DIS, + NDS32_BUILTIN_FFB, + NDS32_BUILTIN_FFMISM, + NDS32_BUILTIN_FLMISM, NDS32_BUILTIN_UALOAD_HW, NDS32_BUILTIN_UALOAD_W, NDS32_BUILTIN_UALOAD_DW, -- 2.30.2