From 890dd98ceb61de168b20acfd0aef1ddeb2cc1f39 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 20 Jul 2025 22:01:36 -0400 Subject: oasm: parse: Add tok_is_xreg() helper Signed-off-by: Ian Moffett --- usr.bin/oasm/include/oasm/lex.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'usr.bin/oasm/include') diff --git a/usr.bin/oasm/include/oasm/lex.h b/usr.bin/oasm/include/oasm/lex.h index 1bb8641..2811ca3 100644 --- a/usr.bin/oasm/include/oasm/lex.h +++ b/usr.bin/oasm/include/oasm/lex.h @@ -119,4 +119,35 @@ struct oasm_token { int lex_tok(struct oasm_state *state, struct oasm_token *ttp); + +/* + * Check if a token is an X register. + * Returns true on match. + */ +__always_inline static inline bool +tok_is_xreg(tt_t tok) +{ + switch (tok) { + case TT_X0: + case TT_X1: + case TT_X2: + case TT_X3: + case TT_X4: + case TT_X5: + case TT_X6: + case TT_X7: + case TT_X8: + case TT_X9: + case TT_X10: + case TT_X11: + case TT_X12: + case TT_X13: + case TT_X14: + case TT_X15: + return true; + } + + return false; +} + #endif /* !_OASM_LEX_H_ */ -- cgit v1.2.3