cpu: fix offset16 type, update c-calls in bpf.cpu
authorDavid Faust <david.faust@oracle.com>
Thu, 25 Jun 2020 18:34:29 +0000 (20:34 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Thu, 25 Jun 2020 18:34:29 +0000 (20:34 +0200)
Correct the type of the offset16 field to HI, and simplify memory
accesses which use it. Also update c-calls in semantics for a
few instructions.

cpu/ChangeLog:

2020-06-25 David Faust  <david.faust@oracle.com>

* bpf.cpu (f-offset16): Change type from INT to HI.
(dxli): Simplify memory access.
(dxsi): Likewise.
(define-endian-insn): Update c-call in semantics.
(dlabs) Likewise.
(dlind) Likewise.

cpu/ChangeLog
cpu/bpf.cpu

index f2ac243c68e1e70714ba7cff81a039f569649ba7..591ac01f38b01a60fabb19608c0c46ad2b314a2e 100644 (file)
@@ -1,3 +1,12 @@
+2020-06-25 David Faust  <david.faust@oracle.com>
+
+       * bpf.cpu (f-offset16): Change type from INT to HI.
+       (dxli): Simplify memory access.
+       (dxsi): Likewise.
+       (define-endian-insn): Update c-call in semantics.
+       (dlabs) Likewise.
+       (dlind) Likewise.
+
 2020-06-02  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
        * bpf.cpu (define-bpf-isa): Set base-insn-bitsize to 64.
index dcfb0ca8cf1dc8f833277c9b8bf69e2e64297be2..95290f6f4e11a7a12c321ac61d774929fe29620e 100644 (file)
 ;; difficulty: we put them in their own instruction word so the
 ;; byte-endianness will be properly applied.
 
-(dwf f-offset16 "eBPF offset field" (all-isas) 16 16 15 16 INT)
+(dwf f-offset16 "eBPF offset field" (all-isas) 16 16 15 16 HI)
 (dwf f-imm32 "eBPF 32-bit immediate field" (all-isas) 32 32 31 32 INT)
 
 ;; For the disjoint 64-bit signed immediate, however, we need to use a
        (+  (f-offset16 0) ((.sym f-src x-endian) 0) (.sym dst x-endian) endsize
            OP_CLASS_ALU x-op-src OP_CODE_END)
        (set (.sym dst x-endian)
-            (c-call DI "bpfbf_end" (.sym dst x-endian) endsize))
+            (c-call DI (.str "bpfbf_end" x-suffix) (.sym dst x-endian) endsize))
        ()))
 
 (define-endian-insn "le" OP_SRC_K le)
                       (mem DI
                            (add DI
                                 (reg DI h-gpr 6) ;; Pointer to struct sk_buff
-                                (const DI 0)))   ;; XXX offsetof
-                      ;; (struct sk_buff, data) XXX but the offset
-                      ;; depends on CONFIG_* options, so this should
-                      ;; be configured in the simulator and driven by
-                      ;; command-line options.  Handle with a c-call.
+                                (c-call "bpfbf_skb_data_offset")))
                       imm32)))
        ;; XXX this clobbers R1-R5
        ()))
                       (mem DI
                            (add DI
                                 (reg DI h-gpr 6) ;; Pointer to struct sk_buff
-                                (const DI 0)))   ;; XXX offsetof
-                      ;; (struct sk_buff, data) XXX but the offset
-                      ;; depends on CONFIG_* options, so this should
-                      ;; be configured in the simulator and driven by
-                      ;; command-line options.  Handle with a c-call.
+                                (c-call "bpfbf_skb_data_offset")))
                       (add DI
                            (.sym src x-endian)
                            imm32))))
           OP_CLASS_LDX (.sym OP_SIZE_ x-size) OP_MODE_MEM)
        (set x-mode
             (.sym dst x-endian)
-            (mem x-mode (add DI (.sym src x-endian) (ext DI (trunc HI offset16)))))
+            (mem x-mode (add DI (.sym src x-endian) offset16)))
        ()))
 
 (define-pmacro (dxsi x-basename x-suffix x-size x-endian x-mode)
        (+ (f-imm32 0) offset16 (.sym src x-endian) (.sym dst x-endian)
           OP_CLASS_STX (.sym OP_SIZE_ x-size) OP_MODE_MEM)
        (set x-mode
-            (mem x-mode (add DI (.sym dst x-endian) (ext DI (trunc HI offset16))))
+            (mem x-mode (add DI (.sym dst x-endian) offset16))
             (.sym src x-endian)) ;; XXX address is section-relative
        ()))
 
This page took 0.027419 seconds and 4 git commands to generate.