]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas: support for the BPF pseudo-c assembly syntax
authorGuillermo E. Martinez <guillermo.e.martinez@oracle.com>
Thu, 20 Apr 2023 14:37:01 +0000 (16:37 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Wed, 26 Apr 2023 17:27:41 +0000 (19:27 +0200)
commitff5a51b377212532a0cf2acea37c6a5672893d8f
tree6659e215c5fc14b8b5b43560dc1da7924f529b71
parent873a1ec4059a2d58899e427a996bf4c3965d93da
gas: support for the BPF pseudo-c assembly syntax

This patch adds support to the GNU assembler for an alternative
assembly syntax used in BPF.  This syntax is C-like and very
unconventional for an assembly language, but it is generated by
clang/llvm and is also used in inline asm templates in kernel code, so
we ought to support it.

After this patch, the assembler is able to parse instructions in both
supported syntax: the normal assembly-like syntax and the pseudo-C
syntax.  Instruction formats can be mixed in the source program: the
assembler recognizes the right syntax to use.

gas/ChangeLog:

2023-04-20  Guillermo E. Martinez  <guillermo.e.martinez@oracle.com>

PR gas/29728
* config/tc-bpf.h (TC_EQUAL_IN_INSN): Define.
* config/tc-bpf.c (LEX_IS_SYMBOL_COMPONENT): Define.
(LEX_IS_WHITESPACE): Likewise.
(LEX_IS_NEWLINE): Likewise.
(LEX_IS_ARITHM_OP): Likewise.
(LEX_IS_STAR): Likewise.
(LEX_IS_CLSE_BR): Likewise.
(LEX_IS_OPEN_BR): Likewise.
(LEX_IS_EQUAL): Likewise.
(LEX_IS_EXCLA): Likewise.
(ST_EOI): Likewise.
(MAX_TOKEN_SZ): Likewise.
(init_pseudoc_lex): New function.
(md_begin): Call init_pseudoc_lex.
(valid_expr): New function.
(build_bpf_non_generic_load): Likewise.
(build_bpf_atomic_insn): Likewise.
(build_bpf_jmp_insn): Likewise.
(build_bpf_arithm_insn): Likewise.
(build_bpf_endianness): Likewise.
(build_bpf_load_store_insn): Likewise.
(look_for_reserved_word): Likewise.
(is_register): Likewise.
(is_cast): Likewise.
(get_token): Likewise.
(bpf_pseudoc_to_normal_syntax): Likewise.
(md_assemble): Try pseudo-C syntax if an instruction cannot be
parsed.
gas/ChangeLog
gas/config/tc-bpf.c
gas/config/tc-bpf.h