head	1.2;
access;
symbols
	perseant-exfatfs-base-20261102:1.2
	netbsd-10-2-RELEASE:1.1.1.1
	perseant-exfatfs-base-20250801:1.2
	netbsd-10-1-RELEASE:1.1.1.1
	perseant-exfatfs-base-20240630:1.1.1.2
	perseant-exfatfs:1.1.1.2.0.2
	perseant-exfatfs-base:1.1.1.2
	netbsd-10-0-RELEASE:1.1.1.1
	netbsd-10-0-RC6:1.1.1.1
	netbsd-10-0-RC5:1.1.1.1
	netbsd-10-0-RC4:1.1.1.1
	netbsd-10-0-RC3:1.1.1.1
	netbsd-10-0-RC2:1.1.1.1
	netbsd-10-0-RC1:1.1.1.1
	gdb-13-2:1.1.1.2
	netbsd-10:1.1.1.1.0.6
	netbsd-10-base:1.1.1.1
	cjep_sun2x-base1:1.1.1.1
	cjep_sun2x:1.1.1.1.0.4
	cjep_sun2x-base:1.1.1.1
	cjep_staticlib_x-base1:1.1.1.1
	cjep_staticlib_x:1.1.1.1.0.2
	cjep_staticlib_x-base:1.1.1.1
	GDB-11-0-50-20200914-git:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.2
date	2024.08.12.22.09.29;	author christos;	state dead;
branches;
next	1.1;
commitid	SgpE5gT1sdUybAlF;

1.1
date	2020.09.15.01.42.13;	author christos;	state Exp;
branches
	1.1.1.1;
next	;
commitid	N511ReXja24bg5oC;

1.1.1.1
date	2020.09.15.01.42.13;	author christos;	state Exp;
branches;
next	1.1.1.2;
commitid	N511ReXja24bg5oC;

1.1.1.2
date	2023.07.30.22.44.40;	author christos;	state Exp;
branches
	1.1.1.2.2.1;
next	;
commitid	HEIv4Prd74m1wSyE;

1.1.1.2.2.1
date	2025.08.02.05.26.39;	author perseant;	state dead;
branches;
next	;
commitid	23j6GFaDws3O875G;


desc
@@


1.2
log
@Merge conflicts between 13.2 and 15.1
@
text
@;; Linux BPF CPU description  -*- Scheme -*-
;; Copyright (C) 2019 Free Software Foundation, Inc.
;;
;; Contributed by Oracle Inc.
;;
;; This file is part of the GNU Binutils and of GDB.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3 of the
;; License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
;; 02110-1301, USA.

;; This file contains a CGEN CPU description for the Linux kernel eBPF
;; instruction set.  eBPF is documented in the linux kernel source
;; tree.  See linux/Documentation/networking/filter.txt, and also the
;; sources in the networking subsystem, notably
;; linux/net/core/filter.c.

(include "simplify.inc")

(define-arch
  (name bpf)
  (comment "Linux kernel BPF")
  (insn-lsb0? #t)
  ;; XXX explain the default-alignment setting is for the simulator.
  ;; It is confusing that the simulator follows the emulated memory
  ;; access conventions for fetching instructions by pieces...
  (default-alignment unaligned)
  (machs bpf xbpf)
  (isas ebpfle ebpfbe xbpfle xbpfbe))

;;;; The ISAs

;; Logically, eBPF comforms a single instruction set featuring two
;; kind of instructions: 64-bit instructions and 128-bit instructions.
;;
;; The 64-bit instructions have the form:
;;
;;      code:8 regs:8 offset:16 imm:32
;;
;; Whereas the 128-bit instructions (at the moment there is only one
;; of such instructions, lddw) have the form:
;;
;;      code:8 regs:8 offset:16 imm:32 unused:32 imm:32 
;;
;; In both formats `regs' is itself composed by two fields:
;;
;;      dst:4 src:4
;;
;; The ISA is supposed to be orthogonal to endianness: the endianness
;; of the instruction fields follow the endianness of the host running
;; the eBPF program, and that's all.  However, this is not entirely
;; true.  The definition of an eBPF code in the Linux kernel is:
;;
;; struct bpf_insn {
;;	__u8	code;		/* opcode */
;;	__u8	dst_reg:4;	/* dest register */
;;	__u8	src_reg:4;	/* source register */
;;	__s16	off;		/* signed offset */
;;	__s32	imm;		/* signed immediate constant */
;; };
;;
;; Since the ordering of fields in C bitmaps is defined by the
;; implementation, the impact of endianness in the encoding of eBPF
;; instructions is effectively defined by GCC.  In particular, GCC
;; places dst_reg before src_reg in little-endian code, and the other
;; way around in big-endian code.
;;
;; So, in reality, eBPF comprises two instruction sets: one for
;; little-endian with instructions like:
;;
;;   code:8 src:4 dst:4 offset:16 imm:32 [unused:32 imm:32]
;;
;; and another for big-endian with instructions like:
;;
;;   code:8 dst:4 src:4 offset:16 imm:32 [unused:32 imm:32]
;;
;; where `offset' and the immediate fields are encoded in
;; little-endian and big-endian byte-order, respectively.

(define-pmacro (define-bpf-isa x-endian)
  (define-isa
    (name (.sym ebpf x-endian))
    (comment "The eBPF instruction set")
    ;; Default length to record in ifields.  This is used in
    ;; calculations involving bit numbers.
    (default-insn-word-bitsize 64)
    ;; Length of an unknown instruction.  Used by disassembly and by the
    ;; simulator's invalid insn handler.
    (default-insn-bitsize 64)
    ;; Number of bits of insn that can be initially fetched.  This is
    ;; the size of the smallest insn.
    (base-insn-bitsize 64)))

(define-bpf-isa le)
(define-bpf-isa be)

(define-pmacro (define-xbpf-isa x-endian)
  (define-isa
    (name (.sym xbpf x-endian))
    (comment "The xBPF instruction set")
    (default-insn-word-bitsize 64)
    (default-insn-bitsize 64)
    (base-insn-bitsize 64)))

(define-xbpf-isa le)
(define-xbpf-isa be)

(define-pmacro all-isas () (ISA ebpfle,ebpfbe,xbpfle,xbpfbe))
(define-pmacro xbpf-isas () (ISA xbpfle,xbpfbe))

(define-pmacro (endian-isas x-endian)
  ((ISA (.sym ebpf x-endian) (.sym xbpf x-endian))))

;;;; Hardware Hierarchy

;;
;;         bpf            architecture
;;          |
;;        bpfbf           cpu-family
;;      /       \
;;     bpf     xbpf       machine
;;      |       |
;;   bpf-def  xbpf-def    model

(define-cpu
  (name bpfbf)
  (comment "Linux kernel eBPF virtual CPU")
  (insn-endian big)
  (word-bitsize 64))

(define-mach
  (name bpf)
  (comment "Linux eBPF")
  (cpu bpfbf)
  (isas ebpfle ebpfbe))

(define-model
  (name bpf-def)
  (comment "Linux eBPF default model")
  (mach bpf)
  (unit u-exec "execution unit" ()
    1 ; issue
    1 ; done
    () ; state
    () ; inputs
    () ; outputs
    () ; profile action (default)
    ))

(define-mach
  (name xbpf)
  (comment "Experimental BPF")
  (cpu bpfbf)
  (isas ebpfle ebpfbe xbpfle xbpfbe))

(define-model
  (name xbpf-def)
  (comment "xBPF default model")
  (mach xbpf)
  (unit u-exec "execution unit" ()
    1 ; issue
    1 ; done
    () ; state
    () ; inputs
    () ; outputs
    () ; profile action (default)
    ))

;;;; Hardware Elements

;; eBPF programs can access 10 general-purpose registers which are
;; 64-bit.

(define-hardware
  (name h-gpr)
  (comment "General Purpose Registers")
  (attrs all-isas (MACH bpf xbpf))
  (type register DI (16))
  (indices keyword "%"
           ;; XXX the frame pointer fp is read-only, so it should
           ;; go in a different hardware.
           (;; ABI names.  Take priority when disassembling.
            (r0 0) (r1 1) (r2 2) (r3 3) (r4 4) (r5 5) (r6 6)
            (r7 7) (r8 8) (r9 9) (fp 10)
            ;; Additional names recognized when assembling.
            (r0 0) (r6 6) (r10 10))))

;; The program counter.  CGEN requires it, even if it is not visible
;; to eBPF programs.

(define-hardware
  (name h-pc)
  (comment "program counter")
  (attrs PC PROFILE all-isas)
  (type pc UDI)
  (get () (raw-reg h-pc))
  (set (newval) (set (raw-reg h-pc) newval)))
  
;; A 64-bit h-sint to be used by the imm64 operand below.  XXX this
;; shouldn't be needed, as h-sint is supposed to be able to hold
;; 64-bit values.  However, in practice CGEN limits h-sint to 32 bits
;; in 32-bit hosts.  To be fixed in CGEN.

(dnh h-sint64 "signed 64-bit integer" (all-isas) (immediate DI)
     () () ())

;;;; The Instruction Sets

;;; Fields and Opcodes

;; Convenience macro to shorten the definition of the fields below.
(define-pmacro (dwf x-name x-comment x-attrs
                    x-word-offset x-word-length x-start x-length
                    x-mode)
  "Define a field including its containing word."
  (define-ifield
    (name x-name)
    (comment x-comment)
    (.splice attrs (.unsplice x-attrs))
    (word-offset x-word-offset)
    (word-length x-word-length)
    (start x-start)
    (length x-length)
    (mode x-mode)))

;; For arithmetic and jump instructions the 8-bit code field is
;; subdivided in:
;;
;;  op-code:4 op-src:1 op-class:3

(dwf f-op-code "eBPF opcode code" (all-isas) 0 8 7 4 UINT)
(dwf f-op-src "eBPF opcode source" (all-isas) 0 8 3 1 UINT)
(dwf f-op-class "eBPF opcode instruction class" (all-isas) 0 8 2 3 UINT)

(define-normal-insn-enum insn-op-code-alu "eBPF instruction codes"
  (all-isas) OP_CODE_ f-op-code
  (;; Codes for OP_CLASS_ALU and OP_CLASS_ALU64
   (ADD #x0) (SUB #x1) (MUL #x2) (DIV #x3) (OR #x4) (AND #x5)
   (LSH #x6) (RSH #x7) (NEG #x8) (MOD #x9) (XOR #xa) (MOV #xb)
   (ARSH #xc) (END #xd)
   ;; Codes for OP_CLASS_JMP
   (JA #x0) (JEQ #x1) (JGT #x2) (JGE #x3) (JSET #x4)
   (JNE #x5) (JSGT #x6) (JSGE #x7) (CALL #x8) (EXIT #x9)
   (JLT #xa) (JLE #xb) (JSLT #xc) (JSLE #xd)))

(define-normal-insn-enum insn-op-src "eBPF instruction source"
  (all-isas) OP_SRC_ f-op-src
  ;; X => use `src' as source operand.
  ;; K => use `imm32' as source operand.
  ((K #b0) (X #b1)))

(define-normal-insn-enum insn-op-class "eBPF instruction class"
  (all-isas) OP_CLASS_ f-op-class
  ((LD    #b000) (LDX   #b001) (ST    #b010) (STX   #b011)
   (ALU   #b100) (JMP   #b101) (JMP32 #b110) (ALU64 #b111)))

;; For load/store instructions, the 8-bit code field is subdivided in:
;;
;; op-mode:3 op-size:2 op-class:3

(dwf f-op-mode "eBPF opcode mode" (all-isas) 0 8 7 3 UINT)
(dwf f-op-size "eBPF opcode size" (all-isas) 0 8 4 2 UINT)

(define-normal-insn-enum insn-op-mode "eBPF load/store instruction modes"
  (all-isas) OP_MODE_ f-op-mode
  ((IMM #b000) (ABS #b001) (IND #b010) (MEM #b011)
   ;; #b100 and #b101 are used in classic BPF only, reserved in eBPF.
   (XADD #b110)))

(define-normal-insn-enum insn-op-size "eBPF load/store instruction sizes"
  (all-isas) OP_SIZE_ f-op-size
  ((W  #b00)   ;; Word:        4 byte
   (H  #b01)   ;; Half-word:   2 byte
   (B  #b10)   ;; Byte:        1 byte
   (DW #b11))) ;; Double-word: 8 byte

;; The fields for the source and destination registers are a bit
;; tricky.  Due to the bizarre nibble swap between little-endian and
;; big-endian ISAs we need to keep different variants of the fields.
;;
;; Note that f-regs is used in the format spec of instructions that do
;; NOT use registers, where endianness is irrelevant i.e. f-regs is a
;; constant 0 opcode.

(dwf f-dstle "eBPF dst register field" ((ISA ebpfle xbpfle)) 8 8 3 4 UINT)
(dwf f-srcle "eBPF source register field" ((ISA ebpfle xbpfle)) 8 8 7 4 UINT)

(dwf f-dstbe "eBPF dst register field" ((ISA ebpfbe xbpfbe)) 8 8 7 4 UINT)
(dwf f-srcbe "eBPF source register field" ((ISA ebpfbe xbpfbe)) 8 8 3 4 UINT)

(dwf f-regs "eBPF registers field" (all-isas) 8 8 7 8 UINT)

;; Finally, the fields for the immediates.
;;
;; The 16-bit offsets and 32-bit immediates do not present any special
;; 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 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
;; multi-ifield.

(dwf f-imm64-a "eBPF 64-bit immediate a" (all-isas) 32 32 31 32 UINT)
(dwf f-imm64-b "eBPF 64-bit immediate b" (all-isas) 64 32 31 32 UINT)
(dwf f-imm64-c "eBPF 64-bit immediate c" (all-isas) 96 32 31 32 UINT)

(define-multi-ifield
  (name f-imm64)
  (comment "eBPF 64-bit immediate field")
  (attrs all-isas)
  (mode DI)
  (subfields f-imm64-a f-imm64-b f-imm64-c)
  (insert (sequence ()
                    (set (ifield f-imm64-b) (const 0))
                    (set (ifield f-imm64-c) (srl (ifield f-imm64) (const 32)))
                    (set (ifield f-imm64-a) (and (ifield f-imm64) (const #xffffffff)))))
  (extract (sequence ()
                     (set (ifield f-imm64)
                          (or (sll UDI (zext UDI (ifield f-imm64-c)) (const 32))
                              (zext UDI (ifield f-imm64-a)))))))

;;; Operands

;; A couple of source and destination register operands are defined
;; for each ISA: ebpfle and ebpfbe.

(dno dstle "destination register" ((ISA ebpfle xbpfle)) h-gpr f-dstle)
(dno srcle "source register" ((ISA ebpfle xbpfle)) h-gpr f-srcle)

(dno dstbe "destination register" ((ISA ebpfbe xbpfbe)) h-gpr f-dstbe)
(dno srcbe "source register" ((ISA ebpfbe xbpfbe)) h-gpr f-srcbe)

;; Jump instructions have a 16-bit PC-relative address.
;; CALL instructions have a 32-bit PC-relative address.

(dno disp16 "16-bit PC-relative address" (all-isas PCREL-ADDR) h-sint
     f-offset16)
(dno disp32 "32-bit PC-relative address" (all-isas PCREL-ADDR) h-sint
     f-imm32)

;; Immediate operands in eBPF are signed, and we want the disassembler
;; to print negative values in a sane way.  Therefore we use the macro
;; below to register a printer, which is itself defined as a C
;; function in bpf.opc.

;; define-normal-signed-immediate-operand
(define-pmacro (dnsio x-name x-comment x-attrs x-type x-index)
  (define-operand
    (name x-name)
    (comment x-comment)
    (.splice attrs (.unsplice x-attrs))
    (type x-type)
    (index x-index)
    (handlers (print "immediate"))))

(dnsio imm32 "32-bit immediate" (all-isas) h-sint f-imm32)
(dnsio offset16 "16-bit offset" (all-isas) h-sint f-offset16)

;; The 64-bit immediate cannot use the default
;; cgen_parse_signed_integer, because it assumes operands are at much
;; 32-bit wide.  Use our own.

(define-operand
  (name imm64)
  (comment "64-bit immediate")
  (attrs all-isas)
  (type h-sint64)
  (index f-imm64)
  (handlers (parse "imm64") (print "immediate")))

;; The endle/endbe instructions take an operand to specify the word
;; width in endianness conversions.  We use both a parser and printer,
;; which are defined as C functions in bpf.opc.

(define-operand
  (name endsize)
  (comment "endianness size immediate: 16, 32 or 64")
  (attrs all-isas)
  (type h-uint)
  (index f-imm32)
  (handlers (parse "endsize") (print "endsize")))

;;; ALU instructions

;; For each opcode in insn-op-code-alu representing and integer
;; arithmetic instruction (ADD, SUB, etc) we define a bunch of
;; instruction variants:
;;
;;   ADD[32]{i,r}le for the little-endian ISA
;;   ADD[32]{i,r}be for the big-endian ISA
;;
;; The `i' variants perform `dst OP imm32 -> dst' operations.
;; The `r' variants perform `dst OP src -> dst' operations.
;;
;; The variants with 32 in their name are of ALU class.  Otherwise
;; they are ALU64 class.

(define-pmacro (define-alu-insn-un x-basename x-suffix x-op-class x-op-code
                 x-endian x-mode x-semop)
  (dni (.sym x-basename x-suffix x-endian)
       (.str x-basename x-suffix)
       (endian-isas x-endian)
       (.str x-basename x-suffix " $dst" x-endian)
       (+ (f-imm32 0) (f-offset16 0) ((.sym f-src x-endian) 0) (.sym dst x-endian)
          x-op-class OP_SRC_K x-op-code)
       (set x-mode (.sym dst x-endian) (x-semop x-mode (.sym dst x-endian)))
       ()))

(define-pmacro (define-alu-insn-bin x-basename x-suffix x-op-class x-op-code
                 x-endian x-mode x-semop)
  (begin
    ;; dst = dst OP immediate
    (dni (.sym x-basename x-suffix "i" x-endian)
         (.str x-basename x-suffix " immediate")
         (endian-isas x-endian)
         (.str x-basename x-suffix " $dst" x-endian ",$imm32")
         (+ imm32 (f-offset16 0) ((.sym f-src x-endian) 0) (.sym dst x-endian)
            x-op-class OP_SRC_K x-op-code)
         (set x-mode (.sym dst x-endian) (x-semop x-mode (.sym dst x-endian) imm32))
         ())
    ;; dst = dst OP src
    (dni (.sym x-basename x-suffix "r" x-endian)
         (.str x-basename x-suffix " register")
         (endian-isas x-endian)
         (.str x-basename x-suffix " $dst" x-endian ",$src" x-endian)
         (+ (f-imm32 0) (f-offset16 0) (.sym src x-endian) (.sym dst x-endian)
            x-op-class OP_SRC_X x-op-code)
         (set x-mode (.sym dst x-endian)
                      (x-semop x-mode (.sym dst x-endian) (.sym src x-endian)))
         ())))

(define-pmacro (define-alu-insn-mov x-basename x-suffix x-op-class x-op-code
                 x-endian x-mode)
  (begin
    (dni (.sym mov x-suffix "i" x-endian)
         (.str mov x-suffix " immediate")
         (endian-isas x-endian)
         (.str x-basename x-suffix " $dst" x-endian ",$imm32")
         (+ imm32 (f-offset16 0) ((.sym f-src x-endian) 0) (.sym dst x-endian)
            x-op-class OP_SRC_K x-op-code)
         (set x-mode (.sym dst x-endian) imm32)
         ())
    (dni (.sym mov x-suffix "r" x-endian)
         (.str mov x-suffix " register")
         (endian-isas x-endian)
         (.str x-basename x-suffix " $dst" x-endian ",$src" x-endian)
         (+ (f-imm32 0) (f-offset16 0) (.sym src x-endian) (.sym dst x-endian)
            x-op-class OP_SRC_X x-op-code)
         (set x-mode (.sym dst x-endian) (.sym src x-endian))
         ())))


;; Unary ALU instructions (neg)
(define-pmacro (daiu x-basename x-op-code x-endian x-semop)
  (begin
    (define-alu-insn-un x-basename "" OP_CLASS_ALU64 x-op-code x-endian DI x-semop)
    (define-alu-insn-un x-basename "32" OP_CLASS_ALU x-op-code x-endian USI x-semop)))

;; Binary ALU instructions (all the others)
;; For ALU32: DST = (u32) DST OP (u32) SRC is correct semantics
(define-pmacro (daib x-basename x-op-code x-endian x-semop)
  (begin
    (define-alu-insn-bin x-basename "" OP_CLASS_ALU64 x-op-code x-endian DI x-semop)
    (define-alu-insn-bin x-basename "32" OP_CLASS_ALU x-op-code x-endian USI x-semop)))

;; Move ALU instructions (mov)
(define-pmacro (daim x-basename x-op-code x-endian)
  (begin
    (define-alu-insn-mov x-basename "" OP_CLASS_ALU64 x-op-code x-endian DI)
    (define-alu-insn-mov x-basename "32" OP_CLASS_ALU x-op-code x-endian USI)))

(define-pmacro (define-alu-instructions x-endian)
  (begin
    (daib add OP_CODE_ADD x-endian add)
    (daib sub OP_CODE_SUB x-endian sub)
    (daib mul OP_CODE_MUL x-endian mul)
    (daib div OP_CODE_DIV x-endian udiv)
    (daib or  OP_CODE_OR x-endian or)
    (daib and OP_CODE_AND x-endian and)
    (daib lsh OP_CODE_LSH x-endian sll)
    (daib rsh OP_CODE_RSH x-endian srl)
    (daib mod OP_CODE_MOD x-endian umod)
    (daib xor OP_CODE_XOR x-endian xor)
    (daib arsh OP_CODE_ARSH x-endian sra)
    (daiu neg OP_CODE_NEG x-endian neg)
    (daim mov OP_CODE_MOV x-endian)))

(define-alu-instructions le)
(define-alu-instructions be)

;;; Endianness conversion instructions

;; The endianness conversion instructions come in several variants:
;;
;;  END{le,be}le for the little-endian ISA
;;  END{le,be}be for the big-endian ISA
;;
;; Please do not be confused by the repeated `be' and `le' here.  Each
;; ISA has both endle and endbe instructions.  It is the disposition
;; of the source and destination register fields that change between
;; ISAs, not the semantics of the instructions themselves (see section
;; "The ISAs" above in this very file.)

(define-pmacro (define-endian-insn x-suffix x-op-src x-endian)
  (dni (.sym "end" x-suffix x-endian)
       (.str "end" x-suffix " register")
       (endian-isas x-endian)
       (.str "end" x-suffix " $dst" x-endian ",$endsize")
       (+  (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 (.str "bpfbf_end" x-suffix) (.sym dst x-endian) endsize))
       ()))

(define-endian-insn "le" OP_SRC_K le)
(define-endian-insn "be" OP_SRC_X le)
(define-endian-insn "le" OP_SRC_K be)
(define-endian-insn "be" OP_SRC_X be)

;;; Load/Store instructions

;; The lddw instruction takes a 64-bit immediate as an operand.  Since
;; this instruction also takes a `dst' operand, we need to define a
;; variant for each ISA:
;;
;;  LDDWle for the little-endian ISA
;;  LDDWbe for the big-endian ISA  

(define-pmacro (define-lddw x-endian)
  (dni (.sym lddw x-endian)
       (.str "lddw" x-endian)
       (endian-isas x-endian)
       (.str "lddw $dst" x-endian ",$imm64")
       (+ imm64 (f-offset16 0) ((.sym f-src x-endian) 0)
          (.sym dst x-endian)
          OP_CLASS_LD OP_SIZE_DW OP_MODE_IMM)
       (set DI (.sym dst x-endian) imm64)
       ()))

(define-lddw le)
(define-lddw be)

;; The absolute load instructions are non-generic loads designed to be
;; used in socket filters.  They come in several variants:
;;
;; LDABS{w,h,b,dw}

(define-pmacro (dlabs x-suffix x-size x-smode)
  (dni (.sym "ldabs" x-suffix)
       (.str "ldabs" x-suffix)
       (all-isas)
       (.str "ldabs" x-suffix " $imm32")
       (+ imm32 (f-offset16 0) (f-regs 0)
          OP_CLASS_LD OP_MODE_ABS (.sym OP_SIZE_ x-size))
       (set x-smode
            (reg x-smode h-gpr 0)
            (mem x-smode
                 (add DI
                      (mem DI
                           (add DI
                                (reg DI h-gpr 6) ;; Pointer to struct sk_buff
                                (c-call "bpfbf_skb_data_offset")))
                      imm32)))
       ;; XXX this clobbers R1-R5
       ()))

(dlabs "w" W SI)
(dlabs "h" H HI)
(dlabs "b" B QI)
(dlabs "dw" DW DI)

;; The indirect load instructions are non-generic loads designed to be
;; used in socket filters.  They come in several variants:
;;
;; LDIND{w,h,b,dw}le for the little-endian ISA
;; LDIND[w,h,b,dw}be for the big-endian ISA

(define-pmacro (dlind x-suffix x-size x-endian x-smode)
  (dni (.sym "ldind" x-suffix x-endian)
       (.str "ldind" x-suffix)
       (endian-isas x-endian)
       (.str "ldind" x-suffix " $src" x-endian ",$imm32")
       (+ imm32 (f-offset16 0) ((.sym f-dst x-endian) 0) (.sym src x-endian)
          OP_CLASS_LD OP_MODE_IND (.sym OP_SIZE_ x-size))
       (set x-smode
            (reg x-smode h-gpr 0)
            (mem x-smode
                 (add DI
                      (mem DI
                           (add DI
                                (reg DI h-gpr 6) ;; Pointer to struct sk_buff
                                (c-call "bpfbf_skb_data_offset")))
                      (add DI
                           (.sym src x-endian)
                           imm32))))
       ;; XXX this clobbers R1-R5
       ()))

(define-pmacro (define-ldind x-endian)
  (begin    
    (dlind "w" W x-endian SI)
    (dlind "h" H x-endian HI)
    (dlind "b" B x-endian QI)
    (dlind "dw" DW x-endian DI)))

(define-ldind le)
(define-ldind be)

;; Generic load and store instructions are provided for several word
;; sizes.  They come in several variants:
;;
;;  LDX{b,h,w,dw}le, STX{b,h,w,dw}le for the little-endian ISA
;;
;;  LDX{b,h,w,dw}be, STX{b,h,w,dw}be for the big-endian ISA
;;
;; Loads operate on [$SRC+-OFFSET] -> $DST
;; Stores operate on $SRC -> [$DST+-OFFSET]

(define-pmacro (dxli x-basename x-suffix x-size x-endian x-mode)
  (dni (.sym x-basename x-suffix x-endian)
       (.str x-basename x-suffix)
       (endian-isas x-endian)
       (.str x-basename x-suffix " $dst" x-endian ",[$src" x-endian "+$offset16]")
       (+ (f-imm32 0) offset16 (.sym src x-endian) (.sym dst x-endian)
          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) offset16)))
       ()))

(define-pmacro (dxsi x-basename x-suffix x-size x-endian x-mode)
  (dni (.sym x-basename x-suffix x-endian)
       (.str x-basename x-suffix)
       (endian-isas x-endian)
       (.str x-basename x-suffix " [$dst" x-endian "+$offset16],$src" x-endian)
       (+ (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) offset16))
            (.sym src x-endian)) ;; XXX address is section-relative
       ()))

(define-pmacro (define-ldstx-insns x-endian)
  (begin
    (dxli "ldx" "w" W x-endian SI)
    (dxli "ldx" "h" H x-endian HI)
    (dxli "ldx" "b" B x-endian QI)
    (dxli "ldx" "dw" DW x-endian DI)

    (dxsi "stx" "w" W x-endian SI)
    (dxsi "stx" "h" H x-endian HI)
    (dxsi "stx" "b" B x-endian QI)
    (dxsi "stx" "dw" DW x-endian DI)))

(define-ldstx-insns le)
(define-ldstx-insns be)

;; Generic store instructions of the form IMM32 -> [$DST+OFFSET] are
;; provided in several variants:
;;
;;  ST{b,h,w,dw}le for the little-endian ISA
;;  ST{b,h,w,dw}be for the big-endian ISA

(define-pmacro (dsti x-suffix x-size x-endian x-mode)
  (dni (.sym "st" x-suffix x-endian)
       (.str "st" x-suffix)
       (endian-isas x-endian)
       (.str "st" x-suffix " [$dst" x-endian "+$offset16],$imm32")
       (+ imm32 offset16 ((.sym f-src x-endian) 0) (.sym dst x-endian)
          OP_CLASS_ST (.sym OP_SIZE_ x-size) OP_MODE_MEM)
       (set x-mode
            (mem x-mode (add DI (.sym dst x-endian) offset16))
            imm32) ;; XXX address is section-relative
       ()))

(define-pmacro (define-st-insns x-endian)
  (begin
    (dsti "b" B x-endian QI)
    (dsti "h" H x-endian HI)
    (dsti "w" W x-endian SI)
    (dsti "dw" DW x-endian DI)))

(define-st-insns le)
(define-st-insns be)

;;; Jump instructions

;; Compare-and-jump instructions, on the other hand, make use of
;; registers.  Therefore, we need to define several variants in both
;; ISAs:
;;
;;   J{eq,gt,ge,lt,le,set,ne,sgt,sge,slt,sle}[32]{i,r}le for the
;;   little-endian ISA.
;;   J{eq,gt,ge,lt,le,set,ne.sgt,sge,slt,sle}[32]{i,r}be for the
;;   big-endian ISA.

(define-pmacro (define-cond-jump-insn x-cond x-suffix x-op-class x-op-code x-endian x-mode x-semop)
  (begin
    (dni (.sym j x-cond x-suffix i x-endian)
         (.str j x-cond x-suffix " i")
         (endian-isas x-endian)
         (.str "j" x-cond x-suffix " $dst" x-endian ",$imm32,$disp16")
         (+ imm32 disp16 ((.sym f-src x-endian) 0) (.sym dst x-endian)
            x-op-class OP_SRC_K (.sym OP_CODE_ x-op-code))
         (if VOID (x-semop x-mode (.sym dst x-endian) imm32)
             (set DI
                  (reg DI h-pc) (add DI (reg DI h-pc)
                                     (mul DI (add HI disp16 1) 8))))
         ())
    (dni (.sym j x-cond x-suffix r x-endian)
         (.str j x-cond x-suffix " r")
         (endian-isas x-endian)
         (.str "j" x-cond x-suffix " $dst" x-endian ",$src" x-endian ",$disp16")
         (+ (f-imm32 0) disp16 (.sym src x-endian) (.sym dst x-endian)
            x-op-class OP_SRC_X (.sym OP_CODE_ x-op-code))
         (if VOID (x-semop x-mode (.sym dst x-endian) (.sym src x-endian))
             (set DI
                  (reg DI h-pc) (add DI (reg DI h-pc)
                                     (mul DI (add HI disp16 1) 8))))
         ())))

(define-pmacro (dcji x-cond x-op-code x-endian x-semop)
  (begin
    (define-cond-jump-insn x-cond "" OP_CLASS_JMP x-op-code x-endian DI x-semop)
    (define-cond-jump-insn x-cond "32" OP_CLASS_JMP32 x-op-code x-endian SI x-semop )))

(define-pmacro (define-condjump-insns x-endian)
  (begin
    (dcji "eq" JEQ x-endian eq)
    (dcji "gt" JGT x-endian gtu)
    (dcji "ge" JGE x-endian geu)
    (dcji "lt" JLT x-endian ltu)
    (dcji "le" JLE x-endian leu)
    (dcji "set" JSET x-endian and)
    (dcji "ne" JNE x-endian ne)
    (dcji "sgt" JSGT x-endian gt)
    (dcji "sge" JSGE x-endian ge)
    (dcji "slt" JSLT x-endian lt)
    (dcji "sle" JSLE x-endian le)))

(define-condjump-insns le)
(define-condjump-insns be)

;; The `call' instruction doesn't make use of registers, but the
;; semantic routine should have access to the src register in order to
;; properly interpret the meaning of disp32.  Therefore we need one
;; version per ISA.

(define-pmacro (define-call-insn x-endian)
  (dni (.sym call x-endian)
       "call"
       (endian-isas x-endian)
       "call $disp32"
       (+ disp32 (f-offset16 0) (f-regs 0)
          OP_CLASS_JMP OP_SRC_K OP_CODE_CALL)
       (c-call VOID
               "bpfbf_call" disp32 (ifield (.sym f-src x-endian)))
       ()))

(define-call-insn le)
(define-call-insn be)

(define-pmacro (define-callr-insn x-endian)
  (dni (.sym callr x-endian)
       "callr"
       ((ISA (.sym xbpf x-endian)))
       (.str "call $dst" x-endian)
       (+ (f-imm32 0) (f-offset16 0) ((.sym f-src x-endian) 0) (.sym dst x-endian)
          OP_CLASS_JMP OP_SRC_X OP_CODE_CALL)
       (c-call VOID
               "bpfbf_callr" (ifield (.sym f-dst x-endian)))
       ()))

(define-callr-insn le)
(define-callr-insn be)

;; The jump-always and `exit' instructions dont make use of either
;; source nor destination registers, so only one variant per
;; instruction is defined.

(dni ja "ja" (all-isas) "ja $disp16"
     (+ (f-imm32 0) disp16 (f-regs 0)
        OP_CLASS_JMP OP_SRC_K OP_CODE_JA)
     (set DI (reg DI h-pc) (add DI (reg DI h-pc)
                                (mul DI (add HI disp16 1) 8)))
     ())

(dni "exit" "exit" (all-isas) "exit"
     (+ (f-imm32 0) (f-offset16 0) (f-regs 0)
        OP_CLASS_JMP (f-op-src 0) OP_CODE_EXIT)
     (c-call VOID "bpfbf_exit")
     ())

;;; Atomic instructions

;; The atomic exchange-and-add instructions come in two flavors: one
;; for swapping 64-bit quantities and another for 32-bit quantities.

(define-pmacro (sem-exchange-and-add x-endian x-mode)
  (sequence VOID ((x-mode tmp))
            ;; XXX acquire lock in simulator...  as a hardware element?
            (set x-mode tmp (mem x-mode (add DI (.sym dst x-endian) offset16)))
            (set x-mode
                 (mem x-mode (add DI (.sym dst x-endian) offset16))
                 (add x-mode tmp (.sym src x-endian)))))

(define-pmacro (define-atomic-insns x-endian)
  (begin
    (dni (.str "xadddw" x-endian)
         "xadddw"
         (endian-isas x-endian)
         (.str "xadddw [$dst" x-endian "+$offset16],$src" x-endian)
         (+ (f-imm32 0) (.sym src x-endian) (.sym dst x-endian)
            offset16 OP_MODE_XADD OP_SIZE_DW OP_CLASS_STX)
         (sem-exchange-and-add x-endian DI)
         ())
    (dni (.str "xaddw" x-endian)
         "xaddw"
         (endian-isas x-endian)
         (.str "xaddw [$dst" x-endian "+$offset16],$src" x-endian)
         (+ (f-imm32 0) (.sym src x-endian) (.sym dst x-endian)
            offset16 OP_MODE_XADD OP_SIZE_W OP_CLASS_STX)
         (sem-exchange-and-add x-endian SI)
         ())))

(define-atomic-insns le)
(define-atomic-insns be)

;;; Breakpoint instruction

;; The brkpt instruction is used by the BPF simulator and it doesn't
;; really belong to the eBPF instruction set.

(dni "brkpt" "brkpt" (all-isas)  "brkpt"
     (+ (f-imm32 0) (f-offset16 0) (f-regs 0)
        OP_CLASS_ALU OP_SRC_X OP_CODE_NEG)
     (c-call VOID "bpfbf_breakpoint")
     ())
@


1.1
log
@Initial revision
@
text
@@


1.1.1.1
log
@Import head of gdb as of 2020-09-14 requested by Kamil

2020-07-24  Aaron Merey  <amerey@@redhat.com>

	* configure: Rebuild.
	* configure.ac: Remove AC_DEBUGINFOD.

2020-07-04  Nick Clifton  <nickc@@redhat.com>

	Binutils 2.35 branch created.

2020-04-21  Stephen Casner  <casner@@acm.org>

	PR 25830
	* configure.ac (noconfigdirs): Exclude gdb & gprof for pdp11.
	* configure: Rebuild.

2020-03-12  Tom Tromey  <tom@@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def (gdbserver): Depend on gdbsupport.

2020-03-12  Tom Tromey  <tom@@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def (gdbsupport): Don't depend on bfd.

2020-03-12  Tom Tromey  <tom@@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def (gdbsupport): Depend on intl.

2020-02-17  Tom Tromey  <tom@@tromey.com>

	* configure: Rebuild.
	* configure.ac (configdirs): Add gnulib and gdbsupport when building
	gdbserver.

2020-02-14  Tom Tromey  <tom@@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def: Make gdbserver require gnulib and libiberty.

2020-02-07  Tom Tromey  <tom@@tromey.com>
	    Pedro Alves  <palves@@redhat.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gdbserver.
	* gdbserver: New directory, moved from gdb/gdbserver.
	* configure.ac (host_tools): Add gdbserver.
	Only build gdbserver on certain systems.
	* Makefile.in, configure: Rebuild.
	* Makefile.def (host_modules, dependencies): Add gdbserver.
	* MAINTAINERS: Add gdbserver.

2020-01-28  Sergio Durigan Junior  <sergiodj@@redhat.com>

	* src-release.sh (getver): Look for gdbsupport's
	create-version.sh script at the current directory if tool is
	"gdb".

2020-01-19  Simon Marchi  <simon.marchi@@polymtl.ca>

	* remote-sim.c (gdbsim_target::wait): Return
	sim_data->remote_sim_ptid instead of inferior_ptid.

2020-01-18  Nick Clifton  <nickc@@redhat.com>

	Binutils 2.34 branch created.

2020-01-18  Nick Clifton  <nickc@@redhat.com>

	Synchronize top level configure files with master version:

	2020-01-01  Ben Elliston  <bje@@gnu.org>

	* config.guess: Update copyright years.
	* config.sub: Likewise.

	2019-12-21  Ben Elliston  <bje@@gnu.org>

	* config.guess (set_cc_for_build): Prevent multiple calls by
	checking if $tmp is already set. We can't check CC_FOR_BUILD as
	the user may set it externally. Thanks to Torbjörn Granlund for
	the bug report.

	2019-12-21  Torbjörn Granlund  <tg@@gmplib.org>

	* config.guess (alpha:Linux:*:*): Guard against missing
	/proc/cpuinfo by redirecting standard error to /dev/null.

	2019-09-12  Daniel Bittman  <danielbittman1@@gmail.com>

	* config.guess (*:Twizzler:*:*): New.
	* config.sub (-twizzler*): New.

	2019-07-24  Ben Elliston  <bje@@gnu.org>

	* config.guess (mips:OSF1:*.*): Whitespace cleanup.

	2019-06-30  Ben Elliston  <bje@@gnu.org>

	* config.sub (case $os): Match nsk* and powerunix. Don't later
	match nsk* and set os=nsk which removes the OS version number.

	2019-06-30  Ben Elliston  <bje@@gnu.org>

	* config.sub: Recognise os108*.

	2019-06-26  Ben Elliston  <bje@@gnu.org>

	* config.sub (hp300): Set $os to hpux.

	2019-06-26  Ben Elliston  <bje@@gnu.org>

	* config.sub (vsta): Move into alphabetical order.

	2019-06-10  Ben Elliston  <bje@@gnu.org>

	* config.guess (*:OS108:*:*): Recognise new OS.

	2019-05-28  Ben Elliston  <bje@@gnu.org>

	* config.guess (*:Darwin:*:*): Run xcode-select to determine if a
	system compiler is installed. If not, do not run set_cc_for_build,
	as the default cc will open a dialog box asking to install
	Xcode. If no C compiler is available, guess based on uname -p and
	uname -m.

	2019-05-28  Ben Elliston  <bje@@gnu.org>

	* config.guess (*:Darwin:*:*): Simplify UNAME_PROCESSOR.

2020-01-17  Simon Marchi  <simon.marchi@@efficios.com>

	* Makefile.def: Add dependencies of all-gdbsupport on all-bfd.
	* Makefile.in: Re-generate.

2020-01-14  Tom Tromey  <tom@@tromey.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gdbsupport.
	* MAINTAINERS: Add gdbsupport.
	* configure: Rebuild.
	* configure.ac (configdirs): Add gdbsupport.
	* gdbsupport: New directory, move from gdb/gdbsupport.
	* Makefile.def (host_modules, dependencies): Add gnulib.
	* Makefile.in: Rebuild.

2020-01-09  Aaron Merey  <amerey@@redhat.com>

        * config/debuginfod.m4: New file. Add macro AC_DEBUGINFOD. Adds
        new configure option --with-debuginfod.
        * configure: Regenerate.
        * configure.ac: Call AC_DEBUGINFOD.

2019-12-26  Christian Biesinger  <cbiesinger@@google.com>

	* .gitignore: Add perf.data and perf.data.old.

2019-10-17  Sergio Durigan Junior  <sergiodj@@redhat.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add libctf.

2019-10-17  Alan Modra  <amodra@@gmail.com>

	PR 29
	* src-release.sh (getver): Replace "head -1" with "head -n 1".

2019-07-30  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (host_modules): libctf is no longer no_install.
	* Makefile.in: Regenerated.

2019-07-13  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (dependencies): all-ld depends on all-libctf.
	* Makefile.in: Regenerated.

2019-09-09  Phil Blundell  <pb@@pbcl.net>

	binutils 2.33 branch created

2019-08-19  Tom Tromey  <tom@@tromey.com>

	* configure: Rebuild.
	* configure.ac: Add --with-static-standard-libraries.

2019-08-09  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Sync with gcc.  Bring in:
	2019-08-08  Martin Liska  <mliska@@suse.cz>

	PR bootstrap/91352
	* lrealpath.c (is_valid_fd): New function.

	2019-07-24  Martin Liska  <mliska@@suse.cz>

	PR lto/91228
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Find first '\0' starting from gnu_lto + 1.

	2019-07-12  Ren Kimura  <rkx1209dev@@gmail.com>

	* simple-object-elf.c (simple_object_elf_match): Check zero value shstrndx.
	This fixes a Bug 90924.

	2019-07-22  Martin Liska  <mliska@@suse.cz>

	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Do not search for gnu_lto_v1, but search for first '\0'.

	2019-07-18  Eduard-Mihai Burtescu  <eddyb@@lyken.rs>

	* cplus-dem.c: Include rust-demangle.h.
	* rust-demangle.c: Include rust-demangle.h.
	* rust-demangle.h: New file.

	2019-05-31  Michael Forney  <mforney@@mforney.org>

	* cp-demangle.c: Don't define CP_DYNAMIC_ARRAYS if __STDC_NO_VLA__
	is non-zero.

	2019-04-30  Ben L  <bobsayshilol@@live.co.uk>

	* d-demangle.c (dlang_parse_assocarray): Correctly handle error result.
	* testsuite/d-demangle-expected: Add testcase.

	* d-demangle.c (dlang_parse_tuple): Correctly handle error result.
	* testsuite/d-demangle-expected: Add testcase.

	* d-demangle.c (dlang_parse_structlit): Correctly handle error result.
	* testsuite/d-demangle-expected: Add testcase.

	* d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result.
	* testsuite/d-demangle-expected: Add testcase.

	* d-demangle.c (dlang_parse_integer): Fix stack underflow.
	* testsuite/d-demangle-expected: Add testcase.

	* cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'.
	* testsuite/demangle-expected: Add testcase.

	* cp-demangle.c (d_encoding): Guard against NULL return values from
	d_right (dc).
	* testsuite/demangle-expected: Add testcase.

	2019-04-29  Ben L  <bobsayshilol@@live.co.uk>

	* cp-demangle.c (d_expression_1): Don't peek ahead unless the current
	char is valid.
	* testsuite/demangle-expected: Add testcase.

	2019-04-10  Nick Clifton  <nickc@@redhat.com>

	PR 89394
	* cp-demangle.c (cplus_demangle_fill_name): Reject negative
	lengths.
	(d_count_templates_scopes): Replace num_templates and num_scopes
	parameters with a struct d_print_info pointer parameter.  Adjust
	body of the function accordingly.  Add recursion counter and check
	that the recursion limit is not reached.
	(d_print_init): Pass dpi parameter to d_count_templates_scopes.
	Reset recursion counter afterwards, unless the recursion limit was
	reached.

2019-07-13  Joel Brobecker  <brobecker@@adacore.com>

	* src-release (getver): If $tool/gdbsupport/create-version.sh
	exists, use that to determine the version number.

2019-06-21  Andreas Schwab  <schwab@@linux-m68k.org>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gnulib.

2019-06-14  Tom Tromey  <tom@@tromey.com>

	* MAINTAINERS: Add gnulib.
	* gnulib: New directory, move from gdb/gnulib.
	* configure.ac (host_libs): Add gnulib.
	* configure: Rebuild.
	* Makefile.def (host_modules, dependencies): Add gnulib.
	* Makefile.in: Rebuild.

2019-06-03  Nick Clifton  <nickc@@redhat.com>

	Revert:
	2019-05-29  Nick Clifton  <nickc@@redhat.com>

	* configure.ac (noconfigdirs): Add libctf if the target does not use
	the ELF file format.
	* configure: Regenerate.

2019-05-29  Nick Clifton  <nickc@@redhat.com>

	* src-release.sh (do_proto_toplev): Add libctf to list of
	directories that can be disabled.

2019-05-29  Nick Clifton  <nickc@@redhat.com>

	* configure.ac (noconfigdirs): Add libctf if the target does not use
	the ELF file format.
	* configure: Regenerate.

2019-05-28  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (dependencies): configure-libctf depends on all-bfd
	and all its deps.
	* Makefile.in: Regenerated.

2019-05-28  Nick Alcock  <nick.alcock@@oracle.com>

	* MAINTAINERS: Add libctf.

2019-05-28  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (host_modules): Add libctf.
	* Makefile.def (dependencies): Likewise.
	libctf depends on zlib, libiberty, and bfd.
	* Makefile.in: Regenerated.
	* configure.ac (host_libs): Add libctf.
	* configure: Regenerated.

2019-05-23  Jose E. Marchesi  <jose.marchesi@@oracle.com>

	* config.guess: Synchronize with config project master sources.
	* config.sub: Likewise.
	* readline/support/config.guess: Likewise.
	* readline/support/config.sub: Likewise.

2019-04-10  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Sync with gcc.  Bring in:
	2019-04-10  Nick Clifton  <nickc@@redhat.com>

	PR 89394
	* cp-demangle.c (cplus_demangle_fill_name): Reject negative
	lengths.
	(d_count_templates_scopes): Replace num_templates and num_scopes
	parameters with a struct d_print_info pointer parameter.  Adjust
	body of the function accordingly.  Add recursion counter and check
	that the recursion limit is not reached.
	(d_print_init): Pass dpi parameter to d_count_templates_scopes.
	Reset recursion counter afterwards, unless the recursion limit was
	reached.

2018-06-24  Nick Clifton  <nickc@@redhat.com>

	2.32 branch created.

2019-01-14  Rainer Orth  <ro@@CeBiTec.Uni-Bielefeld.DE>

	Merge from GCC:
	PR target/88535
	* config.guess: Import upstream version 2019-01-03.
	* config.sub: Import upstream version 2019-01-01.

2019-01-10  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Sync with gcc.  Bring in:
	2019-01-09  Sandra Loosemore  <sandra@@codesourcery.com>

	PR other/16615

	* cp-demangle.c: Mechanically replace "can not" with "cannot".
	* floatformat.c: Likewise.
	* strerror.c: Likewise.

	2018-12-22  Jason Merrill  <jason@@redhat.com>

	Remove support for demangling GCC 2.x era mangling schemes.
	* cplus-dem.c: Remove cplus_mangle_opname, cplus_demangle_opname,
	internal_cplus_demangle, and all subroutines.
	(libiberty_demanglers): Remove entries for ancient GNU (pre-3.0),
	Lucid, ARM, HP, and EDG demangling styles.
	(cplus_demangle): Remove 'work' variable.  Don't call
	internal_cplus_demangle.

2019-01-03  Дилян Палаузов  <dilyan.palauzov@@aegee.org>

	* configure.ac: Don't configure readline if --with-system-readline is
	used.
	* configure: Re-generate.
@
text
@@


1.1.1.2
log
@Import gdb-13.2 over gdb-11.0.50

May 27th, 2023: GDB 13.2 Released!
The latest version of GDB, version 13.2, is available for download.

This is a minor corrective release over GDB 13.1, fixing the following issues:

PR testsuite/30158 (rustc testsuite fails with 13.1, apparently
		    worked before with trunk 20230114 on i686-linux-gnu and
		    powerpc64le-linux-gnu)
PR gdb/30214 (GDB 13.1 does not compile on FreeBSD 13.1)
PR gdb/30240 ((linux/aarch) thread.c:86: internal-error: inferior_thread:
              Assertion `current_thread_ != nullptr' failed)
PR gdb/30249 ([13 regression] hookpost-extended-remote will not work)
PR exp/30271 (Addresses of static thread_local fields are badly
              calculated sometimes)
PR symtab/30357 (Segmentation fault for the 'start' command)
PR symtab/30369 ([gdb/symtab] False match issue in
skip_prologue_using_linetable)

PR gdb/30423 (Build failures with clang 16)
PR build/30450 (Build failure (linux-low.cc:5393:45: error: expected
		':' before ')' token) with musl-1.2.4)

See the NEWS file for a more complete and detailed list of what this release
 includes.

Feb 19th, 2023: GDB 13.1 Released!

The latest version of GDB, version 13.1, is available for download.
This version of GDB includes the following changes and enhancements:
Support for the following new targets has been added in both GDB and GDBserver:
GNU/Linux/LoongArch (gdbserver) loongarch*-*-linux*
GNU/Linux/CSKY (gdbserver) csky*-*linux*
The Windows native target now supports target async.
FreeBSD:
Arm and AArch64: Support for Thread Local Storage (TLS) variables
Hardware watchpoint support on AArch64 FreeBSD
Floating-point support has now been added on LoongArch GNU/Linux.
New commands:
set print nibbles [on|off]
show print nibbles

This controls whether the 'print/t' command will display binary
values in groups of four bits, known as "nibbles". The default is
'off'.

Various styling-related commands. See the gdb/NEWS file for more details.
Various maintenance commands. These are normally aimed at GDB
experts or developers. See the gdb/NEWS file for more details.

Python API improvements:
New Python API for instruction disassembly.

The new attribute 'locations' of gdb.Breakpoint returns a list of
gdb.BreakpointLocation objects specifying the locations where the
breakpoint is inserted into the debuggee.
New Python type gdb.BreakpointLocation.
New function gdb.format_address(ADDRESS, PROGSPACE, ARCHITECTURE)
that formats ADDRESS as 'address '
New function gdb.current_language that returns the name of the
current language. Unlike gdb.parameter('language'), this will never
return 'auto'.
New function gdb.print_options that returns a dictionary of the
prevailing print options, in the form accepted by gdb.Value.format_string.
New method gdb.Frame.language that returns the name of the frame's language.
gdb.Value.format_string now uses the format provided by 'print',
if it is called during a 'print' or other similar operation.
gdb.Value.format_string now accepts the 'summary' keyword. This
can be used to request a shorter representation of a value, the
way that 'set print frame-arguments scalars' does.
The gdb.register_window_type method now restricts the set of
acceptable window names. The first character of a window's name
must start with a character in the set [a-zA-Z], every subsequent
character of a window's name must be in the set [-_.a-zA-Z0-9].
` GDB/MI changes:  MI version 1 is deprecated, and will be removed
in GDB 14.  The async record stating the stopped reason 'breakpoint-hit'
now contains an optional field locno.

Miscellaneous improvements:
gdb now supports zstd compressed debug sections (ELFCOMPRESS_ZSTD) for ELF.
New convenience variable $_inferior_thread_count contains the number
of live threads in the current inferior.
New convenience variables $_hit_bpnum and $_hit_locno, set to the
breakpoint number and the breakpoint location number of the breakpoint
last hit.
The "info breakpoints" now displays enabled breakpoint locations
of disabled breakpoints as in the "y-" state.
The format of 'disassemble /r' and 'record instruction-history /r'
has changed to match the layout of GNU objdump when disassembling.

A new format "/b" has been introduce to provide the old behavior of "/r".
The TUI no longer styles the source and assembly code highlighted
by the current position indicator by default. You can however
re-enable styling using the new "set style tui-current-position"
command.
It is now possible to use the "document" command to document
user-defined commands.
Support for memory tag data for AArch64 MTE.
Support Removal notices:
DBX mode has been removed.
Support for building against Python version 2 has been removed. It
is now only possible to build GDB against Python 3.
Support for the following commands has been removed:

set debug aix-solib on|off
show debug aix-solib
set debug solib-frv on|off
show debug solib-frv

Use the "set/show debug solib" commands instead.
See the NEWS file for a more complete and detailed list of what
this release includes.

Dec 18th, 2022: GDB 13 branch created
The GDB 13 branch (gdb-13-branch) has been created. To check out
a copy of the branch use:

git clone --branch gdb-13-branch https://sourceware.org/git/binutils-gdb.git
May 1st, 2022: GDB 12.1 Released!
The latest version of GDB, version 12.1, is available for download.

This version of GDB includes the following changes and enhancements:

New support for the following native configuration:
GNU/Linux/OpenRISC or1k*-*-linux*
New support for the following targets:
GNU/Linux/LoongArch loongarch*-*-linux*
New GDBserver support on the following configuration:
GNU/Linux/OpenRISC or1k*-*-linux*
Support for the following target has been removed:
S+core score-*-*
Multithreaded symbol loading is now enabled by default

Deprecation Notices:
GDB 12 is the last release of GDB that will support building against Python 2
DBX mode is deprecated, and will be removed in GDB 13
GDB/MI changes:
The '-add-inferior' with no option flags now inherits the connection
of the current inferior, this restores the behaviour of GDB as it
was prior to GDB 10.
The '-add-inferior' command now accepts a '--no-connection' option,
which causes the new inferior to start without a connection.

Python API enhancements:
It is now possible to add GDB/MI commands implemented in Python
New function gdb.Architecture.integer_type()
New gdb.events.gdb_exiting event
New 'gdb.events.connection_removed' event registry
New gdb.TargetConnection object
New gdb.Inferior.connection property
New read-only attribute gdb.InferiorThread.details
New gdb.RemoteTargetConnection.send_packet method
New read-only attributes gdb.Type.is_scalar and gdb.Type.is_signed
The gdb.Value.format_string method now takes a 'styling' argument
Various new function in the "gdb" module
Miscellaneous:
The FreeBSD native target now supports async mode

Improved C++ template support
Support for disabling source highlighting through GNU of the Pygments
library instead.
The "print" command has been changed so as to print floating-point
values with a base-modifying formats such as "/x" to display the
underlying bytes of the value in the desired base.
The "clone-inferior" command now ensures that the TTY, CMD and ARGS
settings are copied from the original inferior to the new one. All
modifications to the environment variables done using the 'set
environment' or 'unset environment' commands are also copied to
the new inferior.
Various new commands have been introduced
See the NEWS file for a more complete and detailed list of what
this release includes.

Mar 20th, 2022: GDB 12 branch created
The GDB 12 branch (gdb-12-branch) has been created. To check out a copy of the branch use:

git clone --branch gdb-12-branch https://sourceware.org/git/binutils-gdb.git
January 16th, 2022: GDB 11.2 Released!
The latest version of GDB, version 11.2, is available for download.

This is a minor corrective release over GDB 11.1, fixing the following issues:

PR sim/28302 (gdb fails to build with glibc 2.34)
PR build/28318 (std::thread support configure check does not use CXX_DIALECT)
PR gdb/28405 (arm-none-eabi: internal-error: ptid_t
	      remote_target::select_thread_for_ambiguous_stop_reply(const
	      target_waitstatus*): Assertion `first_resumed_thread != nullptr'
	      failed)
PR tui/28483 ([gdb/tui] breakpoint creation not displayed)
PR build/28555 (uclibc compile failure since commit
		4655f8509fd44e6efabefa373650d9982ff37fd6)
PR rust/28637 (Rust characters will be encoded using DW_ATE_UTF)
PR gdb/28758 (GDB 11 doesn't work correctly on binaries with a
              SHT_RELR (.relr.dyn) section)
PR gdb/28785 (Support SHT_RELR (.relr.dyn) section)
See the NEWS file for a more complete and detailed list of what
this release includes.

September 13th, 2021: GDB 11.1 Released!
The latest version of GDB, version 11.1, is available for download.

This version of GDB includes the following changes and enhancements:

Support for ARM Symbian (arm*-*-symbianelf*) has been removed.
Building GDB now requires GMP (The GNU Multiple Precision Arithmetic Library).
New command-line options "--early-init-command" (or "-eix") and
"--early-init-eval-command" (or "-eiex")

GDB/MI Changes:
New --qualified option for the '-break-insert' and '-dprintf-insert' commands.
New --force-condition option for the '-break-insert' and
'-dprintf-insert' commands.
New --force option for the '-break-condition' command.
The '-file-list-exec-source-files' now accepts an optional regular
expression to filter the source files included in the result.
The results from '-file-list-exec-source-files' now include a
'debug-fully-read' field to indicate if the corresponding source's
debugging information has been partially read (false) or has been
fully read (true).

TUI Improvements:
Mouse actions are now supported. The mouse wheel scrolls the
appropriate window.  Key combinations that do not have a specific
action on the focused window are now passed to GDB.

Python enhancements:
Inferior objects now contain a read-only 'connection_num' attribute
that gives the connection number as seen in 'info connections' and
'info inferiors'.
New method gdb.Frame.level() which returns the stack level of the frame object.
New method gdb.PendingFrame.level() which returns the stack level
of the frame object.
When hitting a catchpoint, the Python API will now emit a
gdb.BreakpointEvent rather than a gdb.StopEvent. The gdb.Breakpoint
attached to the event will have type BP_CATCHPOINT.
Python TUI windows can now receive mouse click events. If the Window
object implements the click method, it is called for each mouse
click event in this window.  New setting "python ignore-environment
on|off"; if "on", causes GDB's builtin Python to ignore any
environment variable that would otherwise affect how Python behaves
(needs to be set during "early initialization" (see above).  New
setting "python dont-write-bytecode auto|on|off".

Guile API enhancements:
Improved support for rvalue reference values.
New procedures for obtaining value variants: value-reference-value,
value-rvalue-reference-value and value-const-value.
New "qMemTags" and "QMemTags" remote protocol packets (associated
with Memory Tagging).
GDB will now look for the .gdbinit file in a config directory before
looking for ~/.gdbinit. The file is searched for in the following
locations: $XDG_CONFIG_HOME/gdb/gdbinit, $HOME/.config/gdb/gdbinit,
$HOME/.gdbinit. On Apple hosts the search order is instead:
$HOME/Library/Preferences/gdb/gdbinit, $HOME/.gdbinit.  The "break
[...] if CONDITION" command no longer returns an error when the
condition is invalid at one or more locations. Instead, if the
condition is valid at one or more locations, the locations where
the condition is not valid are disabled.
The behavior of the "condition" command is changed to match the
new behavior of the "break" command.

Support for general memory tagging functionality (currently limited
to AArch64 MTE)

Core file debugging now supported for x86_64 Cygwin programs.
New "org.gnu.gdb.riscv.vector" feature for RISC-V targets.
GDB now supports fixed point types which are described in DWARF as
base types with a fixed-point encoding. Additionally, support for
the DW_AT_GNU_numerator and DW_AT_GNU_denominator has also been
added.

Miscellaneous:
New "startup-quietly on|off" setting; when "on", behaves the same
as passing the "-silent" option on the command line.
New "print type hex on|off" setting; when 'on', the 'ptype' command
uses hexadecimal notation to print sizes and offsets of struct
members. When 'off', decimal notation is used.
The "inferior" command, when run without argument, prints information
about the current inferior.
The "ptype" command now supports "/x" and "/d", affecting the base
used to print sizes and offsets.
The output of the "info source" has been restructured.
New "style version foreground | background | intensity" commands
to control the styling of the GDB version number.
Various debug and maintenance commands (mostly useful for the GDB
developers) See the NEWS file for a more complete and detailed list
of what this release includes.
@
text
@a251 2
   ;; xBPF-only: signed div, signed mod
   (SDIV #xe) (SMOD #xf)
d423 1
a423 1
                 x-endian x-mode x-semop x-isas)
d428 1
a428 1
         (.splice (.unsplice x-isas))
d437 1
a437 1
         (.splice (.unsplice x-isas))
d474 1
a474 1
(define-pmacro (daib x-basename x-op-code x-endian x-semop x-isas)
d476 2
a477 2
    (define-alu-insn-bin x-basename "" OP_CLASS_ALU64 x-op-code x-endian DI x-semop x-isas)
    (define-alu-insn-bin x-basename "32" OP_CLASS_ALU x-op-code x-endian USI x-semop x-isas)))
d487 11
a497 13
    (daib add OP_CODE_ADD x-endian add (endian-isas x-endian))
    (daib sub OP_CODE_SUB x-endian sub (endian-isas x-endian))
    (daib mul OP_CODE_MUL x-endian mul (endian-isas x-endian))
    (daib div OP_CODE_DIV x-endian udiv (endian-isas x-endian))
    (daib or  OP_CODE_OR x-endian or (endian-isas x-endian))
    (daib and OP_CODE_AND x-endian and (endian-isas x-endian))
    (daib lsh OP_CODE_LSH x-endian sll (endian-isas x-endian))
    (daib rsh OP_CODE_RSH x-endian srl (endian-isas x-endian))
    (daib mod OP_CODE_MOD x-endian umod (endian-isas x-endian))
    (daib xor OP_CODE_XOR x-endian xor (endian-isas x-endian))
    (daib arsh OP_CODE_ARSH x-endian sra (endian-isas x-endian))
    (daib sdiv OP_CODE_SDIV x-endian div ((ISA (.sym xbpf x-endian))))
    (daib smod OP_CODE_SMOD x-endian mod ((ISA (.sym xbpf x-endian))))
@


1.1.1.2.2.1
log
@Sync with HEAD
@
text
@@


