[PATCH RISU v2 07/13] contrib/generate_all: Do not rely on ag

Richard Henderson posted 13 patches 6 months ago
[PATCH RISU v2 07/13] contrib/generate_all: Do not rely on ag
Posted by Richard Henderson 6 months ago
Use plain grep instead.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 contrib/generate_all.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/generate_all.sh b/contrib/generate_all.sh
index 651cb23..5ff0b3e 100755
--- a/contrib/generate_all.sh
+++ b/contrib/generate_all.sh
@@ -78,8 +78,8 @@ fi
 
 mkdir -p ${TARGET_DIR}
 
-ALL_INSNS=$(cat ${RISU_FILE} | ag "^\w" | cut -f 1 -d " " | sort)
-COUNT=$(cat ${RISU_FILE=} | ag "^\w" | cut -f 1 -d " " | wc -l)
+ALL_INSNS=$(cat ${RISU_FILE} | grep "^[A-Za-z]" | cut -f 1 -d " " | sort)
+COUNT=$(cat ${RISU_FILE=} | grep "^[A-Za-z]" | cut -f 1 -d " " | wc -l)
 set -- $ALL_INSNS
 
 GROUP=$((COUNT / ${SPLIT}))
-- 
2.34.1
Re: [PATCH RISU v2 07/13] contrib/generate_all: Do not rely on ag
Posted by Peter Maydell 5 months, 4 weeks ago
On Sun, 26 May 2024 at 20:38, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Use plain grep instead.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  contrib/generate_all.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/generate_all.sh b/contrib/generate_all.sh
> index 651cb23..5ff0b3e 100755
> --- a/contrib/generate_all.sh
> +++ b/contrib/generate_all.sh
> @@ -78,8 +78,8 @@ fi
>
>  mkdir -p ${TARGET_DIR}
>
> -ALL_INSNS=$(cat ${RISU_FILE} | ag "^\w" | cut -f 1 -d " " | sort)
> -COUNT=$(cat ${RISU_FILE=} | ag "^\w" | cut -f 1 -d " " | wc -l)
> +ALL_INSNS=$(cat ${RISU_FILE} | grep "^[A-Za-z]" | cut -f 1 -d " " | sort)
> +COUNT=$(cat ${RISU_FILE=} | grep "^[A-Za-z]" | cut -f 1 -d " " | wc -l)
>  set -- $ALL_INSNS

risugen's definition of the regex matching an insn name in
parse_config_file() is
  ^[A-Za-z0-9][A-Za-z0-9_]*$

I think we should be consistent with that. (PCRE \w isn't
quite the same as it allows a leading underscore and also
various unicode letters, but it's closer than [A-Za-z].)

(As it happens we don't have any current insn patterns
that take advantage of the ability to start with a number.
So if you'd prefer to define insn names starting with a
number to be invalid and change risugen instead that's
fine too.)

thanks
-- PMM