summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/include
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-20 22:01:36 -0400
committerIan Moffett <ian@osmora.org>2025-07-20 22:04:53 -0400
commit890dd98ceb61de168b20acfd0aef1ddeb2cc1f39 (patch)
tree2d08d2f6c8e088b19e27f745da5e21e737344738 /usr.bin/oasm/include
parent7a43fb95afa4cee74b2282f38789bbc363b86dd7 (diff)
oasm: parse: Add tok_is_xreg() helper
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm/include')
-rw-r--r--usr.bin/oasm/include/oasm/lex.h31
1 files changed, 31 insertions, 0 deletions
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<n> 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_ */