summaryrefslogtreecommitdiff
path: root/bpf_parser.y
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-09-06 11:03:20 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-09-06 11:03:20 +0200
commit382b08547cc61faf10d94cffef890ce0dc85609c (patch)
tree78f52958ae09f048ceec77acc27427e616ca5274 /bpf_parser.y
parent220e83ebb195e958e36ea7ed13c54b61d23e6558 (diff)
bpfc: add gnu as style %-register prefix
Let a and x register also be addressed as %x and %a. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'bpf_parser.y')
-rw-r--r--bpf_parser.y69
1 files changed, 68 insertions, 1 deletions
diff --git a/bpf_parser.y b/bpf_parser.y
index 48a6e4c..c8d2a8f 100644
--- a/bpf_parser.y
+++ b/bpf_parser.y
@@ -135,7 +135,7 @@ static int find_intr_offset_or_panic(char *label_to_search)
%token K_PKT_LEN K_PROTO K_TYPE K_NLATTR K_NLATTR_NEST K_MARK K_QUEUE K_HATYPE
%token K_RXHASH K_CPU K_IFIDX K_VLANT K_VLANP K_POFF
-%token ':' ',' '[' ']' '(' ')' 'x' 'a' '+' 'M' '*' '&' '#'
+%token ':' ',' '[' ']' '(' ')' 'x' 'a' '+' 'M' '*' '&' '#' '%'
%token number label
@@ -198,6 +198,8 @@ labelled
ldb
: OP_LDB '[' 'x' '+' number ']' {
set_curr_instr(BPF_LD | BPF_B | BPF_IND, 0, 0, $5); }
+ | OP_LDB '[' '%' 'x' '+' number ']' {
+ set_curr_instr(BPF_LD | BPF_B | BPF_IND, 0, 0, $6); }
| OP_LDB '[' number ']' {
set_curr_instr(BPF_LD | BPF_B | BPF_ABS, 0, 0, $3); }
| OP_LDB K_PROTO {
@@ -244,6 +246,8 @@ ldb
ldh
: OP_LDH '[' 'x' '+' number ']' {
set_curr_instr(BPF_LD | BPF_H | BPF_IND, 0, 0, $5); }
+ | OP_LDH '[' '%' 'x' '+' number ']' {
+ set_curr_instr(BPF_LD | BPF_H | BPF_IND, 0, 0, $6); }
| OP_LDH '[' number ']' {
set_curr_instr(BPF_LD | BPF_H | BPF_ABS, 0, 0, $3); }
| OP_LDH K_PROTO {
@@ -342,6 +346,8 @@ ld
set_curr_instr(BPF_LD | BPF_MEM, 0, 0, $4); }
| OP_LD '[' 'x' '+' number ']' {
set_curr_instr(BPF_LD | BPF_W | BPF_IND, 0, 0, $5); }
+ | OP_LD '[' '%' 'x' '+' number ']' {
+ set_curr_instr(BPF_LD | BPF_W | BPF_IND, 0, 0, $6); }
| OP_LD '[' number ']' {
set_curr_instr(BPF_LD | BPF_W | BPF_ABS, 0, 0, $3); }
;
@@ -397,12 +403,19 @@ jeq
set_jmp_label($4, JTL);
set_jmp_label($6, JFL);
set_curr_instr(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 0); }
+ | OP_JEQ '%' 'x' ',' label ',' label {
+ set_jmp_label($5, JTL);
+ set_jmp_label($7, JFL);
+ set_curr_instr(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 0); }
| OP_JEQ '#' number ',' label {
set_jmp_label($5, JTL);
set_curr_instr(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, $3); }
| OP_JEQ 'x' ',' label {
set_jmp_label($4, JTL);
set_curr_instr(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 0); }
+ | OP_JEQ '%' 'x' ',' label {
+ set_jmp_label($5, JTL);
+ set_curr_instr(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 0); }
;
jneq
@@ -412,6 +425,9 @@ jneq
| OP_JNEQ 'x' ',' label {
set_jmp_label($4, JFL);
set_curr_instr(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 0); }
+ | OP_JNEQ '%' 'x' ',' label {
+ set_jmp_label($5, JFL);
+ set_curr_instr(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 0); }
;
jlt
@@ -421,6 +437,9 @@ jlt
| OP_JLT 'x' ',' label {
set_jmp_label($4, JFL);
set_curr_instr(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 0); }
+ | OP_JLT '%' 'x' ',' label {
+ set_jmp_label($5, JFL);
+ set_curr_instr(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 0); }
;
jle
@@ -430,6 +449,9 @@ jle
| OP_JLE 'x' ',' label {
set_jmp_label($4, JFL);
set_curr_instr(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 0); }
+ | OP_JLE '%' 'x' ',' label {
+ set_jmp_label($5, JFL);
+ set_curr_instr(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 0); }
;
jgt
@@ -441,12 +463,19 @@ jgt
set_jmp_label($4, JTL);
set_jmp_label($6, JFL);
set_curr_instr(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 0); }
+ | OP_JGT '%' 'x' ',' label ',' label {
+ set_jmp_label($5, JTL);
+ set_jmp_label($7, JFL);
+ set_curr_instr(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 0); }
| OP_JGT '#' number ',' label {
set_jmp_label($5, JTL);
set_curr_instr(BPF_JMP | BPF_JGT | BPF_K, 0, 0, $3); }
| OP_JGT 'x' ',' label {
set_jmp_label($4, JTL);
set_curr_instr(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 0); }
+ | OP_JGT '%' 'x' ',' label {
+ set_jmp_label($5, JTL);
+ set_curr_instr(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 0); }
;
jge
@@ -458,12 +487,19 @@ jge
set_jmp_label($4, JTL);
set_jmp_label($6, JFL);
set_curr_instr(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 0); }
+ | OP_JGE '%' 'x' ',' label ',' label {
+ set_jmp_label($5, JTL);
+ set_jmp_label($7, JFL);
+ set_curr_instr(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 0); }
| OP_JGE '#' number ',' label {
set_jmp_label($5, JTL);
set_curr_instr(BPF_JMP | BPF_JGE | BPF_K, 0, 0, $3); }
| OP_JGE 'x' ',' label {
set_jmp_label($4, JTL);
set_curr_instr(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 0); }
+ | OP_JGE '%' 'x' ',' label {
+ set_jmp_label($5, JTL);
+ set_curr_instr(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 0); }
;
jset
@@ -475,12 +511,19 @@ jset
set_jmp_label($4, JTL);
set_jmp_label($6, JFL);
set_curr_instr(BPF_JMP | BPF_JSET | BPF_X, 0, 0, 0); }
+ | OP_JSET '%' 'x' ',' label ',' label {
+ set_jmp_label($5, JTL);
+ set_jmp_label($7, JFL);
+ set_curr_instr(BPF_JMP | BPF_JSET | BPF_X, 0, 0, 0); }
| OP_JSET '#' number ',' label {
set_jmp_label($5, JTL);
set_curr_instr(BPF_JMP | BPF_JSET | BPF_K, 0, 0, $3); }
| OP_JSET 'x' ',' label {
set_jmp_label($4, JTL);
set_curr_instr(BPF_JMP | BPF_JSET | BPF_X, 0, 0, 0); }
+ | OP_JSET '%' 'x' ',' label {
+ set_jmp_label($5, JTL);
+ set_curr_instr(BPF_JMP | BPF_JSET | BPF_X, 0, 0, 0); }
;
add
@@ -488,6 +531,8 @@ add
set_curr_instr(BPF_ALU | BPF_ADD | BPF_K, 0, 0, $3); }
| OP_ADD 'x' {
set_curr_instr(BPF_ALU | BPF_ADD | BPF_X, 0, 0, 0); }
+ | OP_ADD '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_ADD | BPF_X, 0, 0, 0); }
;
sub
@@ -495,6 +540,8 @@ sub
set_curr_instr(BPF_ALU | BPF_SUB | BPF_K, 0, 0, $3); }
| OP_SUB 'x' {
set_curr_instr(BPF_ALU | BPF_SUB | BPF_X, 0, 0, 0); }
+ | OP_SUB '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_SUB | BPF_X, 0, 0, 0); }
;
mul
@@ -502,6 +549,8 @@ mul
set_curr_instr(BPF_ALU | BPF_MUL | BPF_K, 0, 0, $3); }
| OP_MUL 'x' {
set_curr_instr(BPF_ALU | BPF_MUL | BPF_X, 0, 0, 0); }
+ | OP_MUL '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_MUL | BPF_X, 0, 0, 0); }
;
div
@@ -509,6 +558,8 @@ div
set_curr_instr(BPF_ALU | BPF_DIV | BPF_K, 0, 0, $3); }
| OP_DIV 'x' {
set_curr_instr(BPF_ALU | BPF_DIV | BPF_X, 0, 0, 0); }
+ | OP_DIV '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_DIV | BPF_X, 0, 0, 0); }
;
mod
@@ -516,6 +567,8 @@ mod
set_curr_instr(BPF_ALU | BPF_MOD | BPF_K, 0, 0, $3); }
| OP_MOD 'x' {
set_curr_instr(BPF_ALU | BPF_MOD | BPF_X, 0, 0, 0); }
+ | OP_MOD '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_MOD | BPF_X, 0, 0, 0); }
;
neg
@@ -528,6 +581,8 @@ and
set_curr_instr(BPF_ALU | BPF_AND | BPF_K, 0, 0, $3); }
| OP_AND 'x' {
set_curr_instr(BPF_ALU | BPF_AND | BPF_X, 0, 0, 0); }
+ | OP_AND '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_AND | BPF_X, 0, 0, 0); }
;
or
@@ -535,6 +590,8 @@ or
set_curr_instr(BPF_ALU | BPF_OR | BPF_K, 0, 0, $3); }
| OP_OR 'x' {
set_curr_instr(BPF_ALU | BPF_OR | BPF_X, 0, 0, 0); }
+ | OP_OR '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_OR | BPF_X, 0, 0, 0); }
;
xor
@@ -542,6 +599,8 @@ xor
set_curr_instr(BPF_ALU | BPF_XOR | BPF_K, 0, 0, $3); }
| OP_XOR 'x' {
set_curr_instr(BPF_ALU | BPF_XOR | BPF_X, 0, 0, 0); }
+ | OP_XOR '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_XOR | BPF_X, 0, 0, 0); }
;
lsh
@@ -549,6 +608,8 @@ lsh
set_curr_instr(BPF_ALU | BPF_LSH | BPF_K, 0, 0, $3); }
| OP_LSH 'x' {
set_curr_instr(BPF_ALU | BPF_LSH | BPF_X, 0, 0, 0); }
+ | OP_LSH '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_LSH | BPF_X, 0, 0, 0); }
;
rsh
@@ -556,13 +617,19 @@ rsh
set_curr_instr(BPF_ALU | BPF_RSH | BPF_K, 0, 0, $3); }
| OP_RSH 'x' {
set_curr_instr(BPF_ALU | BPF_RSH | BPF_X, 0, 0, 0); }
+ | OP_RSH '%' 'x' {
+ set_curr_instr(BPF_ALU | BPF_RSH | BPF_X, 0, 0, 0); }
;
ret
: OP_RET 'a' {
set_curr_instr(BPF_RET | BPF_A, 0, 0, 0); }
+ | OP_RET '%' 'a' {
+ set_curr_instr(BPF_RET | BPF_A, 0, 0, 0); }
| OP_RET 'x' {
set_curr_instr(BPF_RET | BPF_X, 0, 0, 0); }
+ | OP_RET '%' 'x' {
+ set_curr_instr(BPF_RET | BPF_X, 0, 0, 0); }
| OP_RET '#' number {
set_curr_instr(BPF_RET | BPF_K, 0, 0, $3); }
;