Home | History | Annotate | Download | only in cpu
      1 ; Copyright 2011 Free Software Foundation, Inc.
      2 ;
      3 ; Contributed by Red Hat Inc;
      4 ;
      5 ; This file is part of the GNU Binutils.
      6 ;
      7 ; This program is free software; you can redistribute it and/or modify
      8 ; it under the terms of the GNU General Public License as published by
      9 ; the Free Software Foundation; either version 3 of the License, or
     10 ; (at your option) any later version.
     11 ;
     12 ; This program is distributed in the hope that it will be useful,
     13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 ; GNU General Public License for more details.
     16 ;
     17 ; You should have received a copy of the GNU General Public License
     18 ; along with this program; if not, write to the Free Software
     19 ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     20 ; MA 02110-1301, USA.
     21 
     22 ;; This coprocessor definition is being used to verify vliw mode behaviour.
     23 ;; This is a mock-up done by Red Hat and is in no way supposed to represent
     24 ;; a real coprocessor.  The hardware is defined in mep-core.cpu.
     25 
     26 ; Coprocessor registers
     27 (define-pmacro rh-isa-1 () (ISA ext_cop1_16,ext_cop1_32,ext_cop1_48,ext_cop1_64))
     28 
     29 (define-hardware
     30   (name h-cr64-rh-1)
     31   (comment "64-bit coprocessor registers for rh coprocessor for core 1")
     32   (attrs VIRTUAL rh-isa-1)
     33   (type register DI (32))
     34   (set (index newval) (c-call VOID "h_cr64_set" index newval))
     35   (get (index) (c-call DI "h_cr64_get" index))
     36   (indices keyword "$c" (.map -reg-pair (.iota 32)))
     37 )
     38 
     39 (define-hardware
     40   (name h-cr-rh-1)
     41   (comment "32-bit coprocessor registers for rh coprocessor for core 1")
     42   (attrs VIRTUAL rh-isa-1)
     43   (type register SI (32))
     44   (set (index newval) (c-call VOID "h_cr64_set" index (ext DI newval)))
     45   (get (index) (trunc SI (c-call DI "h_cr64_get" index)))
     46   (indices keyword "$c" (.map -reg-pair (.iota 32)))
     47 )
     48 
     49 (define-hardware
     50   (name h-ccr-rh-1)
     51   (comment "Coprocessor control registers for rh coprocessor for core 1")
     52   (attrs VIRTUAL rh-isa-1)
     53   (type register SI (64))
     54   (set (index newval) (c-call VOID "h_ccr_set" index newval))
     55   (get (index) (c-call DI "h_ccr_get" index))
     56   (indices keyword "" (.map -ccr-reg-pair (.iota 64)))
     57 )
     58  
     59 ; ifields For 16-bit insns
     60 (dnf f-cphigh4 "High 4 bits" 		((ISA ext_cop1_16,ext_cop1_32,ext_cop1_48,ext_cop1_64))   0  4)
     61 (dnf f-cpcrn   "Copro Reg"  		((ISA ext_cop1_16,ext_cop1_32,ext_cop1_48,ext_cop1_64))   4  5)
     62 (dnf f-cpcrm   "Copro Reg"  		((ISA ext_cop1_16,ext_cop1_32,ext_cop1_48,ext_cop1_64))  11  5)
     63 (dnf f-uu2   "UU for 16-bit insns"      ((ISA ext_cop1_16))   9  2)
     64 (dnf f-uu3   "UU for 16-bit insns"      ((ISA ext_cop1_16))   9  3)
     65 (dnf f-cprm   "Core GPR"                ((ISA ext_cop1_16))  12  4)
     66 
     67 ; ifields For 32-bit insns (some of the above are used too)
     68 ; Notes: 
     69 ; 
     70 ;  f-alone: A value of 0111 means that the insn can run alone in 
     71 ;           one of the vliw modes.  
     72 ;
     73 ;  f-seg32:   Together f-seg32 and f-seg32-a allow 64 different 32-bit 
     74 ;  f-seg32-a: insns to be defined.
     75 (dnf f-seg32 "Enumerate 32 bit-insns"     ((ISA ext_cop1_32))   9  3)
     76 (dnf f-alone "Run-alone indicator"        ((ISA ext_cop1_16,ext_cop1_32,ext_cop1_64))  12  4) 
     77 (dnf f-seg32-a "Enumerate 32 bit-insns"   ((ISA ext_cop1_32))  21  3)
     78 (dnf f-code8 "8 bit unsigned immediate"   ((ISA ext_cop1_32))  24 8)
     79 (dnf f-cpcrm-32 "Corpocessor Reg"         ((ISA ext_cop1_32))  16  5)
     80 
     81 ; ifields for 48-bit insns
     82 ; Note: Part of f-uu12 can be broken off later to enumerate 
     83 ;       any 48-bit insns that may be added. 
     84 (dnf f-uu12 "Unusued 12 bits"            ((ISA ext_cop1_48))   4 12)
     85 (dnf f-code16a "Unsigned immediate"      ((ISA ext_cop1_48))  16 16)
     86 (dnf f-code16b "Unsigned immediate"      ((ISA ext_cop1_48,ext_cop1_64))  32 16)
     87 
     88 ; ifields for 64-bit insns
     89 (dnf f-uu8 "Unsused 8 bits"               ((ISA ext_cop1_64))   4  8)
     90 (dnf f-uu8a "Unused 13 bits"              ((ISA ext_cop1_64))  16  8)
     91 (dnf f-seg64 "Enumerate 64-bit insns"     ((ISA ext_cop1_64))  24  8)
     92 (dnf f-code16c "Unsigned immediate"       ((ISA ext_cop1_64))  48 16)
     93 (dnf f-cpcrn-64 "Coprocessor Register"    ((ISA ext_cop1_64))  32  5)
     94 (dnf f-cpcrm-64 "Coprocessor Register"    ((ISA ext_cop1_64))  37  4)
     95 (dnf f-code23 "23 Bit Unisgned Immediate" ((ISA ext_cop1_64))  41 23)
     96 (dnf f-cpccrn-64 "Coprocessor Register"   ((ISA ext_cop1_64))  32  4)
     97 (dnf f-cpccrm-64 "Core GPR"               ((ISA ext_cop1_64))  36  4)
     98 (dnf f-code24 "24 Bit Unisgned Immediate" ((ISA ext_cop1_64))  40 24)
     99 
    100 
    102 ; Operands for 16-bit insns
    103 (dnop cpcrn   "cpcrn"  ((ISA ext_cop1_16,ext_cop1_32)) h-cr64-rh-1 f-cpcrn)
    104 (dnop cpcrm   "cpcrm"  ((ISA ext_cop1_16,ext_cop1_32)) h-cr64-rh-1 f-cpcrm)
    105 (dnop cprm    "cprm"   ((ISA ext_cop1_16)) h-gpr f-cprm)
    106 
    107 ; Additional operands for 32-bit insns 
    108 (dnop code8 "imm8" ((ISA ext_cop1_32)) h-uint f-code8)
    109 
    110 ; Operands for 48-bit insns
    111 (dnop code16a "code16a" ((ISA ext_cop1_48)) h-uint f-code16a)
    112 (dnop code16b "code16b" ((ISA ext_cop1_48,ext_cop1_64)) h-uint f-code16b)
    113 
    114 ; Additional operands for 64-bit insns
    115 (dnop code16c "code16c" ((ISA ext_cop1_64)) h-uint f-code16c)
    116 (dnop cpcrn64 "cpcrn64" ((ISA ext_cop1_64)) h-cr64-rh-1 f-cpcrn-64)
    117 (dnop cpcrm64 "crm64" ((ISA ext_cop1_64)) h-gpr f-cpcrm-64)
    118 (dnop cpccrn64 "cpccrn64" ((ISA ext_cop1_64)) h-ccr-rh-1 f-cpccrn-64)
    119 (dnop cpccrm64 "cpccrm64" ((ISA ext_cop1_64)) h-gpr f-cpccrm-64)
    120 (dnop cpcode23 "cpcode23" ((ISA ext_cop1_64)) h-uint f-code23)
    121 (dnop cpcode24 "cpcode24" ((ISA ext_cop1_64)) h-uint f-code24)
    122 
    123 
    124 
    126 ; 16- and 32-bit nops can be defined as normal instructions without
    127 ; any problems.  nops take no operands, so nops longer than 32 
    128 ; bits cannot be defined as normal insns since that would result in
    129 ; decodable bits beyond cgen's 32-bit boundary.  As a result, we
    130 ; have to use macros and other real insns to create 48- and 64-bit nops.
    131 ; 
    132 ; In addition, since the names of the nops that will be created as part
    133 ; of future insn sets are not known at this time, the assembler needs a
    134 ; fixed set of nop names that it can use for automatic nop insertion.  
    135 ; The idea is that no matter what those insns are called, we don't want
    136 ; to have to change the C code in the assemblers vliw grouping validation
    137 ; and nop insertion routines.  We therefore have to create macros for
    138 ; all nops to map the macro names which are known to the assembler to the
    139 ; names of the real nop insns.
    140 ;
    141 ; These emitted insns in these macros will need to be modified when
    142 ; new nops are defined in new coprocessor insn sets.
    143 
    144 ; A real 16-bit nop insn exists
    145 (dnmi cpnop16 "cpnop16"
    146       ((ISA ext_cop1_16))
    147       "cpnop16"
    148       (emit cp16nop)
    149 )
    150 
    151 ; A real 32-bit nop insn exists
    152 (dnmi cpnop32 "cpnop32"
    153       ((ISA ext_cop1_32))
    154       "cpnop32"
    155       (emit cp32nop)
    156 )
    157 
    158 ; There is no 48-bit nop insn so we use a real "dummy" insn to enable the nop.
    159 (dnmi cpnop48 "cpnop48"
    160       ((ISA ext_cop1_48))
    161       "cpnop48"
    162       (emit cpf1nop (code16a 0) (code16b 0))
    163 )
    164 
    165 ; There is no 64-bit nop insn so we use a real "dummy" insn to enable the nop.
    166 (dnmi cpnop64 "cpnop64"
    167       ((ISA ext_cop1_64))
    168       "cpnop64"
    169       (emit cpf3nop (code16b 0) (code16c 0))
    170 )
    171 
    172 
    174 (define-pmacro (dncp116i xname xcomment xattrs xsyntax xformat xsemantics xtiming)  (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming ext_cop1_16))
    175 (define-pmacro (dncp132i xname xcomment xattrs xsyntax xformat xsemantics xtiming)  (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming ext_cop1_32))
    176 (define-pmacro (dncp148i xname xcomment xattrs xsyntax xformat xsemantics xtiming)  (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming ext_cop1_48))
    177 (define-pmacro (dncp164i xname xcomment xattrs xsyntax xformat xsemantics xtiming)  (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming ext_cop1_64))
    178 
    179 ; 16-Bit Insns
    180 (dncp116i movcp16 "16-bit coprocessor move insn"
    181         (VLIW64_NO_MATCHING_NOP)
    182         "movcp16 $cpcrn,$cpcrm"
    183         (+ (f-cphigh4 1) cpcrn (f-uu2 0) cpcrm)
    184         (set cpcrn cpcrm)
    185         () 
    186 )
    187 
    188 (dncp116i movcp16a "16-bit coprocessor move insn" 
    189 	(VLIW64_NO_MATCHING_NOP)
    190 	"movcp16a $cpcrn,$cprm"
    191         (+ (f-cphigh4 2) cpcrn (f-uu3 0) cprm)
    192         (set cpcrn (zext DI cprm))
    193         ()
    194 )
    195 
    196 (dncp116i movcp16b "16-bit coprocessor move insn" 
    197 	(VLIW64_NO_MATCHING_NOP)
    198 	"movcp16b $cprm,$cpcrn"
    199         (+ (f-cphigh4 3) cpcrn (f-uu3 0) cprm)
    200 	(set cprm (subword SI cpcrn 1))
    201         ()
    202 )
    203 
    204 (dncp116i cp16nop "16-bit coprocessor nop" 
    205 	(VLIW64_NO_MATCHING_NOP)
    206 	"cp16nop"
    207         (+ (f-cphigh4 0) (f-cpcrn 0) (f-uu2 0) (f-cpcrm 0))
    208 	(unimp "cp16nop")
    209         ()
    210 )
    211 
    212 ; 32-Bit Insns
    213 (dncp132i cp32nop "32-bit coprocessor nop" 
    214 	(VLIW64_NO_MATCHING_NOP)
    215 	"cp32nop"
    216         (+ (f-cphigh4 #xf ) (f-cpcrn 0) (f-seg32 0) (f-alone #x7) 
    217            (f-cpcrm-32 0) (f-seg32-a 0) (f-code8 0))
    218 	(unimp "cpnop32")
    219         ()
    220 )
    221 
    222 (dncp132i cpf2 "General 32-bit insn for compatibility with toshiba's tests " 
    223 	(VLIW64_NO_MATCHING_NOP)
    224 	"cpf2 $code8"
    225         (+ (f-cphigh4 #xf ) (f-cpcrn 0) (f-seg32 0) (f-alone #x7) 
    226            (f-cpcrm-32 0) (f-seg32-a 1) code8)
    227 	(unimp "cpf2")
    228         ()
    229 )
    230 
    231 ; 48-Bit Insns
    232 (dncp148i cpf1 "48-bit coprocessor helper insn" 
    233 	()
    234 	"cpf1 $code16a,$code16b"
    235         (+ (f-cphigh4 4) (f-uu12 0) code16a code16b) 
    236 	(sequence ((HI result))
    237            (if (eq code16a 0)
    238                (set pc (c-call USI "cop_exception" pc))
    239                ; Set branch condition flags to value of code16a[0:3]
    240                ; Branch condition flags do not exist yet.
    241                (nop)
    242            )
    243         )
    244         ()
    245 )
    246 
    247 (dncp148i cpf1nop "48-bit coprocessor nop insn" 
    248 	()
    249 	"cpf1nop $code16a,$code16b"
    250         (+ (f-cphigh4 5) (f-uu12 0) code16a code16b) 
    251 	(sequence ((HI result))
    252            (set result (add code16a code16b))
    253         )
    254         ()
    255 )
    256 
    257 ; 64-Bit Insns
    258 (dncp164i cpf3 "64-bit coprocessor helper insn" 
    259 	()
    260 	"cpf3 $code16b,$code16c"
    261         (+ (f-cphigh4 #xf) (f-uu8 0) (f-alone 7) (f-uu8a 0) 
    262            (f-seg64 0) code16b code16c)
    263 	(sequence ((HI result))
    264            (set result (add code16b code16c))
    265         )
    266         ()
    267 )
    268 
    269 (dncp164i cpf3nop "64-bit coprocessor helper insn" 
    270 	()
    271 	"cpf3nop $code16b,$code16c"
    272         (+ (f-cphigh4 #xf) (f-uu8 0) (f-alone 7) (f-uu8a 0) 
    273            (f-seg64 7) code16b code16c)
    274 	(sequence ((HI result))
    275            (set result (add code16b code16c))
    276         )
    277         ()
    278 )
    279 
    280 (dncp164i cmov64a "64-bit cmov" 
    281 	()
    282 	"cmov64a $cpcrn64,$cpcrm64,$cpcode23"
    283         (+ (f-cphigh4 #xf ) (f-uu8 0) (f-alone 7) (f-uu8a 0) 
    284            (f-seg64 1) cpcrn64 cpcrm64 cpcode23) 
    285         (sequence ((SI dummy))
    286            (set dummy cpcode23)
    287            (set cpcrn64 (zext DI cpcrm64)))
    288         ()
    289 )
    290 
    291 (dncp164i cmov64b "64-bit cmov" 
    292 	()
    293 	"cmov64b $cpcrm64,$cpcrn64,$cpcode23"
    294         (+ (f-cphigh4 #xf ) (f-uu8 0) (f-alone 7) (f-uu8a 0) 
    295            (f-seg64 2) cpcrn64 cpcrm64 cpcode23) 
    296         (sequence ((SI dummy))
    297           (set dummy cpcode23)
    298           (set cpcrm64 (subword SI cpcrn64 1)))
    299         ()
    300 )
    301 
    302 (dncp164i cmovh64a "64-bit cmovh" 
    303 	()
    304 	"cmovh64a $cpcrn64,$cpcrm64,$cpcode23"
    305         (+ (f-cphigh4 #xf ) (f-uu8 0) (f-alone 7) (f-uu8a 0) 
    306            (f-seg64 3) cpcrn64 cpcrm64 cpcode23) 
    307         (sequence ((SI dummy))
    308            (set dummy cpcode23)
    309            (set cpcrn64 (or (sll (zext DI cpcrm64) 32) (zext DI (subword SI cpcrn64 1)))))
    310         ()
    311 )
    312 
    313 (dncp164i cmovh64b "64-bit cmovh" 
    314 	()
    315 	"cmovh64b $cpcrm64,$cpcrn64,$cpcode23"
    316         (+ (f-cphigh4 #xf ) (f-uu8 0) (f-alone 7) (f-uu8a 0) 
    317            (f-seg64 4) cpcrn64 cpcrm64 cpcode23) 
    318         (sequence ((SI dummy))
    319            (set dummy cpcode23)
    320            (set cpcrm64 (subword SI cpcrn64 0)))
    321         ()
    322 )
    323 
    324 (dncp164i cmovc64a "64-bit cmovc" 
    325 	()
    326 	"cmovc64a $cpccrn64,$cpccrm64,$cpcode24"
    327         (+ (f-cphigh4 #xf ) (f-uu8 0) (f-alone 7) (f-uu8a 0) 
    328            (f-seg64 5) cpccrn64 cpccrm64 cpcode24) 
    329         (sequence ((SI dummy))
    330            (set dummy cpcode24)
    331            (set cpccrn64 cpccrm64))
    332         ()
    333 )
    334 
    335 (dncp164i cmovc64b "64-bit cmovc" 
    336 	()
    337 	"cmovc64b $cpccrm64,$cpccrn64,$cpcode24"
    338         (+ (f-cphigh4 #xf ) (f-uu8 0) (f-alone 7) (f-uu8a 0) 
    339            (f-seg64 6) cpccrn64 cpccrm64 cpcode24) 
    340         (sequence ((SI dummy))
    341            (set dummy cpcode24)
    342            (set cpccrm64 cpccrn64))
    343         ()
    344 )
    345 
    346