Add support to GDB for the Renesas rl78 architecture.
[external/binutils.git] / cpu / xc16x.cpu
index efa687d..4903b81 100644 (file)
   (comment "segment")
 )
 
+;; Define an operand that takes a set of handlers.
+;; dowh: define-operand-with-handlers
+(define-pmacro (dowh x-name x-comment x-attrs x-type x-index x-handlers)
+  (define-operand (name x-name) (comment x-comment)
+    (.splice attrs (.unsplice x-attrs))
+    (type x-type) (index x-index)
+    (.splice handlers (.unsplice x-handlers)))
+)
+
 (dnop sr      "source register"              () h-gr    f-r2)
 (dnop dr      "destination register"         () h-gr    f-r1)
 (dnop dri     "destination register"         () h-gr    f-r4)
 (dnop uimm7   "7 bit trap number"            (HASH-PREFIX) h-uint f-uimm7)
 (dnop uimm8   "8 bit unsigned immediate"     (HASH-PREFIX) h-uint f-uimm8)
 (dnop uimm16  "16 bit unsigned immediate"    (HASH-PREFIX) h-uint f-uimm16)
-(dnop upof16  "16 bit unsigned immediate"    (POF-PREFIX) h-addr f-memory)
+(dowh upof16  "16 bit unsigned immediate"    (POF-PREFIX) h-addr f-memory ((print "with_pof_prefix")))
 (dnop reg8    "8 bit word register number"   () h-r8 f-reg8)
 (dnop regmem8 "8 bit word register number"   () h-regmem8 f-regmem8)
 (dnop regbmem8 "8 bit byte register number"  () h-regbmem8 f-regmem8)
 (dnop memory  "16 bit memory"               () h-addr f-memory)
 (dnop memgr8  "16 bit memory"               () h-memgr8 f-memgr8)
 (dnop cbit    "carry bit"                    (SEM-ONLY) h-cbit  f-nil)
-(dnop qbit    "bit addr"                            (DOT-PREFIX) h-uint  f-qbit)
-(dnop qlobit  "bit addr"                     (DOT-PREFIX) h-uint  f-qlobit)
-(dnop qhibit  "bit addr"                     (DOT-PREFIX) h-uint  f-qhibit)
+(dowh qbit    "bit addr"                            (DOT-PREFIX) h-uint f-qbit ((print "with_dot_prefix")))
+(dowh qlobit  "bit addr"                     (DOT-PREFIX) h-uint f-qlobit ((print "with_dot_prefix")))
+(dowh qhibit  "bit addr"                     (DOT-PREFIX) h-uint f-qhibit ((print "with_dot_prefix")))
 (dnop mask8   "8 bit mask"                          (HASH-PREFIX) h-uint f-mask8)
 (dnop masklo8 "8 bit mask"                          (HASH-PREFIX) h-uint f-datahi8)
 (dnop pagenum "10 bit page number"                  (HASH-PREFIX) h-uint f-pagenum)
 (dnop data8   "8 bit data"                          (HASH-PREFIX) h-uint f-data8)
 (dnop datahi8 "8 bit data"                          (HASH-PREFIX) h-uint f-datahi8)
 (dnop sgtdisbit "segmentation enable bit"    (SEM-ONLY) h-sgtdis f-nil)
-(dnop upag16  "16 bit unsigned immediate"    (PAG-PREFIX) h-uint f-uimm16)
+(dowh upag16  "16 bit unsigned immediate"    (PAG-PREFIX) h-uint f-uimm16 ((print "with_pag_prefix")))
 (dnop useg8   "8 bit segment "              (SEG-PREFIX) h-uint f-seg8)
 (dnop useg16  "16 bit address offset"        (SEG-PREFIX) h-uint f-offset16)
 (dnop usof16  "16 bit address offset"        (SOF-PREFIX) h-uint f-offset16)
        ((PIPE OS) (IDOC MOVE))
        (.str insn " [-$"op2 "],$"op1)
        (+ opc1 opc2 op1 op2)
-       (sequence HI ()
+       (sequence ()
          (set op1 (sub op2 (const HI 2)))
          (set HI (mem HI op2) op1)
        )
        ((PIPE OS) (IDOC MOVE))
        (.str insn " $"op1 ",[$"op2"+$hash$"uimm16"]")
        (+ opc1 opc2 op1 op2 uimm16)
-       (sequence mode ((mode tmp1))
+       (sequence ((mode tmp1))
           (set mode tmp1 (add HI op2 uimm16))
           (set mode op1 (mem HI tmp1))
        )
        ((PIPE OS) (IDOC MOVE))
        (.str insn " [$"op2"+$hash$"uimm16 "],$"op1)
        (+ opc1 opc2 op1 op2 uimm16)
-       (sequence mode ((mode tmp1))
+       (sequence ((mode tmp1))
           (set mode tmp1 (add HI op1 uimm16))
           (set mode (mem HI tmp1) op1)
        )
      "movbs $sr,$drb"
      (+ OP1_13 OP2_0 drb sr)
      (sequence ()
-         (if QI (and QI drb (const 128))
-                (set HI sr (or HI (const HI 65280) drb)))
+         (if (and QI drb (const 128))
+            (set HI sr (or HI (const HI 65280) drb)))
          (set HI sr (and HI (const HI 255) drb)) 
      )
      ()
        (.str insn " $"op2 ",$"op1)
        (+ opc1 opc2 op1 op2)
        (sequence ()
-           (if QI (and QI op1 (const 128))
-                  (set HI op2 (or HI (const HI 65280) op1)))
+           (if (and QI op1 (const 128))
+              (set HI op2 (or HI (const HI 65280) op1)))
            (set HI op2 (and HI (const HI 255) op1)) 
        )
        ()
        (sequence ()
            (if (eq cond (const 1))
                (sequence ()
-                   (if QI (lt QI rel (const 0))
-                           (sequence ()
-                                ;; FIXME: (neg QI rel)
-                                ;; FIXME: (add QI rel (const 1))
-                                ;; FIXME: (mul QI rel (const 2))
-                                (set HI pc (sub HI pc rel))
-                           ))
+                   (if (lt QI rel (const 0))
+                       (sequence ()
+                                 ;; FIXME: (neg QI rel)
+                                 ;; FIXME: (add QI rel (const 1))
+                                 ;; FIXME: (mul QI rel (const 2))
+                                 (set HI pc (sub HI pc rel))
+                                 ))
                     (set HI pc (add HI pc (mul QI rel (const 2))))
                )
             )
      "jmps $hash$segm$useg8,$hash$sof$usof16"
      (+ OP1_15 OP2_10 seg usof16)
      (sequence ()
-          (if QI (eq BI sgtdisbit (const BI 0))
-                 (set QI (reg h-cr 10) useg8))
-                 (nop)
+          (if (eq BI sgtdisbit (const BI 0))
+             (set QI (reg h-cr 10) useg8))
+         ;; FIXME: previous indentation suggested this nop was the `else'
+         ;; clause of the previous `if'.
+         (nop)
           (set HI pc usof16)
      )
      ()
      "jmps $seg,$caddr"
      (+ OP1_15 OP2_10 seg caddr)
      (sequence ()
-          (if QI (eq BI sgtdisbit (const BI 0))
-                 (set QI (reg h-cr 10) seg))
-                 (nop)
+          (if (eq BI sgtdisbit (const BI 0))
+             (set QI (reg h-cr 10) seg))
+         ;; FIXME: previous indentation suggested this nop was the `else'
+         ;; clause of the previous `if'.
+         (nop)
           (set HI pc caddr)
      )
      ()
      (sequence ((HI tmp1) (HI tmp2))
           (set HI tmp1 genreg)
           (set HI tmp2 (const 1))
-          (sll HI tmp2 qlobit)
+          ;;(sll HI tmp2 qlobit) - FIXME: missing (set ...)
           (set HI tmp2 (and tmp1 tmp2))
-          (if (eq tmp2 (const 1))
+          (if (eq tmp2 (const 1)) ;; FIXME: (ne tmp2 0)?
              (sequence ()
-                (if QI (lt QI relhi (const 0))
-                       (set HI pc (add HI pc (mul QI relhi (const 2)))))
+                (if (lt QI relhi (const 0))
+                   (set HI pc (add HI pc (mul QI relhi (const 2)))))
              ))
-         (set HI pc (add HI pc (const 4))) 
+         (set HI pc (add HI pc (const 4))) ;; FIXME: Is this right?
      )
      ()
 )
      (sequence ((HI tmp1) (HI tmp2))
           (set HI tmp1 genreg)
           (set HI tmp2 (const 1))
-          (sll HI tmp2 qlobit)
+          ;;(sll HI tmp2 qlobit) - FIXME: missing (set ...)
           (set HI tmp2 (and tmp1 tmp2))
-          (if (eq tmp2 (const 1))
+          (if (eq tmp2 (const 1)) ;; FIXME: (ne tmp2 0)?
              (sequence ()
-                (if QI (lt QI relhi (const 0))
-                       (set tmp2 (const 1))
-                       (set tmp1 genreg)
-                       ;; FIXME: (sll tmp2 qlobit)
-                       ;; FIXME: (inv tmp2)
-                       (set HI tmp1(and tmp1 tmp2))
-                       (set HI genreg tmp1)
-                       (set HI pc (add HI pc (mul QI relhi (const 2)))))
+               ;; FIXME: The `else' clause has several statements.
+                (if (lt QI relhi (const 0))
+                   (set tmp2 (const 1))
+                   (set tmp1 genreg)
+                   ;; FIXME: (sll tmp2 qlobit)
+                   ;; FIXME: (inv tmp2)
+                   (set HI tmp1 (and tmp1 tmp2))
+                   (set HI genreg tmp1)
+                   (set HI pc (add HI pc (mul QI relhi (const 2)))))
              ))
-          (set HI pc (add HI pc (const 4)))
+          (set HI pc (add HI pc (const 4))) ;; FIXME: Is this right?
      )
      ()
 )
      (sequence ((HI tmp1) (HI tmp2))
           (set HI tmp1 genreg)
           (set HI tmp2 (const 1))
-          (sll HI tmp2 qlobit)
+          ;;(sll HI tmp2 qlobit) - FIXME: missing (set ...)
           (set HI tmp2 (and tmp1 tmp2))
-          (if (eq tmp2 (const 0))
+          (if (eq tmp2 (const 0)) ;; FIXME: (ne tmp2 0)?
              (sequence ()
-                (if QI (lt QI relhi (const 0))
-                       (set HI pc (add HI pc (mul QI relhi (const 2)))))
+                (if (lt QI relhi (const 0))
+                   (set HI pc (add HI pc (mul QI relhi (const 2)))))
              ))
-          (set HI pc (add HI pc (const 4)))
+          (set HI pc (add HI pc (const 4))) ;; FIXME: Is this right?
      )
      ()
 )
      (sequence ((HI tmp1) (HI tmp2))
           (set HI tmp1 genreg)
           (set HI tmp2 (const 1))
-          (sll HI tmp2 qlobit)
+          ;;(sll HI tmp2 qlobit) - FIXME: missing (set ...)
           (set HI tmp2 (and tmp1 tmp2))
           (if (eq tmp2 (const 0))
              (sequence ()
-                (if QI (lt QI relhi (const 0))
-                       (set tmp2 (const 1))
-                       (set tmp1 reg8)
-                       ;; FIXME: (sll tmp2 qbit)
-                       (set BI tmp1(or tmp1 tmp2))
-                       (set HI reg8 tmp1)
-                       (set HI pc (add HI pc (mul QI relhi (const 2)))))
+               ;; FIXME: The `else' clause has several statements.
+                (if (lt QI relhi (const 0))
+                   (set tmp2 (const 1))
+                   (set tmp1 reg8)
+                   ;; FIXME: (sll tmp2 qbit)
+                   (set BI tmp1(or tmp1 tmp2))
+                   (set HI reg8 tmp1)
+                   (set HI pc (add HI pc (mul QI relhi (const 2)))))
              ))
-          (set HI pc (add HI pc (const 4)))
+          (set HI pc (add HI pc (const 4))) ;; FIXME: Is this right?
      )
      ()
 )
           (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
          (set HI (mem HI (reg h-cr 9)) pc)
           (sequence ()
-                (if QI (lt QI rel (const 0))
-                       (sequence ()
-                           ;; FIXME: (neg QI rel)
-                           ;; FIXME: (add QI rel (const 1))
-                           ;; FIXME: (mul QI rel (const 2))
-                           (set HI pc (sub HI pc rel))
-                       ))
+                (if (lt QI rel (const 0))
+                   (sequence ()
+                             ;; FIXME: (neg QI rel)
+                             ;; FIXME: (add QI rel (const 1))
+                             ;; FIXME: (mul QI rel (const 2))
+                             (set HI pc (sub HI pc rel))
+                   ))
                 (set HI pc (add HI pc (mul QI rel (const 2))))
           )
       )
           (set HI (mem HI (reg h-cr 9)) (reg h-cr 10))
           (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
           (set HI (mem HI (reg h-cr 9)) pc)
-          (if QI (eq BI sgtdisbit (const BI 0))
-                 (set QI (reg h-cr 10) useg8))
-                 (nop)
+          (if (eq BI sgtdisbit (const BI 0))
+             (set QI (reg h-cr 10) useg8))
+         ;; FIXME: previous indentation suggested this nop was the `else'
+         ;; clause of the previous `if'.
+         (nop)
           (set HI pc usof16)
      )
      ()
           (set HI (mem HI (reg h-cr 9)) (reg h-cr 10))
           (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
           (set HI (mem HI (reg h-cr 9)) pc)
-          (if QI (eq BI sgtdisbit (const BI 0))
-                 (set QI (reg h-cr 10) seg))
-                 (nop)
+          (if (eq BI sgtdisbit (const BI 0))
+             (set QI (reg h-cr 10) seg))
+         ;; FIXME: previous indentation suggested this nop was the `else'
+         ;; clause of the previous `if'.
+         (nop)
           (set HI pc caddr)
      )
      ()
        (sequence ()
            (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
             (set HI (mem HI (reg h-cr 9)) (reg h-cr 4))
-              (if QI (eq BI sgtdisbit (const BI 0))
-                     (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
-                     (set HI (mem HI (reg h-cr 9)) (reg h-cr 10) )
-              )
-              (nop)
+           (if (eq BI sgtdisbit (const BI 0))
+               (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
+               (set HI (mem HI (reg h-cr 9)) (reg h-cr 10) )
+           )
+           (nop)
             (set HI (reg h-cr 10) (reg h-cr 11))
             (set (reg h-cr 9) (sub HI (reg h-cr 9) (const 2)))
             (set HI (mem HI (reg h-cr 9)) pc)
        (sequence ()
            (set HI pc (mem HI (reg h-cr 9)))
            (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
-              (if QI (eq BI sgtdisbit (const BI 0))
-                     (set HI (reg h-cr 10) (mem HI (reg h-cr 9)))
-              )
-              (nop)
+          (if (eq BI sgtdisbit (const BI 0))
+              (set HI (reg h-cr 10) (mem HI (reg h-cr 9)))
+           )
+          (nop)
           (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
        )
        ()
        (sequence ()
            (set HI pc (mem HI (reg h-cr 9)))
            (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
-              (if QI (eq BI sgtdisbit (const BI 0))
-                  (sequence ()
-                       (set HI (reg h-cr 10) (mem HI (reg h-cr 9)))
-                       (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
-                  )
-              )
-              (nop)
+          (if (eq BI sgtdisbit (const BI 0))
+              (sequence ()
+                        (set HI (reg h-cr 10) (mem HI (reg h-cr 9)))
+                        (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
+               )
+           )
+          (nop)
            (set HI (reg h-cr 4) (mem HI (reg h-cr 9)))
           (set (reg h-cr 9) (add HI (reg h-cr 9) (const 2)))
        )
      (+ OP1_13 OP2_1 (f-op-lbit2 0) uimm2 (f-op-bit4 0))
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_1 (f-op-lbit2 2) uimm2 (f-op-bit4 0))
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_12 (f-op-lbit2 1) uimm2 sr)
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_7 (f-op-lbit2 1) uimm2 (f-op-bit4 0) pagenum (f-qlobit 0) (f-qlobit2 0))
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_7 (f-op-lbit2 1) uimm2 (f-op-bit4 0) upag16 )
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_12 (f-op-lbit2 3) uimm2 sr)
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_7 (f-op-lbit2 3) uimm2 (f-op-bit4 0) pagenum (f-qlobit 0) (f-qlobit2 0))
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_12 (f-op-lbit2 0) uimm2 sr)
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_7 (f-op-lbit2 0) uimm2 (f-op-bit4 0) seghi8 (f-op-bit8 0))
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_12 (f-op-lbit2 2) uimm2 sr)
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
      (+ OP1_13 OP2_7 (f-op-lbit2 2) uimm2 (f-op-bit4 0) seghi8 (f-op-bit8 0))
      (sequence ((HI count))
          (set HI count uimm2)
-          (cond HI
+          (cond
            ((ne HI count (const 0))
            (sequence ()
               (set HI pc (add HI pc (const 2)))
          (set HI count (const 0))
          (set HI tmp1 sr)
          (set HI tmp2 (and tmp1 (const 32768)))
-          (cond HI
-           ((ne HI tmp2 (const 1)) (ne HI sr (const 0))
-              (sll HI tmp1 (const 1))
+          (cond
+           ((ne HI tmp2 (const 1)) ;;(ne HI sr (const 0)) - FIXME: and? or?
+              ;;(sll HI tmp1 (const 1)) - FIXME: missing (set ...)
                (set HI tmp2 (and tmp1 (const 32768)))
                (set HI count (add HI count (const 1)))
             )