head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.4
	netbsd-11-0-RC3:1.1.1.4
	gdb-17-1:1.1.1.4
	netbsd-11-0-RC2:1.1.1.4
	netbsd-11-0-RC1:1.1.1.4
	gdb-16-3:1.1.1.4
	perseant-exfatfs-base-20250801:1.1.1.4
	netbsd-11:1.1.1.4.0.2
	netbsd-11-base:1.1.1.4
	netbsd-10-1-RELEASE:1.1.1.3
	gdb-15-1:1.1.1.4
	perseant-exfatfs-base-20240630:1.1.1.3
	perseant-exfatfs:1.1.1.3.0.8
	perseant-exfatfs-base:1.1.1.3
	netbsd-8-3-RELEASE:1.1.1.1
	netbsd-9-4-RELEASE:1.1.1.2
	netbsd-10-0-RELEASE:1.1.1.3
	netbsd-10-0-RC6:1.1.1.3
	netbsd-10-0-RC5:1.1.1.3
	netbsd-10-0-RC4:1.1.1.3
	netbsd-10-0-RC3:1.1.1.3
	netbsd-10-0-RC2:1.1.1.3
	netbsd-10-0-RC1:1.1.1.3
	gdb-13-2:1.1.1.3
	netbsd-10:1.1.1.3.0.6
	netbsd-10-base:1.1.1.3
	netbsd-9-3-RELEASE:1.1.1.2
	cjep_sun2x-base1:1.1.1.3
	cjep_sun2x:1.1.1.3.0.4
	cjep_sun2x-base:1.1.1.3
	cjep_staticlib_x-base1:1.1.1.3
	netbsd-9-2-RELEASE:1.1.1.2
	cjep_staticlib_x:1.1.1.3.0.2
	cjep_staticlib_x-base:1.1.1.3
	netbsd-9-1-RELEASE:1.1.1.2
	GDB-11-0-50-20200914-git:1.1.1.3
	phil-wifi-20200421:1.1.1.2
	phil-wifi-20200411:1.1.1.2
	is-mlppp:1.1.1.2.0.4
	is-mlppp-base:1.1.1.2
	phil-wifi-20200406:1.1.1.2
	netbsd-8-2-RELEASE:1.1.1.1
	netbsd-9-0-RELEASE:1.1.1.2
	netbsd-9-0-RC2:1.1.1.2
	netbsd-9-0-RC1:1.1.1.2
	phil-wifi-20191119:1.1.1.2
	netbsd-9:1.1.1.2.0.2
	netbsd-9-base:1.1.1.2
	phil-wifi-20190609:1.1.1.2
	netbsd-8-1-RELEASE:1.1.1.1
	gdb-8-3:1.1.1.2
	netbsd-8-1-RC1:1.1.1.1
	pgoyette-compat-merge-20190127:1.1.1.1
	pgoyette-compat-20190127:1.1.1.1
	pgoyette-compat-20190118:1.1.1.1
	pgoyette-compat-1226:1.1.1.1
	pgoyette-compat-1126:1.1.1.1
	pgoyette-compat-1020:1.1.1.1
	pgoyette-compat-0930:1.1.1.1
	pgoyette-compat-0906:1.1.1.1
	pgoyette-compat-0728:1.1.1.1
	netbsd-8-0-RELEASE:1.1.1.1
	phil-wifi:1.1.1.1.0.16
	phil-wifi-base:1.1.1.1
	pgoyette-compat-0625:1.1.1.1
	netbsd-8-0-RC2:1.1.1.1
	pgoyette-compat-0521:1.1.1.1
	pgoyette-compat-0502:1.1.1.1
	pgoyette-compat-0422:1.1.1.1
	netbsd-8-0-RC1:1.1.1.1
	pgoyette-compat-0415:1.1.1.1
	pgoyette-compat-0407:1.1.1.1
	pgoyette-compat-0330:1.1.1.1
	pgoyette-compat-0322:1.1.1.1
	pgoyette-compat-0315:1.1.1.1
	pgoyette-compat:1.1.1.1.0.14
	pgoyette-compat-base:1.1.1.1
	gdb-8-0-1:1.1.1.1
	matt-nb8-mediatek:1.1.1.1.0.12
	matt-nb8-mediatek-base:1.1.1.1
	perseant-stdc-iso10646:1.1.1.1.0.10
	perseant-stdc-iso10646-base:1.1.1.1
	netbsd-8:1.1.1.1.0.8
	netbsd-8-base:1.1.1.1
	prg-localcount2-base3:1.1.1.1
	prg-localcount2-base2:1.1.1.1
	prg-localcount2-base1:1.1.1.1
	prg-localcount2:1.1.1.1.0.6
	prg-localcount2-base:1.1.1.1
	pgoyette-localcount-20170426:1.1.1.1
	bouyer-socketcan-base1:1.1.1.1
	pgoyette-localcount-20170320:1.1.1.1
	bouyer-socketcan:1.1.1.1.0.4
	bouyer-socketcan-base:1.1.1.1
	pgoyette-localcount-20170107:1.1.1.1
	pgoyette-localcount-20161104:1.1.1.1
	gdb-7-12:1.1.1.1
	localcount-20160914:1.1.1.1
	pgoyette-localcount-20160806:1.1.1.1
	pgoyette-localcount-20160726:1.1.1.1
	pgoyette-localcount:1.1.1.1.0.2
	pgoyette-localcount-base:1.1.1.1
	gdb-7-10-1:1.1.1.1
	gdb-7-9-1:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2015.08.15.10.24.36;	author christos;	state Exp;
branches
	1.1.1.1;
next	;
commitid	HQEGxxDWfd9mFlxy;

1.1.1.1
date	2015.08.15.10.24.36;	author christos;	state Exp;
branches
	1.1.1.1.16.1;
next	1.1.1.2;
commitid	HQEGxxDWfd9mFlxy;

1.1.1.2
date	2019.05.26.21.01.53;	author christos;	state Exp;
branches;
next	1.1.1.3;
commitid	MDatjuvRsk0MXKoB;

1.1.1.3
date	2020.09.15.01.42.15;	author christos;	state Exp;
branches
	1.1.1.3.8.1;
next	1.1.1.4;
commitid	N511ReXja24bg5oC;

1.1.1.4
date	2024.08.12.21.37.49;	author christos;	state Exp;
branches;
next	;
commitid	dWD83H91pFit0AlF;

1.1.1.1.16.1
date	2019.06.10.21.58.31;	author christos;	state Exp;
branches;
next	;
commitid	jtc8rnCzWiEEHGqB;

1.1.1.3.8.1
date	2025.08.02.05.26.39;	author perseant;	state Exp;
branches;
next	;
commitid	23j6GFaDws3O875G;


desc
@@


1.1
log
@Initial revision
@
text
@; OpenRISC Basic Instruction Set 32-bit (ORBIS)  -*- Scheme -*-
; Copyright 2000-2014 Free Software Foundation, Inc.
; Contributed for OR32 by Johan Rydberg, jrydberg@@opencores.org
; Modified by Julius Baxter, juliusbaxter@@gmail.com
; Modified by Peter Gavin, pgavin@@gmail.com
;
; 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, see <http://www.gnu.org/licenses/>

; Instruction fields.

; Hardware for immediate operands
(dnh h-simm16      "16-bit signed immediate"   ((MACH ORBIS-MACHS)) (immediate (INT 16)) () () ())
(dnh h-uimm16      "16-bit unsigned immediate" ()                   (immediate (UINT 16)) () () ())
(dnh h-uimm6       "6-bit unsigned immediate"  ()                   (immediate (UINT 6)) () () ())

; Hardware for the (internal) atomic registers
(dsh h-atomic-reserve "atomic reserve flag" () (register BI))
(dsh h-atomic-address "atomic reserve address" () (register SI))

; Instruction classes.
(dnf f-opcode      "insn opcode"               ((MACH ORBIS-MACHS)) 31 6)

; Register fields.
(dnf f-r1          "r1"                        ((MACH ORBIS-MACHS)) 25 5)
(dnf f-r2          "r2"                        ((MACH ORBIS-MACHS)) 20 5)
(dnf f-r3          "r3"                        ((MACH ORBIS-MACHS)) 15 5)

; Sub fields
(dnf f-op-25-2     "op-25-2"                   ((MACH ORBIS-MACHS)) 25 2) ;; nop
(dnf f-op-25-5     "op-25-5"                   ((MACH ORBIS-MACHS)) 25 5) ;; sys, trap, *sync, sf*
(dnf f-op-16-1     "op-16-1"                   ((MACH ORBIS-MACHS)) 16 1) ;; movhi,macrc
(dnf f-op-7-4      "op-7-4"                    ((MACH ORBIS-MACHS)) 7 4)
(dnf f-op-3-4      "op-3-4"                    ((MACH ORBIS-MACHS)) 3 4)
(dnf f-op-9-2      "op-9-2"                    ((MACH ORBIS-MACHS)) 9 2) ;; alu ops upper opcode
(dnf f-op-9-4      "op-9-4"                    ((MACH ORBIS-MACHS)) 9 4) ;;
(dnf f-op-7-8      "op-7-8"                    ((MACH ORBIS-MACHS)) 7 8)
(dnf f-op-7-2      "op-7-2"                    ((MACH ORBIS-MACHS)) 7 2) ;; alu lower upper opc,shroti

; Reserved fields
(dnf f-resv-25-26  "resv-25-26"                ((MACH ORBIS-MACHS) RESERVED) 25 26)
(dnf f-resv-25-10  "resv-25-10"                ((MACH ORBIS-MACHS) RESERVED) 25 10)
(dnf f-resv-25-5   "resv-25-5"                 ((MACH ORBIS-MACHS) RESERVED) 25 5)
(dnf f-resv-23-8   "resv-23-8"                 ((MACH ORBIS-MACHS) RESERVED) 23 8)
(dnf f-resv-20-21  "resv-20-21"                ((MACH ORBIS-MACHS) RESERVED) 20 21)
(dnf f-resv-20-5   "resv-20-5"                 ((MACH ORBIS-MACHS) RESERVED) 20 5)
(dnf f-resv-20-4   "resv-20-4"                 ((MACH ORBIS-MACHS) RESERVED) 20 4)
(dnf f-resv-15-8   "resv-15-8"                 ((MACH ORBIS-MACHS) RESERVED) 15 8)
(dnf f-resv-15-6   "resv-15-6"                 ((MACH ORBIS-MACHS) RESERVED) 15 6)
(dnf f-resv-10-11  "resv-10-11"                ((MACH ORBIS-MACHS) RESERVED) 10 11)
(dnf f-resv-10-7   "resv-10-7"                 ((MACH ORBIS-MACHS) RESERVED) 10 7)
(dnf f-resv-10-3   "resv-10-3"                 ((MACH ORBIS-MACHS) RESERVED) 10 3)
(dnf f-resv-10-1   "resv-10-1"                 ((MACH ORBIS-MACHS) RESERVED) 10 1)
(dnf f-resv-7-4    "resv-7-4"                  ((MACH ORBIS-MACHS) RESERVED) 7 4)
(dnf f-resv-5-2    "resv-5-2"                  ((MACH ORBIS-MACHS) RESERVED) 5 2)

(dnf f-imm16-25-5  "imm16-25-5"                ((MACH ORBIS-MACHS)) 25  5)
(dnf f-imm16-10-11 "imm16-10-11"               ((MACH ORBIS-MACHS)) 10 11)

; PC relative, 26-bit (2 shifted to right)
(df f-disp26
    "disp26"
    ((MACH ORBIS-MACHS) PCREL-ADDR)
    25
    26
    INT
    ((value pc) (sra SI (sub IAI value pc) (const 2)))
    ((value pc) (add IAI (sll IAI value (const 2)) pc))
    )

; Immediates.
(dnf f-uimm16    "uimm16"                      ((MACH ORBIS-MACHS))          15 16)
(df  f-simm16    "simm16"                      ((MACH ORBIS-MACHS) SIGN-OPT) 15 16 INT #f #f)
(dnf f-uimm6     "uimm6"                       ((MACH ORBIS-MACHS))          5  6) ;; shroti

(define-multi-ifield
  (name f-uimm16-split)
  (comment "16-bit split unsigned immediate")
  (attrs (MACH ORBIS-MACHS))
  (mode UINT)
  (subfields f-imm16-25-5 f-imm16-10-11)
  (insert (sequence ()
                    (set (ifield f-imm16-25-5)
                         (and (srl (ifield f-uimm16-split)
                                   (const 11))
                              (const #x1f)))
                    (set (ifield f-imm16-10-11)
                         (and (ifield f-uimm16-split)
                              (const #x7ff)))))
  (extract 
           (set (ifield f-uimm16-split)
                (trunc UHI
                       (or (sll (ifield f-imm16-25-5)
                                (const 11))
                           (ifield f-imm16-10-11)))))
  )

(define-multi-ifield
  (name f-simm16-split)
  (comment "16-bit split signed immediate")
  (attrs (MACH ORBIS-MACHS) SIGN-OPT)
  (mode INT)
  (subfields f-imm16-25-5 f-imm16-10-11)
  (insert (sequence ()
                    (set (ifield f-imm16-25-5)
                         (and (sra (ifield f-simm16-split)
                                   (const 11))
                              (const #x1f)))
                    (set (ifield f-imm16-10-11)
                         (and (ifield f-simm16-split)
                              (const #x7ff)))))
  (extract 
           (set (ifield f-simm16-split)
                (trunc HI
                       (or (sll (ifield f-imm16-25-5)
                                (const 11))
                           (ifield f-imm16-10-11)))))
  )

; Enums.

; insn-opcode: bits 31-26
(define-normal-insn-enum 
  insn-opcode "insn main opcode enums" ((MACH ORBIS-MACHS)) OPC_ f-opcode
  (("J"            #x00)
   ("JAL"          #x01)
   ("BNF"          #x03)
   ("BF"           #x04)
   ("NOP"          #x05)
   ("MOVHIMACRC"   #x06)
   ("SYSTRAPSYNCS" #x08)
   ("RFE"          #x09)
   ("VECTOR"       #x0a)
   ("JR"           #x11)
   ("JALR"         #x12)
   ("MACI"         #x13)
   ("LWA"          #x1b)
   ("CUST1"        #x1c)
   ("CUST2"        #x1d)
   ("CUST3"        #x1e)
   ("CUST4"        #x1f)
   ("LD"           #x20)
   ("LWZ"          #x21)
   ("LWS"          #x22)
   ("LBZ"          #x23)
   ("LBS"          #x24)
   ("LHZ"          #x25)
   ("LHS"          #x26)
   ("ADDI"         #x27)
   ("ADDIC"        #x28)
   ("ANDI"         #x29)
   ("ORI"          #x2a)
   ("XORI"         #x2b)
   ("MULI"         #x2c)
   ("MFSPR"        #x2d)
   ("SHROTI"       #x2e)
   ("SFI"          #x2f)
   ("MTSPR"        #x30)
   ("MAC"          #x31)
   ("FLOAT"        #x32)
   ("SWA"          #x33)
   ("SD"           #x34)
   ("SW"           #x35)
   ("SB"           #x36)
   ("SH"           #x37)
   ("ALU"          #x38)
   ("SF"           #x39)
   ("CUST5"        #x3c)
   ("CUST6"        #x3d)
   ("CUST7"        #x3e)
   ("CUST8"        #x3f) 
  )
)

(define-normal-insn-enum insn-opcode-systrapsyncs 
  "systrapsync insn opcode enums" ((MACH ORBIS-MACHS)) 
  OPC_SYSTRAPSYNCS_ f-op-25-5
    (("SYSCALL" #x00 )
     ("TRAP" #x08 )
     ("MSYNC" #x10 )
     ("PSYNC" #x14 )
     ("CSYNC" #x18 )
    )
)

(define-normal-insn-enum insn-opcode-movehimacrc
  "movhi/macrc insn opcode enums" ((MACH ORBIS-MACHS))
  OPC_MOVHIMACRC_ f-op-16-1
  (("MOVHI" #x0)
   ("MACRC" #x1)
  )
)

(define-normal-insn-enum insn-opcode-mac
  "multiply/accumulate insn opcode enums" ((MACH ORBIS-MACHS))
  OPC_MAC_ f-op-3-4
  (("MAC" #x1)
   ("MSB" #x2)
   )
  )

(define-normal-insn-enum insn-opcode-shorts 
  "shift/rotate insn opcode enums" ((MACH ORBIS-MACHS))
  OPC_SHROTS_ f-op-7-2
    (("SLL" #x0 )
     ("SRL" #x1 )
     ("SRA" #x2 )
     ("ROR" #x3 )
    )
)

(define-normal-insn-enum insn-opcode-extbhs
  "extend byte/half opcode enums" ((MACH ORBIS-MACHS))
  OPC_EXTBHS_ f-op-9-4
  (("EXTHS" #x0)
   ("EXTBS" #x1)
   ("EXTHZ" #x2)
   ("EXTBZ" #x3)
   )
)

(define-normal-insn-enum insn-opcode-extws
  "extend word opcode enums" ((MACH ORBIS-MACHS))
  OPC_EXTWS_ f-op-9-4
  (("EXTWS" #x0)
   ("EXTWZ" #x1)
   )
)

(define-normal-insn-enum insn-opcode-alu-regreg 
  "alu reg/reg insn opcode enums" ((MACH ORBIS-MACHS))
  OPC_ALU_REGREG_ f-op-3-4
  (("ADD"   #x0)
   ("ADDC"  #x1)
   ("SUB"   #x2)
   ("AND"   #x3)
   ("OR"    #x4)
   ("XOR"   #x5)
   ("MUL"   #x6)
   ("SHROT" #x8)
   ("DIV"   #x9)
   ("DIVU"  #xA)
   ("MULU"  #xB)
   ("EXTBH" #xC)
   ("EXTW"  #xD)
   ("CMOV"  #xE)
   ("FFL1"  #xF)
   )
)

(define-normal-insn-enum insn-opcode-setflag
  "setflag insn opcode enums" ((MACH ORBIS-MACHS))
  OPC_SF_ f-op-25-5
    (("EQ"  #x00)
     ("NE"  #x01)
     ("GTU" #x02)
     ("GEU" #x03)
     ("LTU" #x04)
     ("LEU" #x05)
     ("GTS" #x0A)
     ("GES" #x0B)
     ("LTS" #x0C)
     ("LES" #x0D)
    )
)


; Instruction operands.

(dnop sys-sr            "supervision register"             ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr            f-nil)
(dnop sys-esr0          "exception supervision register 0" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-esr0          f-nil)
(dnop sys-epcr0         "exception PC register 0"          ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-epcr0         f-nil)

(dnop sys-sr-lee        "SR little endian enable bit"      ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-lee        f-nil)
(dnop sys-sr-f          "SR flag bit"                      ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-f          f-nil)
(dnop sys-sr-cy         "SR carry bit"                     ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-cy         f-nil)
(dnop sys-sr-ov         "SR overflow bit"                  ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-ov         f-nil)
(dnop sys-sr-ove        "SR overflow exception enable bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-ove        f-nil)
(dnop sys-cpucfgr-ob64s "CPUCFGR ORBIS64 supported bit"    ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-cpucfgr-ob64s f-nil)
(dnop sys-cpucfgr-nd    "CPUCFGR no delay bit"             ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-cpucfgr-nd    f-nil)
(dnop sys-fpcsr-rm      "floating point round mode"        ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-fpcsr-rm      f-nil)

(dnop mac-machi         "MAC HI result register"           ((MACH ORBIS-MACHS) SEM-ONLY) h-mac-machi         f-nil)
(dnop mac-maclo         "MAC LO result register"           ((MACH ORBIS-MACHS) SEM-ONLY) h-mac-maclo         f-nil)

(dnop atomic-reserve    "atomic reserve flag"              ((MACH ORBIS-MACHS) SEM-ONLY) h-atomic-reserve    f-nil)
(dnop atomic-address    "atomic address"                   ((MACH ORBIS-MACHS) SEM-ONLY) h-atomic-address    f-nil)

(dnop uimm6             "uimm6"                            ((MACH ORBIS-MACHS))          h-uimm6             f-uimm6)

(dnop rD                "destination register"             ((MACH ORBIS-MACHS))          h-gpr               f-r1)
(dnop rA                "source register A"                ((MACH ORBIS-MACHS))          h-gpr               f-r2)
(dnop rB                "source register B"                ((MACH ORBIS-MACHS))          h-gpr               f-r3)

(define-operand
  (name disp26)
  (comment "pc-rel 26 bit")
  (attrs (MACH ORBIS-MACHS))
  (type h-iaddr)
  (index f-disp26)
  (handlers (parse "disp26"))
  )

(define-operand
  (name simm16)
  (comment "16-bit signed immediate")
  (attrs (MACH ORBIS-MACHS) SIGN-OPT)
  (type h-simm16)
  (index f-simm16)
  (handlers (parse "simm16"))
  )

(define-operand
  (name uimm16)
  (comment "16-bit unsigned immediate")
  (attrs (MACH ORBIS-MACHS))
  (type h-uimm16)
  (index f-uimm16)
  (handlers (parse "uimm16"))
  )

(define-operand
  (name simm16-split)
  (comment "split 16-bit signed immediate")
  (attrs (MACH ORBIS-MACHS) SIGN-OPT)
  (type h-simm16)
  (index f-simm16-split)
  (handlers (parse "simm16"))
)

(define-operand
  (name uimm16-split)
  (comment "split 16-bit unsigned immediate")
  (attrs (MACH ORBIS-MACHS))
  (type h-uimm16)
  (index f-uimm16-split)
  (handlers (parse "uimm16"))
)

; Instructions.

; Branch releated instructions 

(define-pmacro (cti-link-return)
  (set IAI (reg h-gpr 9) (add pc (if sys-cpucfgr-nd 4 8)))
  )
(define-pmacro (cti-transfer-control condition target)
  ;; this mess is necessary because we're
  ;; skipping the delay slot, but it's
  ;; actually the start of the next basic
  ;; block
  (sequence ()
            (if condition
                (delay 1 (set IAI pc target))
                (if sys-cpucfgr-nd
                    (delay 1 (set IAI pc (add pc 4))))
                )
            (if sys-cpucfgr-nd
                (skip 1)
                )
            )
  )

(define-pmacro
  (define-cti
    cti-name
    cti-comment
    cti-attrs
    cti-syntax
    cti-format
    cti-semantics)
  (begin
    (dni
      cti-name
      cti-comment
      (.splice (MACH ORBIS-MACHS) DELAYED-CTI NOT-IN-DELAY-SLOT (.unsplice cti-attrs))
      cti-syntax
      cti-format
      (cti-semantics)
      ()
      )
    )
  )

(define-cti
  l-j
  "jump (pc-relative iaddr)"
  (!COND-CTI UNCOND-CTI)
  "l.j ${disp26}"
  (+ OPC_J disp26)
  (.pmacro ()
           (cti-transfer-control 1 disp26)
           )
  )

(define-cti
  l-jal
  "jump and link (pc-relative iaddr)"
  (!COND-CTI UNCOND-CTI)
  "l.jal ${disp26}"
  (+ OPC_JAL disp26)
  (.pmacro ()
           (sequence ()
                     (cti-link-return)
                     (cti-transfer-control 1 disp26)
                     )
           )
  )

(define-cti
  l-jr
  "jump register (absolute iaddr)"
  (!COND-CTI UNCOND-CTI)
  "l.jr $rB"
  (+ OPC_JR (f-resv-25-10 0) rB (f-resv-10-11 0))
  (.pmacro ()
           (cti-transfer-control 1 rB)
           )
  )

(define-cti
  l-jalr
  "jump register and link (absolute iaddr)"
  (!COND-CTI UNCOND-CTI)
  "l.jalr $rB"
  (+ OPC_JALR (f-resv-25-10 0) rB (f-resv-10-11 0) )
  (.pmacro ()
           (sequence ()
                     (cti-link-return)
                     (cti-transfer-control 1 rB)
                     )
           )
  )

(define-cti
  l-bnf
  "branch if condition bit not set (pc relative iaddr)"
  (COND-CTI !UNCOND-CTI)
  "l.bnf ${disp26}"
  (+ OPC_BNF disp26)
  (.pmacro ()
           (cti-transfer-control (not sys-sr-f) disp26)
           )
  )

(define-cti
  l-bf
  "branch if condition bit set (pc relative iaddr)"
  (COND-CTI !UNCOND-CTI)
  "l.bf ${disp26}"
  (+ OPC_BF disp26)
  (.pmacro ()
           (cti-transfer-control sys-sr-f disp26)
           )
  )

(dni l-trap "trap (exception)"
     ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT)
     "l.trap ${uimm16}"
     (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_TRAP (f-resv-20-5 0) uimm16)
     ; Do exception entry handling in C function, PC set based on SR state
     (raise-exception EXCEPT-TRAP)
     ()
)


(dni l-sys "syscall (exception)"
     ; This function may not be in delay slot
     ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT)

     "l.sys ${uimm16}"
     (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_SYSCALL (f-resv-20-5 0) uimm16)
     ; Do exception entry handling in C function, PC set based on SR state
     (raise-exception EXCEPT-SYSCALL)
     ()
)

(dni l-msync "memory sync"
     ((MACH ORBIS-MACHS))
     "l.msync"
     (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_MSYNC (f-resv-20-21 0))
     (nop)
     ()
)

(dni l-psync "pipeline sync"
     ((MACH ORBIS-MACHS))
     "l.psync"
     (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_PSYNC (f-resv-20-21 0))
     (nop)
     ()
)

(dni l-csync "context sync"
     ((MACH ORBIS-MACHS))
     "l.csync"
     (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_CSYNC (f-resv-20-21 0))
     (nop)
     ()
)

(dni l-rfe "return from exception"
     ; This function may not be in delay slot
     ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT FORCED-CTI)

     "l.rfe"
     (+ OPC_RFE (f-resv-25-26 0))
     (c-call VOID "@@cpu@@_rfe")
     ()
)


; Misc instructions

; l.nop with immediate must be first so it handles all l.nops in sim
(dni l-nop-imm "nop uimm16"
     ((MACH ORBIS-MACHS))
     "l.nop ${uimm16}"
     (+ OPC_NOP (f-op-25-2 #x1) (f-resv-23-8 0) uimm16)
     (c-call VOID "@@cpu@@_nop" (zext UWI uimm16))
     ()
     )

(if (application-is? SIMULATOR)
    (begin)
    (begin
      (dni l-nop "nop"
           ((MACH ORBIS-MACHS))
           "l.nop"
           (+ OPC_NOP (f-op-25-2 #x1) (f-resv-23-8 0) uimm16)
           (nop)
           ()
           )
      )
)

(dni l-movhi "movhi reg/uimm16"
     ((MACH ORBIS-MACHS))
     "l.movhi $rD,$uimm16"
     (+ OPC_MOVHIMACRC rD (f-resv-20-4 0) OPC_MOVHIMACRC_MOVHI uimm16)
     (set UWI rD (sll UWI (zext UWI uimm16) (const 16)))
     ()
)

(dni l-macrc "macrc reg"
     ((MACH ORBIS-MACHS))
     "l.macrc $rD"
     (+ OPC_MOVHIMACRC rD (f-resv-20-4 0) OPC_MOVHIMACRC_MACRC (f-uimm16 0))
     (sequence ()
               (set UWI rD mac-maclo)
               (set UWI mac-maclo 0)
               (set UWI mac-machi 0)
               )
     ()
     )


; System releated instructions

(dni l-mfspr "mfspr"
     ((MACH ORBIS-MACHS))
     "l.mfspr $rD,$rA,${uimm16}"
     (+ OPC_MFSPR rD rA uimm16)
     (set UWI rD (c-call UWI "@@cpu@@_mfspr" (or rA (zext UWI uimm16))))
     ()
)

(dni l-mtspr "mtspr"
     ((MACH ORBIS-MACHS))
     "l.mtspr $rA,$rB,${uimm16-split}"
     (+ OPC_MTSPR rA rB uimm16-split )
     (c-call VOID "@@cpu@@_mtspr" (or rA (zext WI uimm16-split)) rB)
     ()
)


; Load instructions
(define-pmacro (load-store-addr base offset size)
  (c-call AI "@@cpu@@_make_load_store_addr" base (ext SI offset) size))

(dni l-lwz "l.lwz reg/simm16(reg)"
     ((MACH ORBIS-MACHS))
     "l.lwz $rD,${simm16}($rA)"
     (+ OPC_LWZ rD rA simm16)
     (set UWI rD (zext UWI (mem USI (load-store-addr rA simm16 4))))
     ()
)


(dni l-lws "l.lws reg/simm16(reg)"
     ((MACH ORBIS-MACHS))
     "l.lws $rD,${simm16}($rA)"
     (+ OPC_LWS rD rA simm16)
     (set WI rD (ext WI (mem SI (load-store-addr rA simm16 4))))
     ()
)

(dni l-lwa "l.lwa reg/simm16(reg)"
     ((MACH ORBIS-MACHS))
     "l.lwa $rD,${simm16}($rA)"
     (+ OPC_LWA rD rA simm16)
     (sequence ()
               (set UWI rD (zext UWI (mem USI (load-store-addr rA simm16 4))))
               (set atomic-reserve (const 1))
               (set atomic-address (load-store-addr rA simm16 4))
               )
     ()
)

(dni l-lbz "l.lbz reg/simm16(reg)"
     ((MACH ORBIS-MACHS))
     "l.lbz $rD,${simm16}($rA)"
     (+ OPC_LBZ rD rA simm16)
     (set UWI rD (zext UWI (mem UQI (load-store-addr rA simm16 1))))
     ()
)

(dni l-lbs "l.lbs reg/simm16(reg)"
     ((MACH ORBIS-MACHS))
     "l.lbs $rD,${simm16}($rA)"
     (+ OPC_LBS rD rA simm16)
     (set WI rD (ext WI (mem QI (load-store-addr rA simm16 1))))
     ()
)

(dni l-lhz "l.lhz reg/simm16(reg)"
     ((MACH ORBIS-MACHS))
     "l.lhz $rD,${simm16}($rA)"
     (+ OPC_LHZ rD simm16 rA)
     (set UWI rD (zext UWI (mem UHI (load-store-addr rA simm16 2))))
     ()
)

(dni l-lhs "l.lhs reg/simm16(reg)"
     ((MACH ORBIS-MACHS))
     "l.lhs $rD,${simm16}($rA)"
     (+ OPC_LHS rD rA simm16)
     (set WI rD (ext WI (mem HI (load-store-addr rA simm16 2))))
     ()
)


; Store instructions

(define-pmacro (store-insn mnemonic opc-op mode size)
  (begin
     (dni (.sym l- mnemonic)
          (.str "l." mnemonic " simm16(reg)/reg")
          ((MACH ORBIS-MACHS))
          (.str "l." mnemonic " ${simm16-split}($rA),$rB")
          (+ opc-op rA rB simm16-split)
          (sequence ((SI addr))
		    (set addr (load-store-addr rA simm16-split size))
		    (set mode (mem mode addr) (trunc mode rB))
		    (if (eq (and addr #xffffffc) atomic-address)
			(set atomic-reserve (const 0))
			)
                    )
          ()
     )
   )
)

(store-insn sw OPC_SW USI 4)
(store-insn sb OPC_SB UQI 1)
(store-insn sh OPC_SH UHI 2)

(dni l-swa "l.swa simm16(reg)/reg"
     ((MACH ORBIS-MACHS))
     "l.swa ${simm16-split}($rA),$rB"
     (+ OPC_SWA rA rB simm16)
     (sequence ((SI addr) (BI flag))
	       (set addr (load-store-addr rA simm16-split 4))
	       (set sys-sr-f (and atomic-reserve (eq addr atomic-address)))
	       (if sys-sr-f
		   (set USI (mem USI addr) (trunc USI rB))
		   )
	       (set atomic-reserve (const 0))
	       )
     ()
)


; Shift and rotate instructions

(define-pmacro (shift-insn mnemonic)
  (begin
     (dni (.sym l- mnemonic)
          (.str "l." mnemonic " reg/reg/reg")
          ((MACH ORBIS-MACHS))
          (.str "l." mnemonic " $rD,$rA,$rB")
          (+ OPC_ALU rD rA rB (f-resv-10-3 0) (.sym OPC_SHROTS_ (.upcase mnemonic)) (f-resv-5-2 0) 
	     OPC_ALU_REGREG_SHROT )
          (set UWI rD (mnemonic rA rB))
          ()
     )
     (dni (.sym l- mnemonic "i")
          (.str "l." mnemonic " reg/reg/uimm6")
          ((MACH ORBIS-MACHS))
          (.str "l." mnemonic "i $rD,$rA,${uimm6}")
          (+ OPC_SHROTI rD rA (f-resv-15-8 0) (.sym OPC_SHROTS_ (.upcase mnemonic)) uimm6)
          (set rD (mnemonic rA uimm6))
          ()
     )
   )
)

(shift-insn sll)
(shift-insn srl)
(shift-insn sra)
(shift-insn ror)


; Arithmetic insns

; ALU op macro
(define-pmacro (alu-insn mnemonic)
  (begin
     (dni (.sym l- mnemonic)
          (.str "l." mnemonic " reg/reg/reg")
          ((MACH ORBIS-MACHS))
          (.str "l." mnemonic " $rD,$rA,$rB")
          (+ OPC_ALU rD rA rB (f-resv-10-7 0) (.sym OPC_ALU_REGREG_ (.upcase mnemonic)))
          (set rD (mnemonic rA rB))
          ()
     )
  )
)

(alu-insn and)
(alu-insn or)
(alu-insn xor)

(define-pmacro (alu-carry-insn mnemonic)
  (begin
    (dni (.sym l- mnemonic)
         (.str "l." mnemonic " reg/reg/reg")
         ((MACH ORBIS-MACHS))
         (.str "l." mnemonic " $rD,$rA,$rB")
         (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) (.sym OPC_ALU_REGREG_ (.upcase mnemonic)))
         (sequence ()
                   (sequence ()
                             (set BI sys-sr-cy ((.sym mnemonic "c-cflag") WI rA rB 0))
                             (set BI sys-sr-ov ((.sym mnemonic "c-oflag") WI rA rB 0))
                             (set rD (mnemonic WI rA rB))
                             )
                   (if (andif sys-sr-ov sys-sr-ove)
                       (raise-exception EXCEPT-RANGE))
                   )
         ()
         )
    )
  )

(alu-carry-insn add)
(alu-carry-insn sub)

(dni (l-addc) "l.addc reg/reg/reg"
          ((MACH ORBIS-MACHS))
          ("l.addc $rD,$rA,$rB")
          (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) OPC_ALU_REGREG_ADDC)
          (sequence ()
                    (sequence ((BI tmp-sys-sr-cy))
                              (set BI tmp-sys-sr-cy sys-sr-cy)
                              (set BI sys-sr-cy (addc-cflag WI rA rB tmp-sys-sr-cy))
                              (set BI sys-sr-ov (addc-oflag WI rA rB tmp-sys-sr-cy))
                              (set rD (addc WI rA rB tmp-sys-sr-cy))
                              )
                   (if (andif sys-sr-ov sys-sr-ove)
                       (raise-exception EXCEPT-RANGE))
                   )
          ()
)

(dni (l-mul) "l.mul reg/reg/reg"
          ((MACH ORBIS-MACHS))
          ("l.mul $rD,$rA,$rB")
          (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MUL)
          (sequence ()
                    (sequence ()
                              ; 2's complement overflow
                              (set BI sys-sr-ov (mul-o2flag WI rA rB))
                              ; 1's complement overflow
                              (set BI sys-sr-cy (mul-o1flag WI rA rB))
                              (set rD (mul WI rA rB))
                              )
                    (if (andif sys-sr-ov sys-sr-ove)
                        (raise-exception EXCEPT-RANGE))
                    )
          ()
)

(dni (l-mulu) "l.mulu reg/reg/reg"
          ((MACH ORBIS-MACHS))
          ("l.mulu $rD,$rA,$rB")
          (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULU)
          (sequence ()
                    (sequence ()
                              ; 2's complement overflow
                              (set BI sys-sr-ov 0)
                              ; 1's complement overflow
                              (set BI sys-sr-cy (mul-o1flag UWI rA rB))
                              (set rD (mul UWI rA rB))
                              )
                    (if (andif sys-sr-ov sys-sr-ove)
                        (raise-exception EXCEPT-RANGE))
                    )
          ()
)

(dni l-div "divide (signed)"
          ((MACH ORBIS-MACHS))
          "l.div $rD,$rA,$rB"
          (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIV)
          (sequence ()
                    (if (ne rB 0)
                        (sequence ()
                                  (set BI sys-sr-cy 0)
                                  (set WI rD (div WI rA rB))
                                  )
                        (set BI sys-sr-cy 1)
                        )
                    (set BI sys-sr-ov 0)
                    (if (andif sys-sr-cy sys-sr-ove)
                        (raise-exception EXCEPT-RANGE))
                    )
          ()
)

(dni l-divu "divide (unsigned)"
          ((MACH ORBIS-MACHS))
          "l.divu $rD,$rA,$rB"
          (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIVU)
          (sequence ()
                    (if (ne rB 0)
                        (sequence ()
                                  (set BI sys-sr-cy 0)
                                  (set rD (udiv UWI rA rB))
                                  )
                        (set BI sys-sr-cy 1)
                        )
                    (set BI sys-sr-ov 0)
                    (if (andif sys-sr-cy sys-sr-ove)
                        (raise-exception EXCEPT-RANGE))
                    )
          ()
)

(dni l-ff1 "find first '1'"
          ((MACH ORBIS-MACHS))
          "l.ff1 $rD,$rA"
          (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) OPC_ALU_REGREG_FFL1)
          (set rD (c-call UWI "@@cpu@@_ff1" rA))
          ()
)

(dni l-fl1 "find last '1'"
          ((MACH ORBIS-MACHS))
          "l.fl1 $rD,$rA"
          (+ OPC_ALU rD rA rB (f-resv-10-7 #x10) OPC_ALU_REGREG_FFL1)
          (set rD (c-call UWI "@@cpu@@_fl1" rA))
          ()
)


(define-pmacro (alu-insn-simm  mnemonic)
  (begin
      (dni (.sym l- mnemonic "i")
          (.str "l." mnemonic " reg/reg/simm16")
          ((MACH ORBIS-MACHS))
          (.str "l." mnemonic "i $rD,$rA,$simm16")
          (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA simm16)
          (set rD (mnemonic rA (ext WI simm16)))
          ()
     )
   )
)

(define-pmacro (alu-insn-uimm  mnemonic)
  (begin
      (dni (.sym l- mnemonic "i")
          (.str "l." mnemonic " reg/reg/uimm16")
          ((MACH ORBIS-MACHS))
          (.str "l." mnemonic "i $rD,$rA,$uimm16")
          (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA uimm16)
          (set rD (mnemonic rA (zext UWI uimm16)))
          ()
     )
   )
)

(alu-insn-uimm and)
(alu-insn-uimm or)
(alu-insn-simm xor)

(define-pmacro (alu-carry-insn-simm mnemonic)
  (begin
    (dni (.sym l- mnemonic "i")
         (.str "l." mnemonic "i reg/reg/simm16")
         ((MACH ORBIS-MACHS))
         (.str "l." mnemonic "i $rD,$rA,$simm16")
         (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA simm16)
         (sequence ()
                   (sequence ()
                             (set BI sys-sr-cy ((.sym mnemonic "c-cflag") WI rA (ext WI simm16) 0))
                             (set BI sys-sr-ov ((.sym mnemonic "c-oflag") WI rA (ext WI simm16) 0))
                             (set rD (mnemonic WI rA (ext WI simm16)))
                             )
                   (if (andif sys-sr-ov sys-sr-ove)
                       (raise-exception EXCEPT-RANGE))
                   )
         ()
         )
    )
  )

(alu-carry-insn-simm add)

(dni (l-addic)
     ("l.addic reg/reg/simm16")
     ((MACH ORBIS-MACHS))
     ("l.addic $rD,$rA,$simm16")
     (+ OPC_ADDIC rD rA simm16)
     (sequence ()
               (sequence ((BI tmp-sys-sr-cy))
                         (set BI tmp-sys-sr-cy sys-sr-cy)
                         (set BI sys-sr-cy (addc-cflag WI rA (ext WI simm16) tmp-sys-sr-cy))
                         (set BI sys-sr-ov (addc-oflag WI rA (ext WI simm16) tmp-sys-sr-cy))
                         (set WI rD (addc WI rA (ext WI simm16) tmp-sys-sr-cy))
                         )
               (if (andif sys-sr-ov sys-sr-ove)
                   (raise-exception EXCEPT-RANGE))
               )
     ()
)

(dni (l-muli)
     "l.muli reg/reg/simm16"
     ((MACH ORBIS-MACHS))
     ("l.muli $rD,$rA,$simm16")
     (+ OPC_MULI rD rA simm16)
     (sequence ()
               (sequence ()
                         ; 2's complement overflow
                         (set sys-sr-ov (mul-o2flag WI rA (ext WI simm16)))
                         ; 1's complement overflow
                         (set sys-sr-cy (mul-o1flag UWI rA (ext UWI simm16)))
                         (set rD (mul WI rA (ext WI simm16)))
                         )
               (if (andif sys-sr-ov sys-sr-ove)
                   (raise-exception EXCEPT-RANGE))
               )
     ()
     )

(define-pmacro (extbh-insn mnemonic extop extmode truncmode)
  (begin
    (dni (.sym l- mnemonic)
         (.str "l." mnemonic " reg/reg")
         ((MACH ORBIS-MACHS))
         (.str "l." mnemonic " $rD,$rA")
         (+ OPC_ALU rD rA (f-resv-15-6 0) (.sym OPC_EXTBHS_ (.upcase mnemonic)) (f-resv-5-2 0) OPC_ALU_REGREG_EXTBH)
         (set rD (extop extmode (trunc truncmode rA)))
         ()
         )
    )
  )

(extbh-insn exths ext  WI  HI)
(extbh-insn extbs ext  WI  QI)
(extbh-insn exthz zext UWI UHI)
(extbh-insn extbz zext UWI UQI)

(define-pmacro (extw-insn mnemonic extop extmode truncmode)
  (begin
    (dni (.sym l- mnemonic)
         (.str "l." mnemonic " reg/reg")
         ((MACH ORBIS-MACHS))
         (.str "l." mnemonic " $rD,$rA")
         (+ OPC_ALU rD rA (f-resv-15-6 0) (.sym OPC_EXTWS_ (.upcase mnemonic)) (f-resv-5-2 0) OPC_ALU_REGREG_EXTW)
         (set rD (extop extmode (trunc truncmode rA)))
         ()
         )
    )
  )

(extw-insn extws ext  WI  SI)
(extw-insn extwz zext USI USI)

(dni l-cmov
     "l.cmov reg/reg/reg"
     ((MACH ORBIS-MACHS))
     "l.cmov $rD,$rA,$rB"
     (+ OPC_ALU rD rA rB (f-resv-10-1 0) (f-op-9-2 0) (f-resv-7-4 0) OPC_ALU_REGREG_CMOV)
     (if sys-sr-f
         (set UWI rD rA)
         (set UWI rD rB)
         )
     ()
     )

; Compare instructions

; Ordering compare
(define-pmacro (sf-insn op)
  (begin
     (dni (.sym l- "sf" op "s")                                               ; l-sfgts
          (.str "l.sf" op "s reg/reg")                                        ; "l.sfgts reg/reg"
          ((MACH ORBIS-MACHS))
          (.str "l.sf" op "s $rA,$rB")                                        ; "l.sfgts $rA,$rB"
          (+ OPC_SF (.sym "OPC_SF_" (.upcase op) "S") rA rB (f-resv-10-11 0)) ; (+ OPC_SF OPC_SF_GTS rA rB (f-resv-10-11 0))
          (set sys-sr-f (op WI rA rB))                                        ; (set sys-sr-f (gt WI rA rB))
          ()
          )
     (dni (.sym l- "sf" op "si")                                              ; l-sfgtsi
          (.str "l.sf" op "si reg/simm16")                                    ; "l.sfgtsi reg/simm16"
          ((MACH ORBIS-MACHS))
          (.str "l.sf" op "si $rA,$simm16")                                   ; "l.sfgtsi $rA,$simm16"
          (+ OPC_SFI (.sym "OPC_SF_" (.upcase op) "S") rA simm16)             ; (+ OPC_SFI OPC_SF_GTS rA simm16)
          (set sys-sr-f (op WI rA (ext WI simm16)))                           ; (set sys-sr-f (gt WI rA (ext WI simm16)))
          ()
          )
     (dni (.sym l- "sf" op "u")                                               ; l-sfgtu
          (.str "l.sf" op "u reg/reg")                                        ; "l.sfgtu reg/reg"
          ((MACH ORBIS-MACHS))
          (.str "l.sf" op "u $rA,$rB")                                        ; "l.sfgtu $rA,$rB"
          (+ OPC_SF (.sym "OPC_SF_" (.upcase op) "U") rA rB (f-resv-10-11 0)) ; (+ OPC_SF OPC_SF_GTU rA rB (f-resv-10-11 0))
          (set sys-sr-f ((.sym op "u") WI rA rB))                             ; (set sys-sr-f (gtu WI rA rB))
          ()
          )
     ; immediate is sign extended even for unsigned compare
     (dni (.sym l- "sf" op "ui")                                              ; l-sfgtui
          (.str "l.sf" op "ui reg/simm16")                                    ; "l.sfgtui reg/uimm16"
          ((MACH ORBIS-MACHS))
          (.str "l.sf" op "ui $rA,$simm16")                                   ; "l.sfgtui $rA,$simm16"
          (+ OPC_SFI (.sym "OPC_SF_" (.upcase op) "U") rA simm16)             ; (+ OPC_SFI OPC_SF_GTU rA simm16)
          (set sys-sr-f ((.sym op "u") WI rA (ext WI simm16)))                ; (set sys-sr-f (gtu WI rA (ext WI simm16)))
          ()
          )
     )
  )

(sf-insn gt)
(sf-insn ge)
(sf-insn lt)
(sf-insn le)

; Equality compare
(define-pmacro (sf-insn-eq op)
  (begin
     (dni (.sym l- "sf" op)
          (.str "l." op " reg/reg")
          ((MACH ORBIS-MACHS))
          (.str "l.sf" op " $rA,$rB")
          (+ OPC_SF (.sym "OPC_SF_" (.upcase op)) rA rB (f-resv-10-11 0))
          (set sys-sr-f (op WI rA rB))
          ()
     )
     (dni (.sym l- "sf" op "i")
          (.str "l.sf" op "i reg/simm16")
          ((MACH ORBIS-MACHS))
          (.str "l.sf" op "i $rA,$simm16")
          (+ OPC_SFI (.sym "OPC_SF_" (.upcase op)) rA simm16)
          (set sys-sr-f (op WI rA (ext WI simm16)))
          ()
     )
   )
)

(sf-insn-eq eq)
(sf-insn-eq ne)

(dni l-mac
     "l.mac reg/reg"
     ((MACH ORBIS-MACHS))
     "l.mac $rA,$rB"
     (+  OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MAC)
     (sequence ((WI prod) (DI result))
               (set WI prod (mul WI rA rB))
               (set DI result (add (join DI SI mac-machi mac-maclo) (ext DI prod)))
               (set SI mac-machi (subword SI result 0))
               (set SI mac-maclo (subword SI result 1))
               )
     ()
     )

(dni l-msb
     "l.msb reg/reg"
     ((MACH ORBIS-MACHS))
     "l.msb $rA,$rB"
     (+  OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MSB)
     (sequence ((WI prod) (DI result))
               (set WI prod (mul WI rA rB))
               (set DI result (sub (join DI SI mac-machi mac-maclo) (ext DI prod)))
               (set SI mac-machi (subword SI result 0))
               (set SI mac-maclo (subword SI result 1))
               )
     ()
     )

(dni l-maci
     "l.maci reg/simm16"
     ((MACH ORBIS-MACHS))
     "l.maci $rA,${simm16}"
     (+ OPC_MACI (f-resv-25-5 0) rA simm16)
     (sequence ((WI prod) (DI result))
               (set WI prod (mul WI (ext WI simm16) rA))
               (set DI result (add (join DI SI mac-machi mac-maclo) (ext DI prod)))
               (set SI mac-machi (subword SI result 0))
               (set SI mac-maclo (subword SI result 1))
               )
     ()
     )

(define-pmacro (cust-insn cust-num)
  (begin
    (dni (.sym l- "cust" cust-num)
         (.str "l.cust" cust-num)
         ((MACH ORBIS-MACHS))
         (.str "l.cust" cust-num)
         (+ (.sym OPC_CUST cust-num) (f-resv-25-26 0))
         (nop)
         ()
         )
    )
  )

(cust-insn "1")
(cust-insn "2")
(cust-insn "3")
(cust-insn "4")
(cust-insn "5")
(cust-insn "6")
(cust-insn "7")
(cust-insn "8")
@


1.1.1.1
log
@import new gdb
@
text
@@


1.1.1.1.16.1
log
@Sync with HEAD
@
text
@d77 1
a77 1
    ((value pc) (sra IAI (sub IAI value pc) (const 2)))
a80 15
; PC relative, 21-bit, 13 shifted to right, aligned.
; Note that the alignment means that we can't simplify relocations in the
; same way as we do for pc-relative, so we use ABS-ADDR instead of PCREL-ADDR.
(df f-disp21
    "disp21"
    ((MACH ORBIS-MACHS) ABS-ADDR)
    20
    21
    INT
    ((value pc)
     (sub IAI (sra IAI value (const 13)) (sra IAI pc (const 13))))
    ((value pc)
     (sll IAI (add IAI value (sra IAI pc (const 13))) (const 13)))
    )

a136 1
   ("ADRP"	   #x02)
d207 2
a208 4
  (("MAC"   #x1)
   ("MSB"   #x2)
   ("MACU"  #x3)
   ("MSBU"  #x4)
a249 1
   ("MULD"  #x7)
a255 1
   ("MULDU" #xD)
a314 9
  (name disp21)
  (comment "pc-rel 21 bit")
  (attrs (MACH ORBIS-MACHS))
  (type h-iaddr)
  (index f-disp21)
  (handlers (parse "disp21"))
  )

(define-operand
d338 1
a338 1
  (handlers (parse "simm16_split"))
d347 1
a347 1
  (handlers (parse "uimm16_split"))
a405 8
(dni l-adrp "adrp reg/disp21"
    ((MACH ORBIS-MACHS))
    "l.adrp $rD,${disp21}"
    (+ OPC_ADRP rD disp21)
    (set UWI rD disp21)
    ()
  )

d565 1
a565 1
)
d786 15
a800 24
     ((MACH ORBIS-MACHS))
     ("l.mul $rD,$rA,$rB")
     (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MUL)
     (sequence ()
	(sequence ()
	   (set BI sys-sr-ov (mul-o2flag WI rA rB))
	   (set rD (mul WI rA rB))
	)
	(if (andif sys-sr-ov sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
     )
     ()
)

(dni (l-muld) "l.muld reg/reg"
     ((MACH ORBIS-MACHS))
     ("l.muld $rA,$rB")
     (+ OPC_ALU (f-resv-25-5 0) rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULD)
     (sequence ((DI result))
	(set DI result (mul DI (ext DI rA) (ext DI rB)))
	(set SI mac-machi (subword SI result 0))
	(set SI mac-maclo (subword SI result 1))
     )
     ()
d804 15
a818 24
     ((MACH ORBIS-MACHS))
     ("l.mulu $rD,$rA,$rB")
     (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULU)
     (sequence ()
	(sequence ()
	   (set BI sys-sr-cy (mul-o1flag UWI rA rB))
	   (set rD (mul UWI rA rB))
	)
	(if (andif sys-sr-cy sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
     )
     ()
)

(dni (l-muldu) "l.muld reg/reg"
     ((MACH ORBIS-MACHS))
     ("l.muldu $rA,$rB")
     (+ OPC_ALU (f-resv-25-5 0) rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULDU)
     (sequence ((DI result))
	(set DI result (mul DI (zext DI rA) (zext DI rB)))
	(set SI mac-machi (subword SI result 0))
	(set SI mac-maclo (subword SI result 1))
     )
     ()
d822 16
a837 15
     ((MACH ORBIS-MACHS))
     "l.div $rD,$rA,$rB"
     (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIV)
     (if (ne rB 0)
	(sequence ()
	   (set BI sys-sr-ov 0)
	   (set WI rD (div WI rA rB))
	)
	(sequence ()
	   (set BI sys-sr-ov 1)
	   (if sys-sr-ove
	      (raise-exception EXCEPT-RANGE))
	)
     )
     ()
d841 16
a856 15
     ((MACH ORBIS-MACHS))
     "l.divu $rD,$rA,$rB"
     (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIVU)
     (if (ne rB 0)
	(sequence ()
	   (set BI sys-sr-cy 0)
	   (set rD (udiv UWI rA rB))
	)
	(sequence ()
	   (set BI sys-sr-cy 1)
	   (if sys-sr-ove
	       (raise-exception EXCEPT-RANGE))
	)
     )
     ()
d954 1
d956 2
d964 1
a964 1
)
d1088 6
a1093 12
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (ext DI rA) (ext DI rB)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (add prod mac))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-ov (addc-oflag prod mac 0))
	)
	(if (andif sys-sr-ov sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
     )
a1094 18
)

(dni l-maci
     "l.maci reg/simm16"
     ((MACH ORBIS-MACHS))
     "l.maci $rA,${simm16}"
     (+ OPC_MACI (f-resv-25-5 0) rA simm16)
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (ext DI rA) (ext DI simm16)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (add mac prod))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-ov (addc-oflag prod mac 0))
	)
	(if (andif sys-sr-ov sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
a1095 22
     ()
)

(dni l-macu
     "l.macu reg/reg"
     ((MACH ORBIS-MACHS))
     "l.macu $rA,$rB"
     (+  OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MACU)
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (zext DI rA) (zext DI rB)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (add prod mac))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-cy (addc-cflag prod mac 0))
	)
	(if (andif sys-sr-cy sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
     )
     ()
)
d1102 7
a1108 11
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (ext DI rA) (ext DI rB)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (sub mac prod))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-ov (subc-oflag mac result 0))
	)
	(if (andif sys-sr-ov sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
a1109 2
     ()
)
d1111 2
a1112 2
(dni l-msbu
     "l.msbu reg/reg"
d1114 9
a1122 13
     "l.msbu $rA,$rB"
     (+  OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MSBU)
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (zext DI rA) (zext DI rB)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (sub mac prod))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-cy (subc-cflag mac result 0))
	)
	(if (andif sys-sr-cy sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
a1123 2
     ()
)
@


1.1.1.2
log
@   May 11th, 2019: GDB 8.3 Released!
          The latest version of GDB, version 8.3, is available for
          download.

          This version of GDB includes the following changes and
          enhancements:

          + Support for new native configurations (also available as a
            target configuration):
               o RISC-V GNU/Linux (riscv*-*-linux*)
               o RISC-V FreeBSD (riscv*-*-freebsd*)
          + Support for new target configurations:
               o CSKY ELF (csky*-*-elf)
               o CSKY GNU/Linux (csky*-*-linux)
               o NXP S12Z ELF (s12z-*-elf)
               o OpenRISC GNU/Linux (or1k*-*-linux*)
          + Native Windows debugging is only supported on Windows XP or
            later.
          + The Python API in GDB now requires Python 2.6 or later.
          + GDB now supports terminal styling for the CLI and TUI. Source
            highlighting is also supported by building GDB with GNU
            Highlight.
          + Experimental support for compilation and injection of C++
            source code into the inferior (requires GCC 7.1 or higher,
            built with libcp1.so).
          + GDB and GDBserver now support IPv6 connections.
          + Target description support on RISC-V targets.
          + Various enhancements to several commands:
               o "frame", "select-frame" and "info frame" commands
               o "info functions", "info types", "info variables"
               o "info thread"
               o "info proc"
               o System call alias catchpoint support on FreeBSD
               o "target remote" support for Unix Domain sockets.
          + Support for displaying all files opened by a process

         + DWARF index cache: GDB can now automatically save indices of
            DWARF symbols on disk to speed up further loading of the same
            binaries.
          + Various GDB/MI enhancements.
          + GDBserver on PowerPC GNU/Linux now supports access to the PPR,
            DSCR, TAR, EBB/PMU, and HTM registers.
          + Ada task switching support when debugging programs built with
            the Ravenscar profile added to aarch64-elf.
          + GDB in batch mode now exits with status 1 if the last executed
            command failed.
          + Support for building GDB with GCC's Undefined Behavior
            Sanitizer.

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

   February 27th, 2019: GDB 8.3 branch created
          The GDB 8.3 branch (gdb-8.3-branch) has been created. To check
          out a copy of the branch use:

git clone --branch gdb-8.3-branch ssh://sourceware.org/git/binutils-gdb.git

   December 23rd, 2018: GDB 8.2.1 Released!
          The latest version of GDB, version 8.2.1, is available for
          download.

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

          + PR build/23516 (gdb build error under msys+mingw: strip can't
            handle gdb-add-index.exe)
          + PR build/23623 (install-strip fails)
          + PR rust/23626 (gdb crashes in upstream rust nil-enum test)
          + PR rust/23650 (rust field name access error mentions "foo")
          + PR gdb/23663 (gdb 8.1.1: undefined rpl_stat function with musl
            toolchains)
          + PR python/23669 (gdb.execute("show commands") doesn't work)
          + PR python/23714 (Command repetition stops working after
            gdb.execute)
          + PR gdb/23838 (8.2 regression for invalid -data-directory)
          + PR gdb/23974 ("info os" crash when specifying invalid object)
          + PR gdb/23999 (SYMBOL_LANGUAGE assertion failure on AIX)
          + PR gdb/24003 (Error when binary searching CUs for a specific
            DIE when using DWZ)

   September 5th, 2018: GDB 8.2 Released!
          The latest version of GDB, version 8.2, is available for
          download.

          This version of GDB includes the following changes and
          enhancements:

          + Support for the following target has been added:
               o RiscV ELF (riscv*-*-elf)
          + Support for following targets and native configurations has
            been removed:
               o m88k running OpenBSD (m88*-*-openbsd*)
               o SH-5/SH64 ELF (sh64-*-elf*)
               o SH-5/SH64 (sh*)
               o SH-5/SH64 running GNU/Linux (sh*-*-linux*)
               o SH-5/SH64 running OpenBSD (sh*-*-openbsd*)
          + Various Python API enhancements
          + Aarch64/Linux enhancements:
               o SVE support.
               o Hardware watchpoints improvements for entities stored at
                 unaligned addresses.
                    # New "c" response to disable the pager for the rest
                      of the current command.
                    # C expressions can now use _Alignof, and C++
                      expressions can now use alignof.
                    # Improved flexibility for loading symbol files.
                    # The 'info proc' command nows works on running
                      processes on FreeBSD systems as well as core files
                      created on FreeBSD systems.
                    # A new --enable-codesign=CERT configure option to
                      automatically codesign GDB after build (useful on
                      MacOS X).
                 See the NEWS file for a more complete and detailed list
                 of what this release includes.

   July 31st, 2018: GDB 8.1.1 Released!
       The latest version of GDB, version 8.1.1, is available
       for download.
       This is a minor corrective release over GDB 8.1, fixing
       the following issues:
	  # PR gdb/22824 (misleading description of new rbreak
	    Python function in GDB 8.1 NEWS file)
	  # PR gdb/22849 (ctrl-c doesn't work in
	    extended-remote)
	  # PR gdb/22907 ([Regression] gdbserver doesn't work
	    with filename-only binaries)
	 # PR gdb/23028 (inconsistent disassemble of vcvtpd2dq)
	  # PR gdb/23053 (Fix -D_GLIBCXX_DEBUG gdb-add-index
	    regression)
	  # PR gdb/23127 ([AArch64] GDB cannot be used for
	    debugging software that uses high Virtual Addresses)
	  # PR server/23158 (gdbserver no longer functional on
	    Windows)
	  # PR breakpoints/23210 ([8.1/8.2 Regression] Bogus
	    Breakpoint address adjusted from 0xf7fe7dd3 to
	    0xfffffffff7fe7dd3)

   July 4th, 2018: GDB 8.2 branch created
       The GDB 8.2 branch (gdb-8.2-branch) has been created. To
       check out a copy of the branch use:
 git clone --branch gdb-8.2-branch ssh://sourceware.org/git/binutils-gdb.git

   January 31st, 2018: GDB 8.1 Released!
       The latest version of GDB, version 8.1, is available for
       download.
       Changes in this release include:
	  # Breakpoints on C++ functions are now set on all
	    scopes by default ("wild" matching);
	  # Support for inserting breakpoints on functions
	    marked with C++ ABI tags;
	  # Target floating-point arithmetic emulation during
	    expression evaluation (requires MPFR 3.1 or later);
	  # Various Python Scripting enhancements;
	  # Improved Rust support; in particular, Trait objects
	    can now be inspected when debugging Rust code;
	  # GDB no longer makes assumptions about the type of
	    symbols without debugging information to avoid
	    producing erroneous and often confusing results;
	  # The 'enable' and 'disable' commands now accept a
	    range of breakpoint locations;
	  # New 'starti' command to start the program at the
	    first instruction;
	  # New 'rbreak' command to insert a number of
	    breakpoints via a regular expression pattern
	    (requires Python);
	  # The 'ptype' command now supports printing the offset
	    and size of the fields in a struct;
	  # The 'gcore' command now supports dumping all the
	    memory mappings ('-a' command-line option);
	  # New shortcuts for TUI Single-Key mode: 'i' for
	    stepi, and 'o' for nexti;
	  # GDBserver enhancements:
	       @@ Support for transmitting environment variables
		 to GDBserver;
	       @@ Support for starting inferior processes with a
		 specified initial working directory;
	       @@ On Unix systems, support for globbing expansion
		 and variable substitution of inferior
		 command-line arguments;
	  # Various completion enhancements;
	  # The command used to compile and inject code with the
	    'compile' command is now configurable;
	  # New '--readnever' command-line option to speed the
	    GDB startup when debugging information is not
	    needed;
	  # Support for the following new native configurations:
	       @@ FreeBSD/aarch64 (aarch64*-*-freebsd*);
	       @@ FreeBSD/arm (arm*-*-freebsd*);
	  # Support for the following new targets:
	       @@ FreeBSD/aarch64 (aarch64*-*-freebsd*);
	       @@ FreeBSD/arm (arm*-*-freebsd*);
	       @@ OpenRISC ELF (or1k*-*-elf)
	  # Removed support for the following targets and native
	    configurations:
	       @@ Solaris2/x86 (i?86-*-solaris2.[0-9]);
	       @@ Solaris2/sparc (sparc*-*-solaris2.[0-9]);
       See the NEWS file for a more complete and detailed list
       of what this release includes.

   January 5th, 2018: GDB 8.1 branch created
       The GDB 8.1 branch (gdb-8.1-branch) has been created. To
       check out a copy of the branch use:
 git clone --branch gdb-8.1-branch ssh://sourceware.org/git/binutils-gdb.git

   November 1st, 2017: Debugging Tools Devroom at FOSDEM 2018
       We will have a Debugging Tools Devroom at FOSDEM 2018.
       The Call for Participation has recently been announced.
       The Devroom is on the first of the two FOSDEM days, on
       Saturday 3 Feb 2018. See you all at FOSDEM in Brussels!

   September 7th, 2017: GDB 8.0.1 Released!
       The latest version of GDB, version 8.0.1, is available
       for download.
       This is a minor corrective release over GDB 8.0, fixing
       the following issues:
	  # PR breakpoint/21886 (Compressed MIPS code debugging
	    impossible due to memory breakpoint misplacement)
	  # PR symtab/22002 (Assertion on debuggee built with
	    -gdwarf-5 -fdebug-types-section)
						  GDB News (p6 of 30)
	  # PR symtab/22003 (Incompatibility with -gdwarf-5 -
	    DW_FORM_implicit_const)
	  # PR gdb/22046 (Regression on older kernels for T
	    (stopped) processes)
	  # PR sim/20863 (gdb-7.12 powerpc-rtems4.12-gdb does
	    not build on FreeBSD)
	  # PR breakpoint/21555 ("error re-setting breakpoint"
	    on PIE executables)
	  # PR tdep/21717 ("print $fpscr" says "" until some VFP
	    data register is printed)
	  # PR exp/21827 (Regression: gdb command lookup became
	    case-sensitive; but definitions are forced into
	    lowercase)
	  # PR remote/22021 (Multi-arch exec fails with a remote
	    target)
@
text
@d77 1
a77 1
    ((value pc) (sra IAI (sub IAI value pc) (const 2)))
a80 15
; PC relative, 21-bit, 13 shifted to right, aligned.
; Note that the alignment means that we can't simplify relocations in the
; same way as we do for pc-relative, so we use ABS-ADDR instead of PCREL-ADDR.
(df f-disp21
    "disp21"
    ((MACH ORBIS-MACHS) ABS-ADDR)
    20
    21
    INT
    ((value pc)
     (sub IAI (sra IAI value (const 13)) (sra IAI pc (const 13))))
    ((value pc)
     (sll IAI (add IAI value (sra IAI pc (const 13))) (const 13)))
    )

a136 1
   ("ADRP"	   #x02)
d207 2
a208 4
  (("MAC"   #x1)
   ("MSB"   #x2)
   ("MACU"  #x3)
   ("MSBU"  #x4)
a249 1
   ("MULD"  #x7)
a255 1
   ("MULDU" #xD)
a314 9
  (name disp21)
  (comment "pc-rel 21 bit")
  (attrs (MACH ORBIS-MACHS))
  (type h-iaddr)
  (index f-disp21)
  (handlers (parse "disp21"))
  )

(define-operand
d338 1
a338 1
  (handlers (parse "simm16_split"))
d347 1
a347 1
  (handlers (parse "uimm16_split"))
a405 8
(dni l-adrp "adrp reg/disp21"
    ((MACH ORBIS-MACHS))
    "l.adrp $rD,${disp21}"
    (+ OPC_ADRP rD disp21)
    (set UWI rD disp21)
    ()
  )

d565 1
a565 1
)
d786 15
a800 24
     ((MACH ORBIS-MACHS))
     ("l.mul $rD,$rA,$rB")
     (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MUL)
     (sequence ()
	(sequence ()
	   (set BI sys-sr-ov (mul-o2flag WI rA rB))
	   (set rD (mul WI rA rB))
	)
	(if (andif sys-sr-ov sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
     )
     ()
)

(dni (l-muld) "l.muld reg/reg"
     ((MACH ORBIS-MACHS))
     ("l.muld $rA,$rB")
     (+ OPC_ALU (f-resv-25-5 0) rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULD)
     (sequence ((DI result))
	(set DI result (mul DI (ext DI rA) (ext DI rB)))
	(set SI mac-machi (subword SI result 0))
	(set SI mac-maclo (subword SI result 1))
     )
     ()
d804 15
a818 24
     ((MACH ORBIS-MACHS))
     ("l.mulu $rD,$rA,$rB")
     (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULU)
     (sequence ()
	(sequence ()
	   (set BI sys-sr-cy (mul-o1flag UWI rA rB))
	   (set rD (mul UWI rA rB))
	)
	(if (andif sys-sr-cy sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
     )
     ()
)

(dni (l-muldu) "l.muld reg/reg"
     ((MACH ORBIS-MACHS))
     ("l.muldu $rA,$rB")
     (+ OPC_ALU (f-resv-25-5 0) rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULDU)
     (sequence ((DI result))
	(set DI result (mul DI (zext DI rA) (zext DI rB)))
	(set SI mac-machi (subword SI result 0))
	(set SI mac-maclo (subword SI result 1))
     )
     ()
d822 16
a837 15
     ((MACH ORBIS-MACHS))
     "l.div $rD,$rA,$rB"
     (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIV)
     (if (ne rB 0)
	(sequence ()
	   (set BI sys-sr-ov 0)
	   (set WI rD (div WI rA rB))
	)
	(sequence ()
	   (set BI sys-sr-ov 1)
	   (if sys-sr-ove
	      (raise-exception EXCEPT-RANGE))
	)
     )
     ()
d841 16
a856 15
     ((MACH ORBIS-MACHS))
     "l.divu $rD,$rA,$rB"
     (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIVU)
     (if (ne rB 0)
	(sequence ()
	   (set BI sys-sr-cy 0)
	   (set rD (udiv UWI rA rB))
	)
	(sequence ()
	   (set BI sys-sr-cy 1)
	   (if sys-sr-ove
	       (raise-exception EXCEPT-RANGE))
	)
     )
     ()
d954 1
d956 2
d964 1
a964 1
)
d1088 6
a1093 12
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (ext DI rA) (ext DI rB)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (add prod mac))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-ov (addc-oflag prod mac 0))
	)
	(if (andif sys-sr-ov sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
     )
a1094 18
)

(dni l-maci
     "l.maci reg/simm16"
     ((MACH ORBIS-MACHS))
     "l.maci $rA,${simm16}"
     (+ OPC_MACI (f-resv-25-5 0) rA simm16)
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (ext DI rA) (ext DI simm16)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (add mac prod))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-ov (addc-oflag prod mac 0))
	)
	(if (andif sys-sr-ov sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
a1095 22
     ()
)

(dni l-macu
     "l.macu reg/reg"
     ((MACH ORBIS-MACHS))
     "l.macu $rA,$rB"
     (+  OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MACU)
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (zext DI rA) (zext DI rB)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (add prod mac))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-cy (addc-cflag prod mac 0))
	)
	(if (andif sys-sr-cy sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
     )
     ()
)
d1102 7
a1108 11
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (ext DI rA) (ext DI rB)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (sub mac prod))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-ov (subc-oflag mac result 0))
	)
	(if (andif sys-sr-ov sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
a1109 2
     ()
)
d1111 2
a1112 2
(dni l-msbu
     "l.msbu reg/reg"
d1114 9
a1122 13
     "l.msbu $rA,$rB"
     (+  OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MSBU)
     (sequence ()
	(sequence ((DI prod) (DI mac) (DI result))
	   (set DI prod (mul DI (zext DI rA) (zext DI rB)))
	   (set DI mac (join DI SI mac-machi mac-maclo))
	   (set DI result (sub mac prod))
	   (set SI mac-machi (subword SI result 0))
	   (set SI mac-maclo (subword SI result 1))
	   (set BI sys-sr-cy (subc-cflag mac result 0))
	)
	(if (andif sys-sr-cy sys-sr-ove)
	    (raise-exception EXCEPT-RANGE))
a1123 2
     ()
)
@


1.1.1.3
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
@a63 1
(dnf f-resv-8-1    "resv-8-1"                  ((MACH ORBIS-MACHS) RESERVED) 8 1)
d78 1
a78 1
    ((value pc) (add IAI (mul IAI value (const 4)) pc))
d93 1
a93 1
     (mul IAI (add IAI value (sra IAI pc (const 13))) (const 8192)))
d435 1
a435 1
(dni l-adrp "load pc-relative page address"
@


1.1.1.3.8.1
log
@Sync with HEAD
@
text
@d720 1
a720 1
     (sequence ((SI addr))
@


1.1.1.4
log
@Import gdb-15.1, previous was 13.2

ChangeLog:

2024-03-20  Simon Marchi  <simon.marchi@@efficios.com>

	* .pre-commit-config.yaml: Bump black hook to 24.3.0

2024-03-20  Simon Marchi  <simon.marchi@@efficios.com>

	* .pre-commit-config.yaml: New.

2024-03-14  Simon Marchi  <simon.marchi@@efficios.com>

	* Makefile.def: Add configure-gdbserver and all-gdbserver
	dependencies on all-libiconv.
	* Makefile.in: Re-generate.

2024-01-15  Nick Clifton  <nickc@@redhat.com>

	* 2.42 branch point.

2023-11-15  Arsen Arsenović  <arsen@@aarsen.me>

	* intl: Remove directory.  Replaced with out-of-tree GNU
	gettext.
	* .gitignore: Add '/gettext*'.
	* configure.ac (host_libs): Replace intl with gettext.
	(hbaseargs, bbaseargs, baseargs): Split baseargs into
	{h,b}baseargs.
	(skip_barg): New flag.  Skips appending current flag to
	bbaseargs.
	<library exemptions>: Exempt --with-libintl-{type,prefix} from
	target and build machine argument passing.
	* configure: Regenerate.
	* Makefile.def (host_modules): Replace intl module with gettext
	module.
	(configure-ld): Depend on configure-gettext.
	* Makefile.in: Regenerate.
	* src-release.sh: Remove references to the intl/ directory.

2023-07-03  Nick Clifton  <nickc@@redhat.com>

	2.41 Branch Point.

2023-06-26  Nick Clifton  <nickc@@redhat.com>

	* Import these updates to the config scripts

	commit 4ad4bb7c30aca1e705448ba8d51a210bbd47bb52
	Author: Paul Eggert <eggert@@cs.ucla.edu>
	Date:   Fri Jun 23 09:55:10 2023 -0700

		Quote 'like this', not `like this'.

	commit 63acb96f92473ceb5e21d873d7c0aee266b3d6d3
	Author: Paul Eggert <eggert@@cs.ucla.edu>
	Date:   Sat Jan 21 00:15:01 2023 -0600

		Fix config.sub spelling typo for "athlon"

	commit 4ce12a5c9125cedc0d0ba584444a6865396923ec
	Author: Dmitry V. Levin <ldv@@altlinux.org>
	Date:   Sun Jan 1 08:00:00 2023 +0000

		Update copyright years

	commit c397e2c040bce50bcdccb131f90115ba7e8bfc19
	Author: Arsen Arsenovi <arsen@@aarsen.me>
	Date:   Sat Sep 17 23:34:48 2022 +0200

		config.sub: add linux-mlibc targets

	commit 9f9f9b0b13197269848c76e3e057a3ed0680b4bf
	Author: Arsen Arsenovi <arsen@@aarsen.me>
	Date:   Sat Sep 17 23:34:47 2022 +0200

		config.guess: support running on Managarm systems

	commit 87e6687749da7bb2ab158a79fa83721c19ed9246
	Author: Arsen Arsenovi <arsen@@aarsen.me>
	Date:   Sat Sep 17 23:34:46 2022 +0200

		config.sub: add managarm-{mlibc,kernel} targets

	commit 20403c5701973a4cbd7e0b4bbeb627fcd424a0f1
	Author: Xiaotian Wu <wuxiaotian@@loongson.cn>
	Date:   Mon Aug 1 16:05:29 2022 +0800

		Remove loongarchx32

	commit 02ba26b218d3d3db6c56e014655faf463cefa983
	Author: Alexander von Gluck IV <kallisti5@@unixzen.com>
	Date:   Wed May 25 15:43:13 2022 -0500

		config.guess: Update Haiku guesses

	commit f56a7140386d08a531bcfd444d632b28c61a6329
	Author: Bruno Haible <bruno@@clisp.org>
	Date:   Sun May 8 19:08:08 2022 +0200

		config.guess (x86_64:Linux:*:*): Detect 32-bit ABI.

2023-04-20  Nick Clifton  <nickc@@redhat.com>

	* SECURITY.txt: New file.
	* src-release.sh (DEVO_SUPPORT): Add SECURITY.txt.

2022-12-31  Nick Clifton  <nickc@@redhat.com>

	* 2.40 binutils branch created.
@
text
@d720 1
a720 1
     (sequence ((SI addr))
@


