1*16dce513Schristos; CRIS CPU description. -*- Scheme -*- 2*16dce513Schristos; 3*16dce513Schristos; Copyright 2003, 2004, 2007, 2009 Free Software Foundation, Inc. 4*16dce513Schristos; 5*16dce513Schristos; Contributed by Axis Communications AB. 6*16dce513Schristos; 7*16dce513Schristos; This file is part of the GNU Binutils. 8*16dce513Schristos; 9*16dce513Schristos; This program is free software; you can redistribute it and/or modify 10*16dce513Schristos; it under the terms of the GNU General Public License as published by 11*16dce513Schristos; the Free Software Foundation; either version 3 of the License, or 12*16dce513Schristos; (at your option) any later version. 13*16dce513Schristos; 14*16dce513Schristos; This program is distributed in the hope that it will be useful, 15*16dce513Schristos; but WITHOUT ANY WARRANTY; without even the implied warranty of 16*16dce513Schristos; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*16dce513Schristos; GNU General Public License for more details. 18*16dce513Schristos; 19*16dce513Schristos; You should have received a copy of the GNU General Public License 20*16dce513Schristos; along with this program; if not, write to the Free Software 21*16dce513Schristos; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 22*16dce513Schristos; MA 02110-1301, USA. 23*16dce513Schristos 24*16dce513Schristos(include "simplify.inc") 25*16dce513Schristos 26*16dce513Schristos;;;;;;;;;;;;;;;;;; -pmacro (generic ones) 27*16dce513Schristos 28*16dce513Schristos(define-pmacro (.car2 l) (.apply (.pmacro (a b) a) l)) 29*16dce513Schristos(define-pmacro (.cadr2 l) (.apply (.pmacro (a b) b) l)) 30*16dce513Schristos(define-pmacro (SI-ext x) "How to sign-extend a dword to dword (a nop)" x) 31*16dce513Schristos(define-pmacro (HI-ext x) "How to sign-extend a word to dword" (ext SI x)) 32*16dce513Schristos(define-pmacro (QI-ext x) "How to sign-extend a byte to dword" (ext SI x)) 33*16dce513Schristos(define-pmacro (SI-zext x) "How to zero-extend a dword to dword (a nop)" x) 34*16dce513Schristos(define-pmacro (HI-zext x) "How to zero-extend a word to dword" (zext SI x)) 35*16dce513Schristos(define-pmacro (QI-zext x) "How to zero-extend a byte to dword" (zext SI x)) 36*16dce513Schristos(define-pmacro 37*16dce513Schristos (define-pmacro-map x) 38*16dce513Schristos "On a list ((x0 y0) .. (xN yN)), 0 <= m <= N, (define-pmacro xm ym)" 39*16dce513Schristos (.splice 40*16dce513Schristos begin 41*16dce513Schristos (.unsplice 42*16dce513Schristos (.map 43*16dce513Schristos (.pmacro (l) (.apply (.pmacro (xm ym) (define-pmacro xm ym)) l)) x))) 44*16dce513Schristos) 45*16dce513Schristos 46*16dce513Schristos;;;;;;;;;;;;;;;;;; -arch -isa -cpu -model 47*16dce513Schristos 48*16dce513Schristos(define-arch 49*16dce513Schristos (name cris) 50*16dce513Schristos (comment "Axis Communications CRIS") 51*16dce513Schristos (default-alignment unaligned) 52*16dce513Schristos (insn-lsb0? #t) 53*16dce513Schristos (machs crisv0 crisv3 crisv8 crisv10 crisv32) 54*16dce513Schristos (isas cris) 55*16dce513Schristos) 56*16dce513Schristos 57*16dce513Schristos(define-isa 58*16dce513Schristos (name cris) 59*16dce513Schristos (base-insn-bitsize 16) 60*16dce513Schristos (liw-insns 1) 61*16dce513Schristos (parallel-insns 1) 62*16dce513Schristos) 63*16dce513Schristos 64*16dce513Schristos(define-pmacro 65*16dce513Schristos (define-cpu-cris x-suffix x-comment) 66*16dce513Schristos "Define a CRIS CPU family" 67*16dce513Schristos (define-cpu 68*16dce513Schristos (name (.sym cris x-suffix f)) 69*16dce513Schristos (comment x-comment) 70*16dce513Schristos (endian little) 71*16dce513Schristos ; CGEN-FIXME: Should be deduced from the default? 72*16dce513Schristos (word-bitsize 32) 73*16dce513Schristos (file-transform (.str x-suffix)) 74*16dce513Schristos ) 75*16dce513Schristos) 76*16dce513Schristos 77*16dce513Schristos; Useful when there's a need to iterate over all models. 78*16dce513Schristos(define-pmacro (cris-cpu-model-numbers) 79*16dce513Schristos "List of CRIS CPU model numbers (version register contents)" 80*16dce513Schristos (0 3 8 10 32) 81*16dce513Schristos) 82*16dce513Schristos 83*16dce513Schristos(define-pmacro (cris-cpu-models) 84*16dce513Schristos "List of CRIS CPU model names" 85*16dce513Schristos (.map (.pmacro (n) (.sym v n)) (cris-cpu-model-numbers)) 86*16dce513Schristos) 87*16dce513Schristos 88*16dce513Schristos; Mapping from model name to number. 89*16dce513Schristos(define-pmacro-map 90*16dce513Schristos (.map (.pmacro (n) ((.sym v n -number) n)) 91*16dce513Schristos (cris-cpu-model-numbers))) 92*16dce513Schristos 93*16dce513Schristos; FIXME: Rationalize these rules. 94*16dce513Schristos; CPU names must be distinct from the architecture name and machine names. 95*16dce513Schristos; The "b" suffix stands for "base" and is the convention. 96*16dce513Schristos; The "f" suffix stands for "family" and is the convention. 97*16dce513Schristos; We ignore the "b" convention, partly because v0 isn't really a "base", at 98*16dce513Schristos; least not for some aspects of v32. 99*16dce513Schristos(define-cpu-cris v0 "CRIS base family") 100*16dce513Schristos(define-cpu-cris v3 "CRIS v3 family") 101*16dce513Schristos(define-cpu-cris v8 "CRIS v8 family") 102*16dce513Schristos(define-cpu-cris v10 "CRIS v10 family") 103*16dce513Schristos(define-cpu-cris v32 "CRIS v32 family") 104*16dce513Schristos 105*16dce513Schristos(define-pmacro MACH-PRE-V32 (MACH crisv0,crisv3,crisv8,crisv10)) 106*16dce513Schristos(define-pmacro MACH-V3-UP (MACH crisv3,crisv8,crisv10,crisv32)) 107*16dce513Schristos(define-pmacro MACH-V32 (MACH crisv32)) 108*16dce513Schristos(define-pmacro MACH-PC MACH-PRE-V32) 109*16dce513Schristos(define-pmacro MACH-ACR MACH-V32) 110*16dce513Schristos(define-pmacro MACH-BRANCH-OFFSET-AT-INSN MACH-V32) 111*16dce513Schristos(define-pmacro MACH-BRANCH-OFFSET-AFTER-INSN MACH-PRE-V32) 112*16dce513Schristos 113*16dce513Schristos(define-pmacro 114*16dce513Schristos current-mach-is-v32 115*16dce513Schristos "Whether the generated code is for V32. See comment at h-v32." 116*16dce513Schristos (reg h-v32) 117*16dce513Schristos) 118*16dce513Schristos 119*16dce513Schristos(define-pmacro (define-mach-cris x-suffix x-comment x-name) 120*16dce513Schristos "Define a CRIS mach" 121*16dce513Schristos (define-mach 122*16dce513Schristos (name (.sym cris x-suffix)) 123*16dce513Schristos ; They're all called "cris" in bfd. Watch out for breakages for some 124*16dce513Schristos ; uses. 125*16dce513Schristos (bfd-name x-name) 126*16dce513Schristos (comment x-comment) 127*16dce513Schristos (cpu (.sym cris x-suffix f))) 128*16dce513Schristos) 129*16dce513Schristos 130*16dce513Schristos(define-mach-cris v0 "Generic CRIS v0 CPU, ETRAX 1 .. 3" "cris") 131*16dce513Schristos(define-mach-cris v3 "Generic CRIS v3 CPU, ETRAX 4" "cris") 132*16dce513Schristos(define-mach-cris v8 "Generic CRIS v8 CPU, ETRAX 100" "cris") 133*16dce513Schristos(define-mach-cris v10 "Generic CRIS v10 CPU, ETRAX 100 LX" "cris") 134*16dce513Schristos(define-mach-cris v32 "Generic CRIS v32 CPU, ETRAX FS" "crisv32") 135*16dce513Schristos 136*16dce513Schristos(define-pmacro (define-model-simplecris x-name x-comment) 137*16dce513Schristos "Define a simple CRIS model" 138*16dce513Schristos (define-model 139*16dce513Schristos (name (.sym cris x-name)) 140*16dce513Schristos (comment x-comment) 141*16dce513Schristos (mach (.sym cris x-name)) 142*16dce513Schristos 143*16dce513Schristos (unit u-exec "Execution Unit" () 1 1 () () () ()) 144*16dce513Schristos (unit u-mem "Memory Unit" () 1 1 () () () ()) 145*16dce513Schristos 146*16dce513Schristos (unit u-const16 "Fetch 16-bit operand" () 1 1 () () () ()) 147*16dce513Schristos (unit u-const32 "Fetch 32-bit operand" () 1 1 148*16dce513Schristos () () () ()) 149*16dce513Schristos ; Used in special-case insn, for example arithmetic with PC destination. 150*16dce513Schristos (unit u-stall "Stall unit" () 1 1 () () () ()) 151*16dce513Schristos (unit u-skip4 "Skip 4 bytes" () 1 1 () () () ()) 152*16dce513Schristos (unit u-multiply "Multiply Unit" () 1 1 ((MACH crisv10)) () () ()) 153*16dce513Schristos (unit u-movem "Movem Unit" () 1 1 () 154*16dce513Schristos ((Rd INT -1)) 155*16dce513Schristos () ())) 156*16dce513Schristos) 157*16dce513Schristos 158*16dce513Schristos(define-model-simplecris v0 "Model of CRIS v0, ETRAX 1 .. 3") 159*16dce513Schristos(define-model-simplecris v3 "Model of CRIS v3, ETRAX 4") 160*16dce513Schristos(define-model-simplecris v8 "Model of CRIS v8, ETRAX 100") 161*16dce513Schristos(define-model-simplecris v10 "Model of CRIS v10, ETRAX 100 LX") 162*16dce513Schristos 163*16dce513Schristos; For some reason, we get an error: 164*16dce513Schristos; Generating arch.h ... 165*16dce513Schristos; ERROR: In procedure vector-ref: 166*16dce513Schristos; ERROR: Wrong type argument in position 1: () 167*16dce513Schristos; if we include timings for machs that we don't generate sims for. 168*16dce513Schristos; Last checked: CVS as of 2004-11-18. 169*16dce513Schristos; CGEN-FIXME: Looks like another CGEN bug. When it's fixed (or when 170*16dce513Schristos; generating sims for v0, v3 or v8), add 0, 3 and 8 to 171*16dce513Schristos; simplecris-timing-models. But before that, simplecris-timing-x has to 172*16dce513Schristos; be rewritten to work on a multiple-element-list, not assume a single 173*16dce513Schristos; element. (A change which seems likely to depend on lexical scoping for 174*16dce513Schristos; macros to be introduced: try the obvious implementation.) 175*16dce513Schristos(define-pmacro simplecris-timing-models (10)) 176*16dce513Schristos(define-pmacro (simplecris-common-timing x-units) 177*16dce513Schristos "Make timing models, using x-units for all simplecris-timing-models" 178*16dce513Schristos ; CGEN-FIXME: Another CGEN bug: the part (.unsplice (10)) will remain 179*16dce513Schristos ; unexpanded in (.sym crisv (.unsplice (10)) if we write this as 180*16dce513Schristos ; ((.splice (.sym crisv (.unsplice simplecris-timing-models)) 181*16dce513Schristos ; (.unsplice x-units))) 182*16dce513Schristos ((.splice (.sym crisv (.apply (.pmacro (x) x) simplecris-timing-models)) 183*16dce513Schristos (.unsplice x-units))) 184*16dce513Schristos) 185*16dce513Schristos 186*16dce513Schristos(define-pmacro-map 187*16dce513Schristos ( 188*16dce513Schristos ; Timing for memory instructions running on a simple cris model. 189*16dce513Schristos ((simplecris-mem-timing) (simplecris-common-timing 190*16dce513Schristos ((unit u-mem) (unit u-exec)))) 191*16dce513Schristos ; Timing for movem instructions running on a simple cris model. 192*16dce513Schristos ((simplecris-movem-timing) (simplecris-common-timing 193*16dce513Schristos ((unit u-movem) (unit u-exec)))) 194*16dce513Schristos ; Similar, for an 8- or 16-bit constant ([PC+]) operand. 195*16dce513Schristos ((simplecris-const-timing-HI) 196*16dce513Schristos (simplecris-common-timing 197*16dce513Schristos ((unit u-const16) (unit u-exec)))) 198*16dce513Schristos ; Similar, for a 32-bit constant ([PC+]) operand. 199*16dce513Schristos ((simplecris-const-timing-SI) 200*16dce513Schristos (simplecris-common-timing 201*16dce513Schristos ((unit u-const32) (unit u-exec)))) 202*16dce513Schristos ; Similar, no particular operand. 203*16dce513Schristos ((simplecris-timing) (simplecris-common-timing 204*16dce513Schristos ((unit u-exec))))) 205*16dce513Schristos) 206*16dce513Schristos 207*16dce513Schristos(define-model 208*16dce513Schristos (name crisv32) 209*16dce513Schristos (comment "Model of CRISv32") 210*16dce513Schristos (mach crisv32) 211*16dce513Schristos 212*16dce513Schristos (state 213*16dce513Schristos ; Bitmask of h-gr register (0..15) and h-sr register (17..31) 214*16dce513Schristos ; modified by 3rd previous insn, updated by the u-exec unit. 215*16dce513Schristos ; Because there's no need to mark writes to special registers BZ and 216*16dce513Schristos ; WZ, bit 16 is for jump mark and bit 20 for memory-write mark. 217*16dce513Schristos (prev-prev-prev-modf-regs UINT) 218*16dce513Schristos 219*16dce513Schristos ; Ditto for the 2nd previous insn. 220*16dce513Schristos (prev-prev-modf-regs UINT) 221*16dce513Schristos 222*16dce513Schristos ; Ditto for the previous insn. 223*16dce513Schristos (prev-modf-regs UINT) 224*16dce513Schristos 225*16dce513Schristos ; Bit-mask for regs modified by the current insn, propagated to 226*16dce513Schristos ; prev-modf-regs. 227*16dce513Schristos (modf-regs UINT) 228*16dce513Schristos 229*16dce513Schristos ; Registers loaded by movem are not forwarded to the execution 230*16dce513Schristos ; stage, so we need to insert stall-cycles for ordinary insns 231*16dce513Schristos ; accessing such registers. In addition to the *modf-regs 232*16dce513Schristos ; above, these are set to tell *ordinary* insns which registers 233*16dce513Schristos ; are inaccessible. 234*16dce513Schristos 235*16dce513Schristos (prev-prev-prev-movem-dest-regs UINT) 236*16dce513Schristos 237*16dce513Schristos ; Ditto for the 2nd previous insn. 238*16dce513Schristos (prev-prev-movem-dest-regs UINT) 239*16dce513Schristos 240*16dce513Schristos ; Ditto for the previous insn. 241*16dce513Schristos (prev-movem-dest-regs UINT) 242*16dce513Schristos 243*16dce513Schristos ; Bit-mask for regs modified by the current insn, propagated to 244*16dce513Schristos ; prev-movem-dest-regs. 245*16dce513Schristos (movem-dest-regs UINT)) 246*16dce513Schristos 247*16dce513Schristos ; It seems this pipeline description isn't used at all; this is just 248*16dce513Schristos ; for show. 249*16dce513Schristos ; Noteworthy is the placement of the memory stage before the execute stage. 250*16dce513Schristos (pipeline all "" () ((fetch) (decode) (memory) (execute) (writeback))) 251*16dce513Schristos 252*16dce513Schristos ; Units that contribute only a constant pipeline delay are not included. 253*16dce513Schristos (unit u-mem "Memory Unit" () 1 1 () 254*16dce513Schristos ((Rs INT -1)) 255*16dce513Schristos () ()) 256*16dce513Schristos 257*16dce513Schristos ; Artificial units for read/write-related hazard accounting. 258*16dce513Schristos (unit u-mem-r "Memory Unit Read" () 1 1 () () () ()) 259*16dce513Schristos (unit u-mem-w "Memory Unit Write" () 1 1 () () () ()) 260*16dce513Schristos 261*16dce513Schristos (unit u-movem-rtom "Movem-to-memory Unit" () 1 1 () 262*16dce513Schristos ((Rs INT -1) (Rd INT -1)) 263*16dce513Schristos () ()) 264*16dce513Schristos (unit u-movem-mtor "Movem-to-register Unit" () 1 1 () 265*16dce513Schristos ((Rs INT -1) (Rd INT -1)) 266*16dce513Schristos () ()) 267*16dce513Schristos (unit u-multiply "Multiply Unit" () 1 1 () 268*16dce513Schristos ((Rs INT -1) (Rd INT -1)) 269*16dce513Schristos () ()) 270*16dce513Schristos (unit u-branch "Branch Unit" () 1 1 () 271*16dce513Schristos () 272*16dce513Schristos () ()) 273*16dce513Schristos (unit u-jump-r "Jump-to-register Unit" () 1 1 () 274*16dce513Schristos ((Rs INT -1)) 275*16dce513Schristos () ()) 276*16dce513Schristos (unit u-jump-sr "Jump-to-special-register Unit" () 1 1 () 277*16dce513Schristos ((Ps INT -1)) 278*16dce513Schristos () ()) 279*16dce513Schristos (unit u-jump "JAS/BAS Unit, saving PC" () 1 1 () 280*16dce513Schristos () 281*16dce513Schristos ((Pd INT -1)) ()) 282*16dce513Schristos 283*16dce513Schristos ; To keep track of PC; not really functional units. 284*16dce513Schristos (unit u-const16 "Fetch 16-bit operand" () 1 1 () () () ()) 285*16dce513Schristos (unit u-const32 "Fetch 32-bit operand" () 1 1 () () () ()) 286*16dce513Schristos (unit u-skip4 "Skip 4 bytes" () 1 1 () () () ()) 287*16dce513Schristos 288*16dce513Schristos ; For v32, we need to keep track of inputs (for movem destination 289*16dce513Schristos ; cycle penalties) and output (for e.g. memory source and jump 290*16dce513Schristos ; source cycle penalties). 291*16dce513Schristos (unit u-exec "Execution Unit" () 1 1 () 292*16dce513Schristos ((Rd INT -1) (Rs INT -1)) 293*16dce513Schristos ((Rd INT -1)) 294*16dce513Schristos ()) 295*16dce513Schristos 296*16dce513Schristos ; Special case of u-exec for movem: don't treat Rd as an incoming 297*16dce513Schristos ; parameter. 298*16dce513Schristos (unit u-exec-movem "Execution Unit" () 1 1 () 299*16dce513Schristos ((Rs INT -1)) 300*16dce513Schristos ((Rd INT -1)) 301*16dce513Schristos ()) 302*16dce513Schristos 303*16dce513Schristos ; Special case of u-exec when the destination is a special 304*16dce513Schristos ; register. 305*16dce513Schristos (unit u-exec-to-sr "Execution Unit" () 1 1 () 306*16dce513Schristos ((Rs INT -1)) 307*16dce513Schristos ((Pd INT -1)) ()) 308*16dce513Schristos) 309*16dce513Schristos 310*16dce513Schristos(define-pmacro (crisv32-timing-destreg d) 311*16dce513Schristos "Timing for instructions running on a crisv32 model" 312*16dce513Schristos ((crisv32 313*16dce513Schristos (.splice unit u-exec (.unsplice d)))) 314*16dce513Schristos) 315*16dce513Schristos(define-pmacro (crisv32-timing) (crisv32-timing-destreg ())) 316*16dce513Schristos 317*16dce513Schristos(define-pmacro (cris-timing-Rd-sfield) 318*16dce513Schristos (crisv32-timing-destreg ((out Rd Rd-sfield))) 319*16dce513Schristos) 320*16dce513Schristos 321*16dce513Schristos(define-pmacro (crisv32-timing-c-HI) 322*16dce513Schristos ((crisv32 (unit u-const16) (unit u-exec))) 323*16dce513Schristos) 324*16dce513Schristos 325*16dce513Schristos(define-pmacro-map 326*16dce513Schristos ((crisv32-timing-c-QI crisv32-timing-c-HI) 327*16dce513Schristos ((crisv32-timing-c-SI) ((crisv32 (unit u-const32) (unit u-exec)))) 328*16dce513Schristos ((crisv32-timing-c-sr-SI) ((crisv32 (unit u-const32) (unit u-exec-to-sr)))) 329*16dce513Schristos ((crisv32-reg-sr-timing) ((crisv32 (unit u-exec-to-sr)))) 330*16dce513Schristos ((crisv32-mem-sr-timing) 331*16dce513Schristos ((crisv32 (unit u-mem) (unit u-mem-r) (unit u-exec-to-sr)))) 332*16dce513Schristos ((crisv32-mem-timing) ((crisv32 (unit u-mem) (unit u-mem-r) (unit u-exec)))) 333*16dce513Schristos ((crisv32-mem-write-timing) ((crisv32 (unit u-mem) (unit u-exec) (unit u-mem-w))))) 334*16dce513Schristos) 335*16dce513Schristos 336*16dce513Schristos(define-pmacro-map 337*16dce513Schristos ( 338*16dce513Schristos ; Timing for instructions using memory operands. 339*16dce513Schristos ((cris-mem-timing) (.splice (.unsplice (simplecris-mem-timing)) 340*16dce513Schristos (.unsplice (crisv32-mem-timing)))) 341*16dce513Schristos ; Timing for instructions using memory operands. 342*16dce513Schristos ((cris-mem-write-timing) (.splice 343*16dce513Schristos (.unsplice (simplecris-mem-timing)) 344*16dce513Schristos (.unsplice (crisv32-mem-write-timing)))) 345*16dce513Schristos ; Timing for moves from general register to special register. 346*16dce513Schristos ((cris-reg-sr-timing) (.splice (.unsplice (simplecris-timing)) 347*16dce513Schristos (.unsplice (crisv32-reg-sr-timing)))) 348*16dce513Schristos ; Timing for moves from memory to special register. 349*16dce513Schristos ((cris-mem-sr-timing) (.splice (.unsplice (simplecris-mem-timing)) 350*16dce513Schristos (.unsplice (crisv32-mem-sr-timing)))) 351*16dce513Schristos ; Timing for non-mul, non-memory, non-special-register, 16-bit instructions. 352*16dce513Schristos ((cris-timing) (.splice (.unsplice (simplecris-timing)) 353*16dce513Schristos (.unsplice (crisv32-timing)))) 354*16dce513Schristos ; Timing for instructions with 8- or 16-bit constant operand ([PC+]). 355*16dce513Schristos ((cris-timing-const-HI) (.splice 356*16dce513Schristos (.unsplice (simplecris-const-timing-HI)) 357*16dce513Schristos (.unsplice (crisv32-timing-c-HI)))) 358*16dce513Schristos ; Timing for instructions with a 32-bit constant operand ([PC+]). 359*16dce513Schristos ((cris-timing-const-SI) (.splice 360*16dce513Schristos (.unsplice (simplecris-const-timing-SI)) 361*16dce513Schristos (.unsplice (crisv32-timing-c-SI)))) 362*16dce513Schristos ; Like cris-timing-const-SI, but destination special register. 363*16dce513Schristos ((cris-timing-const-sr-SI) (.splice 364*16dce513Schristos (.unsplice (simplecris-const-timing-SI)) 365*16dce513Schristos (.unsplice (crisv32-timing-c-sr-SI)))) 366*16dce513Schristos ; Like cris-timing-const-HI, but destination special register. 367*16dce513Schristos ((cris-timing-const-sr-HI) (.splice 368*16dce513Schristos (.unsplice (simplecris-const-timing-HI)) 369*16dce513Schristos (.unsplice (crisv32-timing-c-sr-SI))))) 370*16dce513Schristos) 371*16dce513Schristos 372*16dce513Schristos(define-pmacro cris-timing-const-QI cris-timing-const-HI) 373*16dce513Schristos(define-pmacro cris-timing-const-sr-QI cris-timing-const-sr-HI) 374*16dce513Schristos 375*16dce513Schristos(define-pmacro (simplecris-common-writable-specregs) 376*16dce513Schristos "The common writable special registers in pre-v32 models." 377*16dce513Schristos ((HI 5) (SI 9) (SI 10) (SI 11) (SI 12) (SI 13)) 378*16dce513Schristos) 379*16dce513Schristos 380*16dce513Schristos(define-pmacro (simplecris-common-readable-specregs) 381*16dce513Schristos "The common readable special registers in pre-v32 models." 382*16dce513Schristos (.splice (.unsplice (simplecris-common-writable-specregs)) 383*16dce513Schristos (QI 0) (QI 1) (HI 4) (SI 8)) 384*16dce513Schristos) 385*16dce513Schristos 386*16dce513Schristos(define-pmacro (cris-implemented-writable-specregs-v0) 387*16dce513Schristos "Special writable registers in v0 and their sizes" 388*16dce513Schristos (.splice (.unsplice (simplecris-common-writable-specregs)) (HI 6) (HI 7)) 389*16dce513Schristos) 390*16dce513Schristos(define-pmacro 391*16dce513Schristos cris-implemented-specregs-const-v0 392*16dce513Schristos cris-implemented-writable-specregs-v0 393*16dce513Schristos) 394*16dce513Schristos(define-pmacro (cris-implemented-readable-specregs-v0) 395*16dce513Schristos "Special readable registers in v0 and their sizes" 396*16dce513Schristos (.splice (.unsplice (simplecris-common-readable-specregs)) (HI 6) (HI 7)) 397*16dce513Schristos) 398*16dce513Schristos 399*16dce513Schristos(define-pmacro (cris-implemented-writable-specregs-v3) 400*16dce513Schristos "Special writable registers in v3 and their sizes" 401*16dce513Schristos (.splice (.unsplice (cris-implemented-writable-specregs-v0)) (SI 14)) 402*16dce513Schristos) 403*16dce513Schristos(define-pmacro 404*16dce513Schristos cris-implemented-specregs-const-v3 405*16dce513Schristos cris-implemented-writable-specregs-v3 406*16dce513Schristos) 407*16dce513Schristos(define-pmacro (cris-implemented-readable-specregs-v3) 408*16dce513Schristos "Special readable registers in v3 and their sizes" 409*16dce513Schristos (.splice (.unsplice (cris-implemented-readable-specregs-v0)) (SI 14)) 410*16dce513Schristos) 411*16dce513Schristos 412*16dce513Schristos(define-pmacro (cris-implemented-writable-specregs-v8) 413*16dce513Schristos "Special writable registers in v8 and their sizes" 414*16dce513Schristos (.splice (.unsplice (simplecris-common-writable-specregs)) (SI 14)) 415*16dce513Schristos) 416*16dce513Schristos(define-pmacro 417*16dce513Schristos cris-implemented-specregs-const-v8 418*16dce513Schristos cris-implemented-writable-specregs-v8 419*16dce513Schristos) 420*16dce513Schristos(define-pmacro (cris-implemented-readable-specregs-v8) 421*16dce513Schristos "Special readable registers in v8 and their sizes" 422*16dce513Schristos (.splice (.unsplice (simplecris-common-readable-specregs)) (SI 14)) 423*16dce513Schristos) 424*16dce513Schristos 425*16dce513Schristos(define-pmacro (cris-implemented-writable-specregs-v10) 426*16dce513Schristos "Special writable registers in v10 and their sizes" 427*16dce513Schristos (.splice (.unsplice (simplecris-common-writable-specregs)) 428*16dce513Schristos (SI 7) (SI 14) (SI 15)) 429*16dce513Schristos) 430*16dce513Schristos(define-pmacro 431*16dce513Schristos cris-implemented-specregs-const-v10 432*16dce513Schristos cris-implemented-writable-specregs-v10 433*16dce513Schristos) 434*16dce513Schristos(define-pmacro (cris-implemented-readable-specregs-v10) 435*16dce513Schristos "Special registers in v10 and their sizes" 436*16dce513Schristos (.splice (.unsplice (simplecris-common-readable-specregs)) 437*16dce513Schristos (SI 7) (SI 14) (SI 15)) 438*16dce513Schristos) 439*16dce513Schristos 440*16dce513Schristos(define-pmacro (cris-implemented-writable-specregs-v32) 441*16dce513Schristos "Special writable registers in v32 and their sizes" 442*16dce513Schristos ((SI 2) (QI 3) 443*16dce513Schristos (SI 5) (SI 6) (SI 7) (SI 9) 444*16dce513Schristos (SI 10) (SI 11) (SI 12) (SI 13) (SI 14) (SI 15)) 445*16dce513Schristos) 446*16dce513Schristos(define-pmacro (cris-implemented-readable-specregs-v32) 447*16dce513Schristos "Special readable registers in v32 and their sizes" 448*16dce513Schristos (.splice (.unsplice (cris-implemented-writable-specregs-v32)) 449*16dce513Schristos (QI 0) (QI 1) (HI 4) (SI 8)) 450*16dce513Schristos) 451*16dce513Schristos 452*16dce513Schristos; For v32, all special register operations on constants (that is, 453*16dce513Schristos; move) take 32-bit operands, not the real size of the register, as in 454*16dce513Schristos; other move operations. 455*16dce513Schristos(define-pmacro (cris-implemented-specregs-const-v32) 456*16dce513Schristos (.map (.pmacro (x) (SI (.cadr2 x))) 457*16dce513Schristos (cris-implemented-writable-specregs-v32)) 458*16dce513Schristos) 459*16dce513Schristos 460*16dce513Schristos(define-pmacro cris-swap-codes 461*16dce513Schristos "CRIS Swap codes in numeric order (no zero)" 462*16dce513Schristos ( r b br w wr wb wbr 463*16dce513Schristos n nr nb nbr nw nwr nwb nwbr) 464*16dce513Schristos) 465*16dce513Schristos 466*16dce513Schristos(define-pmacro cris-flagnames 467*16dce513Schristos "CRIS flag field values, dest and src fields concatenated" 468*16dce513Schristos (c v z n x i u p) ; ... b m for pre-v32 469*16dce513Schristos) 470*16dce513Schristos 471*16dce513Schristos(define-pmacro-map 472*16dce513Schristos ; Bitnumber for each respective flag. 473*16dce513Schristos (.map (.pmacro (x num) ((.sym x -bitnumber) num)) 474*16dce513Schristos cris-flagnames (.iota 8)) 475*16dce513Schristos) 476*16dce513Schristos 477*16dce513Schristos; I give up. Here's a perl-script to get the values I want for this macro 478*16dce513Schristos; (not working along list principles, though). You can run this region. 479*16dce513Schristos; perl -e '$x = "cvznxiup"; for ($i = 0; $i < 256; $i++) { $s = ""; 480*16dce513Schristos; for ($j = 0; $j < 8; $j++) { if ($i & (1 << $j)) { 481*16dce513Schristos; $s .= substr ($x, $j, 1);}} 482*16dce513Schristos; printf ("%s%s", $s eq "" ? "_" : $s, (($i + 1) % 8) == 0 ? "\n " : " "); }' 483*16dce513Schristos(define-pmacro cris-flag-combinations 484*16dce513Schristos "Combinations of flags in numeric order" 485*16dce513Schristos (_ c v cv z cz vz cvz 486*16dce513Schristos n cn vn cvn zn czn vzn cvzn 487*16dce513Schristos x cx vx cvx zx czx vzx cvzx 488*16dce513Schristos nx cnx vnx cvnx znx cznx vznx cvznx 489*16dce513Schristos i ci vi cvi zi czi vzi cvzi 490*16dce513Schristos ni cni vni cvni zni czni vzni cvzni 491*16dce513Schristos xi cxi vxi cvxi zxi czxi vzxi cvzxi 492*16dce513Schristos nxi cnxi vnxi cvnxi znxi cznxi vznxi cvznxi 493*16dce513Schristos u cu vu cvu zu czu vzu cvzu 494*16dce513Schristos nu cnu vnu cvnu znu cznu vznu cvznu 495*16dce513Schristos xu cxu vxu cvxu zxu czxu vzxu cvzxu 496*16dce513Schristos nxu cnxu vnxu cvnxu znxu cznxu vznxu cvznxu 497*16dce513Schristos iu ciu viu cviu ziu cziu vziu cvziu 498*16dce513Schristos niu cniu vniu cvniu zniu czniu vzniu cvzniu 499*16dce513Schristos xiu cxiu vxiu cvxiu zxiu czxiu vzxiu cvzxiu 500*16dce513Schristos nxiu cnxiu vnxiu cvnxiu znxiu cznxiu vznxiu cvznxiu 501*16dce513Schristos p cp vp cvp zp czp vzp cvzp 502*16dce513Schristos np cnp vnp cvnp znp cznp vznp cvznp 503*16dce513Schristos xp cxp vxp cvxp zxp czxp vzxp cvzxp 504*16dce513Schristos nxp cnxp vnxp cvnxp znxp cznxp vznxp cvznxp 505*16dce513Schristos ip cip vip cvip zip czip vzip cvzip 506*16dce513Schristos nip cnip vnip cvnip znip cznip vznip cvznip 507*16dce513Schristos xip cxip vxip cvxip zxip czxip vzxip cvzxip 508*16dce513Schristos nxip cnxip vnxip cvnxip znxip cznxip vznxip cvznxip 509*16dce513Schristos up cup vup cvup zup czup vzup cvzup 510*16dce513Schristos nup cnup vnup cvnup znup cznup vznup cvznup 511*16dce513Schristos xup cxup vxup cvxup zxup czxup vzxup cvzxup 512*16dce513Schristos nxup cnxup vnxup cvnxup znxup cznxup vznxup cvznxup 513*16dce513Schristos iup ciup viup cviup ziup cziup vziup cvziup 514*16dce513Schristos niup cniup vniup cvniup zniup czniup vzniup cvzniup 515*16dce513Schristos xiup cxiup vxiup cvxiup zxiup czxiup vzxiup cvzxiup 516*16dce513Schristos nxiup cnxiup vnxiup cvnxiup znxiup cznxiup vznxiup cvznxiup 517*16dce513Schristos ) 518*16dce513Schristos) 519*16dce513Schristos 520*16dce513Schristos(define-pmacro cc-condition (not cbit)) 521*16dce513Schristos(define-pmacro cs-condition cbit) 522*16dce513Schristos(define-pmacro ne-condition (not zbit)) 523*16dce513Schristos(define-pmacro eq-condition zbit) 524*16dce513Schristos(define-pmacro vc-condition (not vbit)) 525*16dce513Schristos(define-pmacro vs-condition vbit) 526*16dce513Schristos(define-pmacro pl-condition (not nbit)) 527*16dce513Schristos(define-pmacro mi-condition nbit) 528*16dce513Schristos(define-pmacro ls-condition (or cbit zbit)) 529*16dce513Schristos(define-pmacro hi-condition (not (or cbit zbit))) 530*16dce513Schristos(define-pmacro ge-condition (not (xor vbit nbit))) 531*16dce513Schristos(define-pmacro lt-condition (xor vbit nbit)) 532*16dce513Schristos(define-pmacro gt-condition (not (or (xor vbit nbit) zbit))) 533*16dce513Schristos(define-pmacro le-condition (or (xor vbit nbit) zbit)) 534*16dce513Schristos(define-pmacro a-condition 1) 535*16dce513Schristos 536*16dce513Schristos; FIXME: define this properly for v10 and pre-v10. 537*16dce513Schristos(define-pmacro wf-condition pbit) 538*16dce513Schristos 539*16dce513Schristos(define-pmacro (cris-condition condno) 540*16dce513Schristos "Return condition state for condition number CONDNO" 541*16dce513Schristos (sequence 542*16dce513Schristos BI 543*16dce513Schristos ((SI tmpcond) (BI condres)) 544*16dce513Schristos (set tmpcond condno) 545*16dce513Schristos (.splice 546*16dce513Schristos cond 547*16dce513Schristos (.unsplice 548*16dce513Schristos (.map 549*16dce513Schristos (.pmacro 550*16dce513Schristos (condn condc) 551*16dce513Schristos ((eq tmpcond condn) (set condres (.sym condc -condition)))) 552*16dce513Schristos (.iota 16) 553*16dce513Schristos cris-condition-codes))) 554*16dce513Schristos condres) 555*16dce513Schristos) 556*16dce513Schristos 557*16dce513Schristos;;;;;;;;;;;;;;;;;; -keyword 558*16dce513Schristos 559*16dce513Schristos; General registers. 560*16dce513Schristos(define-pmacro (cris-general-gregs) 561*16dce513Schristos (.splice (SP 14) (.unsplice (.map (.pmacro (n) ((.sym R n) n)) (.iota 15)))) 562*16dce513Schristos) 563*16dce513Schristos 564*16dce513Schristos; Can't keep more than one gr-names definition at the same time; 565*16dce513Schristos; generated enum declarations in sim/cris/cris-desc.h will collide. 566*16dce513Schristos; FIXME: (include "different-mach-parts") 567*16dce513Schristos 568*16dce513Schristos(define-keyword 569*16dce513Schristos (name gr-names-pcreg) 570*16dce513Schristos (attrs MACH-PC) 571*16dce513Schristos (print-name h-gr-real-pc) 572*16dce513Schristos ; Put PC first so it is preferred over r15. 573*16dce513Schristos (.splice values (PC 15) (.unsplice (cris-general-gregs))) 574*16dce513Schristos) 575*16dce513Schristos 576*16dce513Schristos(define-keyword 577*16dce513Schristos (name gr-names-acr) 578*16dce513Schristos (attrs MACH-ACR) 579*16dce513Schristos ; The print-name directive will control the enum prefix. With the 580*16dce513Schristos ; arguably more appropriate h-gr-v32 or h-gr-acr, we'd get names like 581*16dce513Schristos ; H_GR_ACR_R0 instead of H_GR_R0. Since we have to choose something for 582*16dce513Schristos ; unprefixed names, we use the CRISv32 names. FIXME: All users should 583*16dce513Schristos ; change to use H_GR_V32_R0 (etc.), then change this to h-gr-v32. 584*16dce513Schristos (print-name h-gr) 585*16dce513Schristos ; Put ACR first so it is preferred over r15. 586*16dce513Schristos (.splice values (ACR 15) (.unsplice (cris-general-gregs))) 587*16dce513Schristos) 588*16dce513Schristos 589*16dce513Schristos(define-keyword 590*16dce513Schristos (name gr-names-v32) 591*16dce513Schristos (attrs MACH-V32) 592*16dce513Schristos ; In preparation for implementing the FIXME above. 593*16dce513Schristos (print-name h-gr-v32) 594*16dce513Schristos ; Put ACR first so it is preferred over r15. 595*16dce513Schristos (.splice values (ACR 15) (.unsplice (cris-general-gregs))) 596*16dce513Schristos) 597*16dce513Schristos 598*16dce513Schristos; Special registers with names common to all. 599*16dce513Schristos(define-pmacro (cris-general-pregs) 600*16dce513Schristos (.splice 601*16dce513Schristos (VR 1) 602*16dce513Schristos (SRP 11) 603*16dce513Schristos (.unsplice (.map (.pmacro (n) ((.sym P n) n)) (.iota 15)))) 604*16dce513Schristos) 605*16dce513Schristos 606*16dce513Schristos(define-keyword 607*16dce513Schristos (name p-names-v10) 608*16dce513Schristos (attrs MACH-PRE-V32) 609*16dce513Schristos (print-name h-sr-pre-v32) 610*16dce513Schristos (.splice 611*16dce513Schristos values 612*16dce513Schristos (CCR 5) 613*16dce513Schristos (MOF 7) 614*16dce513Schristos (IBR 9) 615*16dce513Schristos (IRP 10) 616*16dce513Schristos (BAR 12) 617*16dce513Schristos (DCCR 13) 618*16dce513Schristos (BRP 14) 619*16dce513Schristos (USP 15) 620*16dce513Schristos (.unsplice (cris-general-pregs))) 621*16dce513Schristos) 622*16dce513Schristos 623*16dce513Schristos(define-keyword 624*16dce513Schristos (name p-names-v32) 625*16dce513Schristos (attrs MACH-V32) 626*16dce513Schristos ; See comment for gr-names-acr. 627*16dce513Schristos (print-name h-sr) 628*16dce513Schristos (.splice 629*16dce513Schristos values 630*16dce513Schristos (BZ 0) 631*16dce513Schristos (PID 2) 632*16dce513Schristos (SRS 3) 633*16dce513Schristos (WZ 4) 634*16dce513Schristos (EXS 5) 635*16dce513Schristos (EDA 6) 636*16dce513Schristos (MOF 7) 637*16dce513Schristos (DZ 8) 638*16dce513Schristos (EBP 9) 639*16dce513Schristos (ERP 10) 640*16dce513Schristos (NRP 12) 641*16dce513Schristos (CCS 13) 642*16dce513Schristos (USP 14) 643*16dce513Schristos (SPC 15) 644*16dce513Schristos (.unsplice (cris-general-pregs))) 645*16dce513Schristos) 646*16dce513Schristos 647*16dce513Schristos; Similarly as for h-gr-v32, in preparation. 648*16dce513Schristos(define-keyword 649*16dce513Schristos (name p-names-v32-x) 650*16dce513Schristos (attrs MACH-V32) 651*16dce513Schristos ; See comment for gr-names-acr. 652*16dce513Schristos (print-name h-sr-v32) 653*16dce513Schristos (.splice 654*16dce513Schristos values 655*16dce513Schristos (BZ 0) 656*16dce513Schristos (PID 2) 657*16dce513Schristos (SRS 3) 658*16dce513Schristos (WZ 4) 659*16dce513Schristos (EXS 5) 660*16dce513Schristos (EDA 6) 661*16dce513Schristos (MOF 7) 662*16dce513Schristos (DZ 8) 663*16dce513Schristos (EBP 9) 664*16dce513Schristos (ERP 10) 665*16dce513Schristos (NRP 12) 666*16dce513Schristos (CCS 13) 667*16dce513Schristos (USP 14) 668*16dce513Schristos (SPC 15) 669*16dce513Schristos (.unsplice (cris-general-pregs))) 670*16dce513Schristos) 671*16dce513Schristos 672*16dce513Schristos(define-pmacro p0 (reg h-sr 0)) 673*16dce513Schristos(define-pmacro vr (reg h-sr 1)) 674*16dce513Schristos(define-pmacro pid (reg h-sr 2)) 675*16dce513Schristos(define-pmacro srs (reg h-sr 3)) 676*16dce513Schristos(define-pmacro p4 (reg h-sr 4)) 677*16dce513Schristos(define-pmacro ccr (reg h-sr 5)) 678*16dce513Schristos(define-pmacro mof (reg h-sr 7)) 679*16dce513Schristos(define-pmacro p8 (reg h-sr 8)) 680*16dce513Schristos(define-pmacro ibr (reg h-sr 9)) 681*16dce513Schristos(define-pmacro ebp (reg h-sr 9)) 682*16dce513Schristos(define-pmacro erp (reg h-sr 10)) 683*16dce513Schristos(define-pmacro srp (reg h-sr 11)) 684*16dce513Schristos(define-pmacro ccs (reg h-sr 13)) 685*16dce513Schristos(define-pmacro dccr (reg h-sr 13)) 686*16dce513Schristos(define-pmacro usp (reg h-sr 14)) 687*16dce513Schristos(define-pmacro spc (reg h-sr 15)) 688*16dce513Schristos 689*16dce513Schristos(define-pmacro sp (reg h-gr 14)) 690*16dce513Schristos(define-pmacro acr (reg h-gr 15)) 691*16dce513Schristos 692*16dce513Schristos(define-pmacro cris-condition-codes 693*16dce513Schristos "CRIS condition codes in numeric order" 694*16dce513Schristos (cc cs ne eq vc vs pl mi ls hi ge lt gt le a wf) 695*16dce513Schristos) 696*16dce513Schristos 697*16dce513Schristos; No use having different lists; this is the only CC that 698*16dce513Schristos; differs between v10 and v32, and mostly in the name. 699*16dce513Schristos(define-pmacro sb wf) 700*16dce513Schristos 701*16dce513Schristos 702*16dce513Schristos;;;;;;;;;;;;;;;;;; -hardware 703*16dce513Schristos 704*16dce513Schristos;; Various constant generators. 705*16dce513Schristos 706*16dce513Schristos(define-hardware 707*16dce513Schristos (name h-inc) 708*16dce513Schristos (comment "autoincrement-bit syntax specifier") 709*16dce513Schristos (type immediate (UINT 1)) 710*16dce513Schristos (values keyword "" (("" 0) ("+" 1))) 711*16dce513Schristos) 712*16dce513Schristos 713*16dce513Schristos(define-hardware 714*16dce513Schristos (name h-ccode) 715*16dce513Schristos (comment "Condition code specifier") 716*16dce513Schristos (type immediate (UINT 4)) 717*16dce513Schristos (values keyword "" 718*16dce513Schristos (.map (.pmacro (x y) ((.str x) y)) 719*16dce513Schristos cris-condition-codes (.iota 16))) 720*16dce513Schristos) 721*16dce513Schristos 722*16dce513Schristos(define-hardware 723*16dce513Schristos (name h-swap) 724*16dce513Schristos (comment "Swap option specifier") 725*16dce513Schristos (type immediate (UINT 4)) 726*16dce513Schristos (values 727*16dce513Schristos keyword "" 728*16dce513Schristos (.splice 729*16dce513Schristos (" " 0) 730*16dce513Schristos (.unsplice 731*16dce513Schristos (.map 732*16dce513Schristos (.pmacro (x y) ((.str x) y)) cris-swap-codes (.iota 15 1))))) 733*16dce513Schristos) 734*16dce513Schristos 735*16dce513Schristos(define-hardware 736*16dce513Schristos (name h-flagbits) 737*16dce513Schristos (comment "Flag bits specifier") 738*16dce513Schristos (type immediate (UINT 8)) 739*16dce513Schristos (values 740*16dce513Schristos keyword "" 741*16dce513Schristos (.map (.pmacro (x y) ((.str x) y)) cris-flag-combinations (.iota 256))) 742*16dce513Schristos) 743*16dce513Schristos 744*16dce513Schristos; Apparently, the semantic-name isn't used for accessors, so external 745*16dce513Schristos; users like the sim glue and SID sees the -v32 and -pre-v32 munged names. 746*16dce513Schristos; Defining "dispatchers"; virtual registers whose getter and setter works 747*16dce513Schristos; on the "real" mach variants, seems to help. CGEN-FIXME: Make 748*16dce513Schristos; semantic-name set the generated names. 749*16dce513Schristos(define-pmacro (cris-d-hwreg x-name x-type) 750*16dce513Schristos (define-hardware 751*16dce513Schristos (name x-name) 752*16dce513Schristos (comment (.str "Dispatcher for " x-name)) 753*16dce513Schristos (attrs VIRTUAL) 754*16dce513Schristos (type register x-type) 755*16dce513Schristos (get () (reg (.sym x-name -x))) 756*16dce513Schristos (set (val) (set (reg (.sym x-name -x)) val))) 757*16dce513Schristos) 758*16dce513Schristos(define-pmacro (cris-d-hwregf-a x-name x-type x-n x-attrs) 759*16dce513Schristos (define-hardware 760*16dce513Schristos (name x-name) 761*16dce513Schristos (comment (.str "Dispatcher for " x-name)) 762*16dce513Schristos (.splice attrs VIRTUAL (.unsplice x-attrs)) 763*16dce513Schristos (type register x-type (x-n)) 764*16dce513Schristos (get (index) (reg (.sym x-name -x) index)) 765*16dce513Schristos (set (index val) (set-quiet (reg (.sym x-name -x) index) val))) 766*16dce513Schristos) 767*16dce513Schristos(define-pmacro (cris-d-hwregf x-name x-type x-n) 768*16dce513Schristos (cris-d-hwregf-a x-name x-type x-n ()) 769*16dce513Schristos) 770*16dce513Schristos(define-pmacro (cris-d-hwregf-p x-name x-type x-n) 771*16dce513Schristos (cris-d-hwregf-a x-name x-type x-n (PROFILE)) 772*16dce513Schristos) 773*16dce513Schristos 774*16dce513Schristos; At first glance we could use (eq-attr (current-mach) ...) for 775*16dce513Schristos; everything, but that seems sometimes (always?) to yield false. For 776*16dce513Schristos; ifields, it causes noncompilable C-code. For the insn semantics code, 777*16dce513Schristos; it causes tests movei.ms and mulv32.ms to fail, apparently because the 778*16dce513Schristos; current-mach-is-v32 usage in flags setting is miscompiled as 0 (or 779*16dce513Schristos; rather, misgenerated). Instead we use different definitions of a 780*16dce513Schristos; MACH-tagged virtual register yielding a constant, together with a 781*16dce513Schristos; pmacro. CGEN-FIXME: If eq-attr is someday fixed, we could just remove 782*16dce513Schristos; these h-v32 virtual register definitions and change the pmacro 783*16dce513Schristos; definition for current-mach-is-v32. 784*16dce513Schristos(define-hardware 785*16dce513Schristos (semantic-name h-v32) 786*16dce513Schristos (name h-v32-v32) 787*16dce513Schristos (attrs MACH-V32 VIRTUAL) 788*16dce513Schristos (type register BI) 789*16dce513Schristos (get () (const BI 1)) 790*16dce513Schristos (set (val) (error "Can't set h-v32")) 791*16dce513Schristos) 792*16dce513Schristos(define-hardware 793*16dce513Schristos (semantic-name h-v32) 794*16dce513Schristos (name h-v32-non-v32) 795*16dce513Schristos (attrs MACH-PRE-V32 VIRTUAL) 796*16dce513Schristos (type register BI) 797*16dce513Schristos (get () (const BI 0)) 798*16dce513Schristos (set (val) (error "Can't set h-v32")) 799*16dce513Schristos) 800*16dce513Schristos 801*16dce513Schristos;; "Real" hardware. 802*16dce513Schristos 803*16dce513Schristos(define-hardware 804*16dce513Schristos (name h-pc) 805*16dce513Schristos (comment "program counter") 806*16dce513Schristos (attrs PC PROFILE) 807*16dce513Schristos (type pc) 808*16dce513Schristos ; There's no bit 0 in PC, so just ignore it when jumping etc. 809*16dce513Schristos (set (val) (set (raw-reg h-pc) (and val (inv 1)))) 810*16dce513Schristos) 811*16dce513Schristos 812*16dce513Schristos; Note that setting register 15 isn't handled here, but in each insn, so 813*16dce513Schristos; the proper "jump" attributes and other special stuff for speedy 814*16dce513Schristos; execution can be present. 815*16dce513Schristos(cris-d-hwregf-p h-gr SI 16) 816*16dce513Schristos(define-hardware 817*16dce513Schristos (semantic-name h-gr-x) 818*16dce513Schristos (name h-gr-pc) 819*16dce513Schristos (attrs MACH-PC VIRTUAL) 820*16dce513Schristos (comment "General purpose registers, aborting on PC access") 821*16dce513Schristos (type register SI (16)) 822*16dce513Schristos (indices extern-keyword gr-names-pcreg) 823*16dce513Schristos (get 824*16dce513Schristos (index) 825*16dce513Schristos (if SI (eq index 15) 826*16dce513Schristos (error SI "General register read of PC is not implemented.") 827*16dce513Schristos (reg SI h-gr-real-pc index))) 828*16dce513Schristos (set 829*16dce513Schristos (index val) 830*16dce513Schristos (sequence 831*16dce513Schristos () 832*16dce513Schristos (if (eq index 15) 833*16dce513Schristos (error "General register write to PC is not implemented.")) 834*16dce513Schristos (set (reg SI h-gr-real-pc index) val))) 835*16dce513Schristos) 836*16dce513Schristos(define-hardware 837*16dce513Schristos (name h-gr-real-pc) 838*16dce513Schristos (attrs MACH-PC) 839*16dce513Schristos (comment "General purpose registers") 840*16dce513Schristos (type register SI (16)) 841*16dce513Schristos (indices extern-keyword gr-names-pcreg) 842*16dce513Schristos) 843*16dce513Schristos 844*16dce513Schristos; We have to use a virtual register trick to get the "raw", unaccounted 845*16dce513Schristos; contents of the global register; the raw-reg RTX only works for 846*16dce513Schristos; non-virtual register files. 847*16dce513Schristos(define-hardware 848*16dce513Schristos (semantic-name h-raw-gr) 849*16dce513Schristos (name h-raw-gr-pc) 850*16dce513Schristos (attrs MACH-PC VIRTUAL) 851*16dce513Schristos (comment "Unaccounted version of general purpose registers") 852*16dce513Schristos (type register SI (16)) 853*16dce513Schristos (get (index) (raw-reg h-gr-real-pc index)) 854*16dce513Schristos (set (index val) (set-quiet (raw-reg h-gr-real-pc index) val)) 855*16dce513Schristos) 856*16dce513Schristos(define-hardware 857*16dce513Schristos (semantic-name h-gr-x) 858*16dce513Schristos (name h-gr-acr) 859*16dce513Schristos (attrs MACH-ACR) 860*16dce513Schristos (comment "General purpose registers") 861*16dce513Schristos (type register SI (16)) 862*16dce513Schristos (indices extern-keyword gr-names-acr) 863*16dce513Schristos) 864*16dce513Schristos(define-hardware 865*16dce513Schristos (semantic-name h-raw-gr) 866*16dce513Schristos (name h-raw-gr-acr) 867*16dce513Schristos (attrs MACH-ACR VIRTUAL) 868*16dce513Schristos (comment "Unaccounted version of general purpose registers") 869*16dce513Schristos (type register SI (16)) 870*16dce513Schristos (get (index) (raw-reg h-gr-x index)) 871*16dce513Schristos (set (index val) (set-quiet (raw-reg h-gr-x index) val)) 872*16dce513Schristos) 873*16dce513Schristos 874*16dce513Schristos; FIXME: get and set semantics? Unknown how to split semantics best; with 875*16dce513Schristos; get/set semantics or within the insn specification. Doing the former for 876*16dce513Schristos; now. Should use different names for pre-v10. 877*16dce513Schristos; FIXME: No dccr for v0 and v3. Different high flag bits. 878*16dce513Schristos(cris-d-hwregf-p h-sr SI 16) 879*16dce513Schristos(define-pmacro 880*16dce513Schristos (cris-h-sr machver) 881*16dce513Schristos (define-hardware 882*16dce513Schristos (semantic-name h-sr-x) 883*16dce513Schristos (name (.sym h-sr-v machver)) 884*16dce513Schristos (attrs (MACH (.sym crisv machver))) 885*16dce513Schristos (comment (.str "Special registers for v" machver)) 886*16dce513Schristos (type register SI (16)) 887*16dce513Schristos (indices extern-keyword p-names-v10) 888*16dce513Schristos (get 889*16dce513Schristos (index) 890*16dce513Schristos (cond 891*16dce513Schristos SI 892*16dce513Schristos ((orif (orif (eq index (regno p0)) (eq index (regno p4))) 893*16dce513Schristos (eq index (regno p8))) 0) 894*16dce513Schristos ((eq index (regno vr)) machver) 895*16dce513Schristos ((orif (eq index (regno ccr)) 896*16dce513Schristos (eq index (regno dccr))) 897*16dce513Schristos ; Return "P U I X N Z V C" for the low 8 bits. 898*16dce513Schristos ; FIXME: More bits. 899*16dce513Schristos (or SI 900*16dce513Schristos (and SI (raw-reg SI h-sr-x (regno ccr)) #xffffff00) 901*16dce513Schristos (or 902*16dce513Schristos (zext SI (reg BI h-cbit)) 903*16dce513Schristos (or 904*16dce513Schristos (sll (zext SI (reg BI h-vbit)) 1) 905*16dce513Schristos (or 906*16dce513Schristos (sll (zext SI (reg BI h-zbit)) 2) 907*16dce513Schristos (or 908*16dce513Schristos (sll (zext SI (reg BI h-nbit)) 3) 909*16dce513Schristos (or 910*16dce513Schristos (sll (zext SI (reg BI h-xbit)) 4) 911*16dce513Schristos (or 912*16dce513Schristos (sll (zext SI (reg BI h-ibit)) 5) 913*16dce513Schristos (or 914*16dce513Schristos (sll (zext SI (reg BI h-ubit)) 6) 915*16dce513Schristos (or 916*16dce513Schristos (sll (zext SI (reg BI h-pbit)) 7) 917*16dce513Schristos 0)))))))))) 918*16dce513Schristos (else (raw-reg SI h-sr-x index)))) 919*16dce513Schristos (set 920*16dce513Schristos (index val) 921*16dce513Schristos (cond 922*16dce513Schristos ((orif (orif (eq index (regno p0)) (eq index (regno p4))) 923*16dce513Schristos (orif (eq index (regno p8)) (eq index (regno vr)))) 924*16dce513Schristos (nop)) 925*16dce513Schristos ((orif (eq index (regno ccr)) (eq index (regno dccr))) 926*16dce513Schristos (sequence 927*16dce513Schristos () 928*16dce513Schristos (set (reg BI h-cbit) (if BI (ne SI (and val (sll 1 0)) 0) 1 0)) 929*16dce513Schristos (set (reg BI h-vbit) (if BI (ne SI (and val (sll 1 1)) 0) 1 0)) 930*16dce513Schristos (set (reg BI h-zbit) (if BI (ne SI (and val (sll 1 2)) 0) 1 0)) 931*16dce513Schristos (set (reg BI h-nbit) (if BI (ne SI (and val (sll 1 3)) 0) 1 0)) 932*16dce513Schristos (set (reg BI h-xbit) (if BI (ne SI (and val (sll 1 4)) 0) 1 0)) 933*16dce513Schristos (set (reg BI h-ibit) (if BI (ne SI (and val (sll 1 5)) 0) 1 0)) 934*16dce513Schristos (set (reg BI h-ubit) (if BI (ne SI (and val (sll 1 6)) 0) 1 0)) 935*16dce513Schristos (set (reg BI h-pbit) (if BI (ne SI (and val (sll 1 7)) 0) 1 0)) 936*16dce513Schristos (set-quiet (raw-reg SI h-sr-x (regno ccr)) val) 937*16dce513Schristos (set-quiet (raw-reg SI h-sr-x (regno dccr)) val))) 938*16dce513Schristos (else (set-quiet (raw-reg SI h-sr-x index) val))))) 939*16dce513Schristos) 940*16dce513Schristos 941*16dce513Schristos(cris-h-sr 0) 942*16dce513Schristos(cris-h-sr 3) 943*16dce513Schristos(cris-h-sr 8) 944*16dce513Schristos(cris-h-sr 10) 945*16dce513Schristos 946*16dce513Schristos(define-hardware 947*16dce513Schristos (semantic-name h-sr-x) 948*16dce513Schristos (name h-sr-v32) 949*16dce513Schristos (attrs MACH-V32) 950*16dce513Schristos (comment "Special registers for v32") 951*16dce513Schristos (type register SI (16)) 952*16dce513Schristos (indices extern-keyword p-names-v32) 953*16dce513Schristos 954*16dce513Schristos (get 955*16dce513Schristos (index) 956*16dce513Schristos (cond 957*16dce513Schristos SI 958*16dce513Schristos ((orif (orif (eq index (regno p0)) (eq index (regno p4))) 959*16dce513Schristos (eq index (regno p8))) 0) 960*16dce513Schristos ((eq index (regno vr)) 32) 961*16dce513Schristos ((eq index (regno ccs)) 962*16dce513Schristos ; Return "S R P U I X N Z V C" for the low 10 bits. 963*16dce513Schristos (or SI 964*16dce513Schristos (and SI (raw-reg SI h-sr-x (regno ccs)) #x3ffffc00) 965*16dce513Schristos (or 966*16dce513Schristos (zext SI (reg BI h-cbit)) 967*16dce513Schristos (or 968*16dce513Schristos (sll (zext SI (reg BI h-vbit)) 1) 969*16dce513Schristos (or 970*16dce513Schristos (sll (zext SI (reg BI h-zbit)) 2) 971*16dce513Schristos (or 972*16dce513Schristos (sll (zext SI (reg BI h-nbit)) 3) 973*16dce513Schristos (or 974*16dce513Schristos (sll (zext SI (reg BI h-xbit)) 4) 975*16dce513Schristos (or 976*16dce513Schristos (sll (zext SI (reg BI h-ibit)) 5) 977*16dce513Schristos (or 978*16dce513Schristos (sll (zext SI (reg BI h-ubit)) 6) 979*16dce513Schristos (or 980*16dce513Schristos (sll (zext SI (reg BI h-pbit)) 7) 981*16dce513Schristos (or 982*16dce513Schristos (sll (zext SI (reg BI h-rbit)) 8) 983*16dce513Schristos (or 984*16dce513Schristos (sll (zext SI (reg BI h-sbit)) 9) 985*16dce513Schristos (or 986*16dce513Schristos (sll (zext SI (reg BI h-mbit)) 30) 987*16dce513Schristos (or 988*16dce513Schristos (sll (zext SI (reg BI h-qbit)) 31) 989*16dce513Schristos 0)))))))))))))) 990*16dce513Schristos ((eq index (regno usp)) 991*16dce513Schristos ; In user mode, return general stack pointer. 992*16dce513Schristos (if BI (reg BI h-ubit) 993*16dce513Schristos (raw-reg SI h-gr-x (regno sp)) 994*16dce513Schristos (raw-reg SI h-sr-x (regno usp)))) 995*16dce513Schristos (else (raw-reg SI h-sr-x index)))) 996*16dce513Schristos 997*16dce513Schristos (set 998*16dce513Schristos (index val) 999*16dce513Schristos (cond 1000*16dce513Schristos ((orif (orif (eq index (regno p0)) (eq index (regno p4))) 1001*16dce513Schristos (orif (eq index (regno p8)) (eq index (regno vr)))) 1002*16dce513Schristos (nop)) 1003*16dce513Schristos ((eq index (regno ccs)) 1004*16dce513Schristos (sequence 1005*16dce513Schristos () 1006*16dce513Schristos ; Protected bits are handled as such in the respective setter function. 1007*16dce513Schristos (set (reg BI h-cbit) (if BI (ne SI (and val (sll 1 0)) 0) 1 0)) 1008*16dce513Schristos (set (reg BI h-vbit) (if BI (ne SI (and val (sll 1 1)) 0) 1 0)) 1009*16dce513Schristos (set (reg BI h-zbit) (if BI (ne SI (and val (sll 1 2)) 0) 1 0)) 1010*16dce513Schristos (set (reg BI h-nbit) (if BI (ne SI (and val (sll 1 3)) 0) 1 0)) 1011*16dce513Schristos (set (reg BI h-xbit) (if BI (ne SI (and val (sll 1 4)) 0) 1 0)) 1012*16dce513Schristos (set (reg BI h-ibit) (if BI (ne SI (and val (sll 1 5)) 0) 1 0)) 1013*16dce513Schristos (set (reg BI h-sbit) (if BI (ne SI (and val (sll 1 9)) 0) 1 0)) 1014*16dce513Schristos (set (reg BI h-mbit) (if BI (ne SI (and val (sll 1 30)) 0) 1 0)) 1015*16dce513Schristos (set (reg BI h-pbit) (if BI (ne SI (and val (sll 1 7)) 0) 1 0)) 1016*16dce513Schristos (set (reg BI h-rbit) (if BI (ne SI (and val (sll 1 8)) 0) 1 0)) 1017*16dce513Schristos (set (reg BI h-qbit) (if BI (ne SI (and val (sll 1 31)) 0) 1 0)) 1018*16dce513Schristos ; Set the U bit last, so the setter functions for the other bits 1019*16dce513Schristos ; don't see it as set from this operation. It is not cleared from 1020*16dce513Schristos ; this operation, so we don't have to handle that; it's only 1021*16dce513Schristos ; cleared "manually" from within simulator-specific context-switch 1022*16dce513Schristos ; machinery. 1023*16dce513Schristos (set (reg BI h-ubit) (if BI (ne SI (and val (sll 1 6)) 0) 1 0)) 1024*16dce513Schristos (set-quiet (raw-reg SI h-sr-x index) val))) 1025*16dce513Schristos ((eq index (regno usp)) 1026*16dce513Schristos ; In user mode, set general register 14 too, whenever setting USP. 1027*16dce513Schristos (sequence 1028*16dce513Schristos () 1029*16dce513Schristos (if (reg BI h-ubit) (set (raw-reg SI h-gr-x (regno sp)) val)) 1030*16dce513Schristos (set (raw-reg SI h-sr-x (regno usp)) val))) 1031*16dce513Schristos ((eq index (regno srs)) 1032*16dce513Schristos (if (not (reg BI h-ubit)) (set (raw-reg h-sr-x (regno srs)) val))) 1033*16dce513Schristos ((eq index (regno ebp)) 1034*16dce513Schristos (if (not (reg BI h-ubit)) (set (raw-reg h-sr-x (regno ebp)) val))) 1035*16dce513Schristos ((eq index (regno pid)) 1036*16dce513Schristos (if (not (reg BI h-ubit)) 1037*16dce513Schristos (sequence 1038*16dce513Schristos () 1039*16dce513Schristos (c-call VOID "@cpu@_write_pid_handler" val) 1040*16dce513Schristos (set (raw-reg h-sr-x (regno pid)) val)))) 1041*16dce513Schristos ((eq index (regno spc)) 1042*16dce513Schristos (if (not (reg BI h-ubit)) (set (raw-reg h-sr-x (regno spc)) val))) 1043*16dce513Schristos (else (set-quiet (raw-reg SI h-sr-x index) val)))) 1044*16dce513Schristos) 1045*16dce513Schristos 1046*16dce513Schristos(define-hardware 1047*16dce513Schristos (name h-supr) 1048*16dce513Schristos (attrs MACH-V32 VIRTUAL) 1049*16dce513Schristos (comment "Support registers") 1050*16dce513Schristos (type register SI (16)) 1051*16dce513Schristos (values keyword "" (.map (.pmacro (y) ((.str S y) y)) (.iota 16))) 1052*16dce513Schristos (get (index) (c-call SI "@cpu@_read_supr" index)) 1053*16dce513Schristos (set (index val) (c-call VOID "@cpu@_write_supr" index val)) 1054*16dce513Schristos) 1055*16dce513Schristos 1056*16dce513Schristos(define-pmacro (cris-dsh semantic-name name comment attrs type) 1057*16dce513Schristos "Like dsh, but the semantic-name is separate" 1058*16dce513Schristos (define-full-hardware 1059*16dce513Schristos name comment attrs semantic-name type () () () () () ()) 1060*16dce513Schristos) 1061*16dce513Schristos 1062*16dce513Schristos; We define the condition codes that hold arithmetic flags separately 1063*16dce513Schristos; and "or" them in, in the get and set methods of the special 1064*16dce513Schristos; registers. We define arithmetic flags as any of C V Z N X. They 1065*16dce513Schristos; thankfully have that order (zero-based) in all processor versions. 1066*16dce513Schristos 1067*16dce513Schristos; To avoid having two variants of most move-type instructions because V32 1068*16dce513Schristos; doesn't set C and V (and N and Z), we fake the setting to virtual 1069*16dce513Schristos; registers which have two different implementations. 1070*16dce513Schristos(define-pmacro (cris-move-flag f f-name f-whence) 1071*16dce513Schristos "Flag set differently in pre-v32 and v32 in some cases" 1072*16dce513Schristos (begin 1073*16dce513Schristos (dsh (.sym h- f bit) (.str f-name " bit") () (register BI)) 1074*16dce513Schristos (cris-d-hwreg (.sym h- f bit-move) BI) 1075*16dce513Schristos (define-hardware 1076*16dce513Schristos (semantic-name (.sym h- f bit-move-x)) 1077*16dce513Schristos (name (.sym h- f bit-move-v32)) 1078*16dce513Schristos (comment (.str f-name " bit set in " f-whence " instructions, ignored")) 1079*16dce513Schristos (attrs MACH-V32 VIRTUAL) 1080*16dce513Schristos (type register BI) 1081*16dce513Schristos (get 1082*16dce513Schristos () 1083*16dce513Schristos (sequence BI () 1084*16dce513Schristos (error (.str "Can't get h-" f "bit-move on CRISv32")) 0)) 1085*16dce513Schristos (set (val) (nop))) 1086*16dce513Schristos (define-hardware 1087*16dce513Schristos (semantic-name (.sym h- f bit-move-x)) 1088*16dce513Schristos (name (.sym h- f bit-move-pre-v32)) 1089*16dce513Schristos (comment 1090*16dce513Schristos (.str 1091*16dce513Schristos f-name " bit set in " f-whence " instructions, same as " f "bit")) 1092*16dce513Schristos (attrs MACH-PRE-V32 VIRTUAL) 1093*16dce513Schristos (type register BI) 1094*16dce513Schristos (get () (reg (.sym h- f bit))) 1095*16dce513Schristos (set (val) (set (reg (.sym h- f bit)) val)))) 1096*16dce513Schristos) 1097*16dce513Schristos 1098*16dce513Schristos(cris-move-flag c "carry" "move-type") 1099*16dce513Schristos(cris-move-flag v "overflow" "move-type") 1100*16dce513Schristos(cris-move-flag z "zero" "moveq") 1101*16dce513Schristos(cris-move-flag n "sign" "moveq") 1102*16dce513Schristos 1103*16dce513Schristos(dsh h-xbit "extended-arithmetic bit" () (register BI)) 1104*16dce513Schristos(cris-d-hwreg h-ibit BI) 1105*16dce513Schristos(cris-dsh h-ibit-x h-ibit-pre-v32 1106*16dce513Schristos "interrupt-enable bit" (MACH-PRE-V32) (register BI)) 1107*16dce513Schristos(dsh h-pbit "sequence-broken bit" ((MACH crisv10,crisv32)) (register BI)) 1108*16dce513Schristos(dsh h-rbit "carry bit for MCP+restore-p bit" (MACH-V32) (register BI)) 1109*16dce513Schristos(cris-d-hwreg h-ubit BI) 1110*16dce513Schristos(cris-dsh h-ubit-x h-ubit-pre-v32 1111*16dce513Schristos "user mode bit" ((MACH crisv10)) (register BI)) 1112*16dce513Schristos(dsh h-gbit "guru mode bit" (MACH-V32) (register BI)) 1113*16dce513Schristos 1114*16dce513Schristos; When doing a transition from kernel to user mode on V32, we save the 1115*16dce513Schristos; stack pointer in an internal register and copy USP to R14, so we don't 1116*16dce513Schristos; need non-trivial handlers for general registers. 1117*16dce513Schristos(dsh 1118*16dce513Schristos h-kernel-sp 1119*16dce513Schristos "Kernel stack pointer during user mode" 1120*16dce513Schristos (MACH-V32) 1121*16dce513Schristos (register SI) 1122*16dce513Schristos) 1123*16dce513Schristos 1124*16dce513Schristos(define-hardware 1125*16dce513Schristos (semantic-name h-ubit-x) 1126*16dce513Schristos (name h-ubit-v32) 1127*16dce513Schristos (comment "User mode bit") 1128*16dce513Schristos (attrs MACH-V32) 1129*16dce513Schristos (type register BI) 1130*16dce513Schristos (set 1131*16dce513Schristos (val) 1132*16dce513Schristos (sequence 1133*16dce513Schristos () 1134*16dce513Schristos (if (andif val (not (raw-reg BI h-ubit-x))) 1135*16dce513Schristos (sequence 1136*16dce513Schristos () 1137*16dce513Schristos (set (reg SI h-kernel-sp) (raw-reg h-gr-x (regno sp))) 1138*16dce513Schristos (set (raw-reg h-gr-x (regno sp)) (raw-reg h-sr-x (regno usp))) 1139*16dce513Schristos (set (raw-reg BI h-ubit-x) val) 1140*16dce513Schristos (c-call VOID "@cpu@_usermode_enabled"))))) 1141*16dce513Schristos) 1142*16dce513Schristos 1143*16dce513Schristos(define-hardware 1144*16dce513Schristos (semantic-name h-ibit-x) 1145*16dce513Schristos (name h-ibit-v32) 1146*16dce513Schristos (comment "Interrupt-enable bit") 1147*16dce513Schristos (attrs MACH-V32) 1148*16dce513Schristos (type register BI) 1149*16dce513Schristos (set 1150*16dce513Schristos (val) 1151*16dce513Schristos (sequence 1152*16dce513Schristos () 1153*16dce513Schristos (if (not (reg BI h-ubit)) 1154*16dce513Schristos (sequence 1155*16dce513Schristos ((BI enabled)) 1156*16dce513Schristos (set enabled (andif val (not (raw-reg BI h-ibit-x)))) 1157*16dce513Schristos (set (raw-reg BI h-ibit-x) val) 1158*16dce513Schristos ; Call handler when enabling. 1159*16dce513Schristos (if enabled (c-call VOID "@cpu@_interrupts_enabled")))))) 1160*16dce513Schristos) 1161*16dce513Schristos 1162*16dce513Schristos(define-hardware 1163*16dce513Schristos (name h-mbit) 1164*16dce513Schristos (comment "NMI enable bit") 1165*16dce513Schristos (attrs MACH-V32) 1166*16dce513Schristos (type register BI) 1167*16dce513Schristos (set 1168*16dce513Schristos (val) 1169*16dce513Schristos (sequence 1170*16dce513Schristos () 1171*16dce513Schristos ; Don't allow clearing (through this handler) when once set. 1172*16dce513Schristos (if (andif val (andif (not (raw-reg BI h-mbit)) (not (reg BI h-ubit)))) 1173*16dce513Schristos (sequence 1174*16dce513Schristos () 1175*16dce513Schristos (set (raw-reg BI h-mbit) 1) 1176*16dce513Schristos ; Call handler when enabling. 1177*16dce513Schristos (c-call VOID "@cpu@_nmi_enabled"))))) 1178*16dce513Schristos) 1179*16dce513Schristos 1180*16dce513Schristos(define-pmacro 1181*16dce513Schristos (dsh-cond-bit-v32 x-name x-comment x-cond) 1182*16dce513Schristos "dsh bit for MACH-V32, with bit only changeable when X-COND" 1183*16dce513Schristos (define-hardware 1184*16dce513Schristos (name x-name) 1185*16dce513Schristos (comment x-comment) 1186*16dce513Schristos (attrs MACH-V32) 1187*16dce513Schristos (type register BI) 1188*16dce513Schristos (set (val) (sequence () (if x-cond (set (raw-reg BI x-name) val))))) 1189*16dce513Schristos) 1190*16dce513Schristos(define-pmacro 1191*16dce513Schristos (dsh-protected-bit-v32 x-name x-comment) 1192*16dce513Schristos "dsh bit for MACH-V32, with bit only changeable in kernel mode" 1193*16dce513Schristos (dsh-cond-bit-v32 x-name x-comment (not (reg BI h-ubit))) 1194*16dce513Schristos) 1195*16dce513Schristos(dsh-protected-bit-v32 h-qbit "Pending single-step bit") 1196*16dce513Schristos 1197*16dce513Schristos(define-hardware 1198*16dce513Schristos (name h-sbit) 1199*16dce513Schristos (comment "Cause single step exception on ... [see CRISv32 ref] bit") 1200*16dce513Schristos (attrs MACH-V32) 1201*16dce513Schristos (type register BI) 1202*16dce513Schristos (set 1203*16dce513Schristos (val) 1204*16dce513Schristos (sequence 1205*16dce513Schristos () 1206*16dce513Schristos (if (not (reg BI h-ubit)) 1207*16dce513Schristos (sequence 1208*16dce513Schristos ((BI enabled)) 1209*16dce513Schristos (set enabled (andif val (not (raw-reg BI h-sbit)))) 1210*16dce513Schristos (set (raw-reg BI h-sbit) val) 1211*16dce513Schristos ; Call handler when enabling. 1212*16dce513Schristos (if enabled (c-call VOID "@cpu@_single_step_enabled")))))) 1213*16dce513Schristos) 1214*16dce513Schristos 1215*16dce513Schristos(dnop cbit "" (SEM-ONLY) h-cbit f-nil) 1216*16dce513Schristos(dnop cbit-move 1217*16dce513Schristos "cbit for pre-V32, nothing for newer" (SEM-ONLY) h-cbit-move f-nil) 1218*16dce513Schristos(dnop vbit "" (SEM-ONLY) h-vbit f-nil) 1219*16dce513Schristos(dnop vbit-move 1220*16dce513Schristos "vbit for pre-V32, nothing for newer" (SEM-ONLY) h-vbit-move f-nil) 1221*16dce513Schristos(dnop zbit "" (SEM-ONLY) h-zbit f-nil) 1222*16dce513Schristos(dnop zbit-move 1223*16dce513Schristos "zbit for pre-V32, nothing for newer" (SEM-ONLY) h-zbit-move f-nil) 1224*16dce513Schristos(dnop nbit "" (SEM-ONLY) h-nbit f-nil) 1225*16dce513Schristos(dnop nbit-move 1226*16dce513Schristos "nbit for pre-V32, nothing for newer" (SEM-ONLY) h-nbit-move f-nil) 1227*16dce513Schristos(dnop xbit "" (SEM-ONLY) h-xbit f-nil) 1228*16dce513Schristos(dnop ibit "" (SEM-ONLY) h-ibit f-nil) 1229*16dce513Schristos(dnop ubit "" (SEM-ONLY (MACH crisv10,crisv32)) h-ubit f-nil) 1230*16dce513Schristos(dnop pbit "" (SEM-ONLY (MACH crisv10,crisv32)) h-pbit f-nil) 1231*16dce513Schristos(dnop 1232*16dce513Schristos rbit "carry bit for MCP+restore-P flag bit" (SEM-ONLY MACH-V32) h-rbit f-nil) 1233*16dce513Schristos(dnop sbit "" (SEM-ONLY MACH-V32) h-sbit f-nil) 1234*16dce513Schristos(dnop mbit "" (SEM-ONLY MACH-V32) h-mbit f-nil) 1235*16dce513Schristos(dnop qbit "" (SEM-ONLY MACH-V32) h-qbit f-nil) 1236*16dce513Schristos 1237*16dce513Schristos(cris-d-hwreg h-insn-prefixed-p BI) 1238*16dce513Schristos(cris-dsh 1239*16dce513Schristos h-insn-prefixed-p-x 1240*16dce513Schristos h-insn-prefixed-p-pre-v32 1241*16dce513Schristos "instruction-is-prefixed bit" 1242*16dce513Schristos (MACH-PRE-V32) 1243*16dce513Schristos (register BI) 1244*16dce513Schristos) 1245*16dce513Schristos 1246*16dce513Schristos; CRISv32 has no prefixing on memory accesses. CGEN-FIXME: [Once (eq-attr 1247*16dce513Schristos; (current-mach) ...) works]: can we change andif and/or orif so it 1248*16dce513Schristos; doesn't look too close at short-circuited operands and avoid defining an 1249*16dce513Schristos; operand that doesn't apply to a certain mach? 1250*16dce513Schristos(define-hardware 1251*16dce513Schristos (semantic-name h-insn-prefixed-p-x) 1252*16dce513Schristos (name h-insn-prefixed-p-v32) 1253*16dce513Schristos (attrs MACH-V32 VIRTUAL) 1254*16dce513Schristos (comment "instruction-is-prefixed bit") 1255*16dce513Schristos (type register BI) 1256*16dce513Schristos (get () (const BI 0)) 1257*16dce513Schristos (set (val) (nop)) 1258*16dce513Schristos) 1259*16dce513Schristos(dnop 1260*16dce513Schristos prefix-set 1261*16dce513Schristos "Instruction-prefixed flag" 1262*16dce513Schristos (SEM-ONLY) 1263*16dce513Schristos h-insn-prefixed-p 1264*16dce513Schristos f-nil 1265*16dce513Schristos) 1266*16dce513Schristos 1267*16dce513Schristos(cris-dsh 1268*16dce513Schristos h-prefixreg h-prefixreg-pre-v32 1269*16dce513Schristos "Prefix-address register" (MACH-PRE-V32) (register SI)) 1270*16dce513Schristos(define-hardware 1271*16dce513Schristos (semantic-name h-prefixreg) 1272*16dce513Schristos (name h-prefixreg-v32) 1273*16dce513Schristos (comment "Prefix-address register, redirecting to ACR") 1274*16dce513Schristos (attrs MACH-V32 VIRTUAL) 1275*16dce513Schristos (type register SI) 1276*16dce513Schristos ; Why can't we have just a "acr" a.k.a "(reg h-gr 15)" here? 1277*16dce513Schristos (get () acr) 1278*16dce513Schristos (set (value) (set acr value)) 1279*16dce513Schristos) 1280*16dce513Schristos 1281*16dce513Schristos(dnop 1282*16dce513Schristos prefixreg 1283*16dce513Schristos "Prefix address" 1284*16dce513Schristos (SEM-ONLY) 1285*16dce513Schristos h-prefixreg 1286*16dce513Schristos f-nil 1287*16dce513Schristos) 1288*16dce513Schristos 1289*16dce513Schristos;;;;;;;;;;;;;;;;;; -ifield 1290*16dce513Schristos 1291*16dce513Schristos; 15 0 1292*16dce513Schristos; +-----------+-----+-----------+-----+-----------+ 1293*16dce513Schristos; | Operand2 | Mode| Opcode | Size| Operand1 | 1294*16dce513Schristos; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 1295*16dce513Schristos; 1296*16dce513Schristos; Figure 5. General instruction format. 1297*16dce513Schristos; 1298*16dce513Schristos; Some deviations from this format exist, [see below]. 1299*16dce513Schristos 1300*16dce513Schristos; Field specifiers in CGEN specify the highest numbered bit followed by 1301*16dce513Schristos; the number of bits. 1302*16dce513Schristos 1303*16dce513Schristos(dnf f-operand1 "Operand1" () 3 4) 1304*16dce513Schristos(dnf f-size "Size" () 5 2) 1305*16dce513Schristos(dnf f-opcode "Opcode" () 9 4) 1306*16dce513Schristos(dnf f-mode "Mode" () 11 2) 1307*16dce513Schristos(dnf f-operand2 "Operand2" () 15 4) 1308*16dce513Schristos 1309*16dce513Schristos; Subfields. FIXME: unfortunately there's some limitation in CGEN so we 1310*16dce513Schristos; can't (as would be somewhat intuitive) make f-mode a multi-ifield 1311*16dce513Schristos; consisting of these two, concatenated. 1312*16dce513Schristos(dnf f-memmode "Indirect of autoincrement" () 10 1) 1313*16dce513Schristos(dnf f-membit "Memory specifier" () 11 1) 1314*16dce513Schristos 1315*16dce513Schristos(dnf f-b5 "Bit 5 (zero for some quick operands)" () 5 1) 1316*16dce513Schristos 1317*16dce513Schristos; When the addressing mode is quick immediate, the low bits are 1318*16dce513Schristos; part of the operand. 1319*16dce513Schristos(dnf f-opcode-hi "Opcode field, high bits" () 9 2) 1320*16dce513Schristos 1321*16dce513Schristos; Common synonyms for those fields. 1322*16dce513Schristos(define-pmacro f-source f-operand1) 1323*16dce513Schristos(define-pmacro f-dest f-operand2) 1324*16dce513Schristos 1325*16dce513Schristos(dnmf 1326*16dce513Schristos f-dstsrc "Dest and source fields concatenated" () UINT 1327*16dce513Schristos (f-dest f-source) 1328*16dce513Schristos ; Insert-code. 1329*16dce513Schristos (sequence 1330*16dce513Schristos ((SI tmpval)) 1331*16dce513Schristos (set tmpval (ifield f-dstsrc)) 1332*16dce513Schristos (set (ifield f-dest) (and (srl tmpval 4) #xf)) 1333*16dce513Schristos (set (ifield f-source) (and tmpval #xf))) 1334*16dce513Schristos ; Extract-code. 1335*16dce513Schristos (set 1336*16dce513Schristos (ifield f-dstsrc) 1337*16dce513Schristos (and (or (ifield f-source) (sll (ifield f-dest) 4)) #xff)) 1338*16dce513Schristos) 1339*16dce513Schristos 1340*16dce513Schristos;The 6-bit value may be sign or zero extended depending on the instruction. 1341*16dce513Schristos; 1342*16dce513Schristos; 15 0 1343*16dce513Schristos; +-----------+-----+-----------+-----+-----------+ 1344*16dce513Schristos; | Operand2 | Mode| Opcode | Immediate value | 1345*16dce513Schristos; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 1346*16dce513Schristos; 1347*16dce513Schristos; Figure 6. Quick immediate addressing mode instruction format. 1348*16dce513Schristos 1349*16dce513Schristos(dnf f-u6 "Quick immediate unsigned 6-bit" () 5 6) 1350*16dce513Schristos(df f-s6 "Quick signed 6-bit" () 5 6 INT #f #f) 1351*16dce513Schristos 1352*16dce513Schristos; There's also a variant used with shift insns, with one bit larger opcode 1353*16dce513Schristos; and one bit smaller immediate value, though it doesn't have a general 1354*16dce513Schristos; graphic description. 1355*16dce513Schristos(dnf f-u5 "Quick unsigned 5-bit" () 4 5) 1356*16dce513Schristos 1357*16dce513Schristos; Similarly, a four-bit immediate field. 1358*16dce513Schristos(dnf f-u4 "Quick unsigned 4-bit" () 3 4) 1359*16dce513Schristos 1360*16dce513Schristos; An 8-bit signed value, which doesn't have a general graphic description. 1361*16dce513Schristos(df f-s8 "Source signed byte" () 7 8 INT #f #f) 1362*16dce513Schristos 1363*16dce513Schristos; The 9-bit branch offset, with bit 0 in the field being bit 8 in the 1364*16dce513Schristos; offset, and bit 0 in the offset always 0. 1365*16dce513Schristos(df f-disp9-hi "PC-relative 9-bit offset, sign bit" () 0 1 INT #f #f) 1366*16dce513Schristos(dnf f-disp9-lo "PC-relative 9-bit offset, low bits" () 7 7) 1367*16dce513Schristos 1368*16dce513Schristos; It would work to have this in two mach-specific variants, but 1369*16dce513Schristos; considering that current-mach-is-v32 is a compile-time constant, we 1370*16dce513Schristos; don't win any simulator performance. 1371*16dce513Schristos(dnmf 1372*16dce513Schristos f-disp9 "PC-relative 9-bit offset" 1373*16dce513Schristos (PCREL-ADDR) 1374*16dce513Schristos INT 1375*16dce513Schristos (f-disp9-hi f-disp9-lo) 1376*16dce513Schristos ; Insert-code. 1377*16dce513Schristos (sequence 1378*16dce513Schristos ((SI absval)) 1379*16dce513Schristos (set absval (srl (sub (sub SI (ifield f-disp9) pc) 1380*16dce513Schristos (if SI current-mach-is-v32 0 2)) 1)) 1381*16dce513Schristos (set (ifield f-disp9-hi) (if (lt absval 0) 1 0)) 1382*16dce513Schristos (set (ifield f-disp9-lo) (and absval) #x7f)) 1383*16dce513Schristos ; Extract-code. 1384*16dce513Schristos (sequence 1385*16dce513Schristos ((SI abslo) (SI absval)) 1386*16dce513Schristos (set abslo (sll (ifield f-disp9-lo) 1)) 1387*16dce513Schristos (set absval 1388*16dce513Schristos (or (if SI (ne (ifield f-disp9-hi) 0) 1389*16dce513Schristos (inv SI #xff) 1390*16dce513Schristos 0) 1391*16dce513Schristos abslo)) 1392*16dce513Schristos (set (ifield f-disp9) 1393*16dce513Schristos (add SI (add SI pc absval) (if SI current-mach-is-v32 0 2)))) 1394*16dce513Schristos) 1395*16dce513Schristos 1396*16dce513Schristos; The operand of LAPCQ is PC-relative, similar to f-disp9 but unsigned, 1397*16dce513Schristos; and only four bits. 1398*16dce513Schristos(df 1399*16dce513Schristos f-qo 1400*16dce513Schristos "PC-relative 4-bit unsigned offset, counted from start of insn" 1401*16dce513Schristos (MACH-V32 PCREL-ADDR) 1402*16dce513Schristos 3 4 1403*16dce513Schristos UINT 1404*16dce513Schristos ; Insert-code. 1405*16dce513Schristos ((value pc) (srl SI (sub SI value pc) 1)) 1406*16dce513Schristos ; Extract-code. 1407*16dce513Schristos ((value pc) (add SI pc (sll SI value 1))) 1408*16dce513Schristos) 1409*16dce513Schristos 1410*16dce513Schristos; 8-bit, 16-bit and 32-bit immediates. The 8-bit values are constructed 1411*16dce513Schristos; through encoding/decoding functions, since the PC increment is by a 1412*16dce513Schristos; word. 1413*16dce513Schristos(define-pmacro (dcrisf x-name x-comment x-attrs x-word-offset x-word-length 1414*16dce513Schristos x-start x-length x-mode x-encode x-decode) 1415*16dce513Schristos (define-ifield 1416*16dce513Schristos (name x-name) 1417*16dce513Schristos (comment x-comment) 1418*16dce513Schristos (.splice attrs (.unsplice x-attrs)) 1419*16dce513Schristos (word-offset x-word-offset) 1420*16dce513Schristos (word-length x-word-length) 1421*16dce513Schristos (start x-start) 1422*16dce513Schristos (length x-length) 1423*16dce513Schristos (mode x-mode) 1424*16dce513Schristos (.splice encode (.unsplice x-encode)) 1425*16dce513Schristos (.splice decode (.unsplice x-decode)) 1426*16dce513Schristos ) 1427*16dce513Schristos) 1428*16dce513Schristos 1429*16dce513Schristos(dcrisf 1430*16dce513Schristos f-indir-pc+-byte "[PC+] 8-bit field" (SIGN-OPT) 1431*16dce513Schristos 16 16 1432*16dce513Schristos 15 16 ; CGEN-FIXME: Should be 7 8 1433*16dce513Schristos INT (#f) (#f) 1434*16dce513Schristos) 1435*16dce513Schristos 1436*16dce513Schristos(dcrisf 1437*16dce513Schristos f-indir-pc+-word "[PC+] 16-bit field" (SIGN-OPT) 1438*16dce513Schristos 16 16 15 16 INT (#f) (#f) 1439*16dce513Schristos) 1440*16dce513Schristos 1441*16dce513Schristos; CGEN-FIXME: I shouldn't have to use trunc here, should I? 1442*16dce513Schristos; Sign-extension should be implicit through use of SI (as opposed to USI) 1443*16dce513Schristos; and additionally through SIGN-OPT. The ext isn't actually needed, but 1444*16dce513Schristos; having it there rather than implicit makes more sense than to just have 1445*16dce513Schristos; the trunc. 1446*16dce513Schristos(dcrisf 1447*16dce513Schristos f-indir-pc+-word-pcrel "[PC+] PC-relative 16-bit field" 1448*16dce513Schristos (PCREL-ADDR SIGN-OPT) 1449*16dce513Schristos 16 16 15 16 SI 1450*16dce513Schristos ((value pc) (sub SI value (add SI pc (if SI current-mach-is-v32 0 4)))) 1451*16dce513Schristos ((value pc) (add SI (ext SI (trunc HI value)) (add SI pc (if SI current-mach-is-v32 0 4)))) 1452*16dce513Schristos) 1453*16dce513Schristos 1454*16dce513Schristos(dcrisf 1455*16dce513Schristos f-indir-pc+-dword "PC autoincrement - 32-bit field" (SIGN-OPT) 1456*16dce513Schristos 16 32 31 32 INT (#f) (#f) 1457*16dce513Schristos) 1458*16dce513Schristos 1459*16dce513Schristos(dcrisf 1460*16dce513Schristos f-indir-pc+-dword-pcrel 1461*16dce513Schristos "[PC+] PC-relative 32-bit field, counted from start of insn" 1462*16dce513Schristos (SIGN-OPT MACH-V32 PCREL-ADDR) 1463*16dce513Schristos 16 32 31 32 INT 1464*16dce513Schristos ((value pc) (sub SI value pc)) 1465*16dce513Schristos ((value pc) (add SI pc value)) 1466*16dce513Schristos) 1467*16dce513Schristos 1468*16dce513Schristos;;;;;;;;;;;;;;;;;; -insn-enum -normal-operand -normal-derived-operand 1469*16dce513Schristos 1470*16dce513Schristos;; How different fields are transformed into something we put in insns. 1471*16dce513Schristos 1472*16dce513Schristos; m := size modifier, byte (00), word (01) or dword (10) 1473*16dce513Schristos; z := size modifier, byte (0) or word (1) 1474*16dce513Schristos; (For the latter, the "higher" bit is always 0, mapping trivially on m.) 1475*16dce513Schristos 1476*16dce513Schristos(define-normal-insn-enum 1477*16dce513Schristos insn-size 1478*16dce513Schristos "Standard instruction operand size" 1479*16dce513Schristos () 1480*16dce513Schristos SIZE_ 1481*16dce513Schristos f-size 1482*16dce513Schristos ("BYTE" "WORD" "DWORD" "FIXED") 1483*16dce513Schristos) 1484*16dce513Schristos 1485*16dce513Schristos; The mode field for insns with "s" operand (perhaps with a partial set of 1486*16dce513Schristos; operand types). 1487*16dce513Schristos(define-normal-insn-enum 1488*16dce513Schristos insn-mode 1489*16dce513Schristos "Standard instruction addressing modes" 1490*16dce513Schristos () 1491*16dce513Schristos MODE_ 1492*16dce513Schristos f-mode 1493*16dce513Schristos ("QUICK_IMMEDIATE" "REGISTER" "INDIRECT" "AUTOINCREMENT") 1494*16dce513Schristos) 1495*16dce513Schristos 1496*16dce513Schristos(define-normal-insn-enum 1497*16dce513Schristos insn-memoryness-mode 1498*16dce513Schristos "Whether the operand is indirect" 1499*16dce513Schristos () 1500*16dce513Schristos MODEMEMP_ 1501*16dce513Schristos f-membit 1502*16dce513Schristos ("NO" "YES") 1503*16dce513Schristos) 1504*16dce513Schristos 1505*16dce513Schristos; FIXME: Needed? 1506*16dce513Schristos(define-normal-insn-enum 1507*16dce513Schristos insn-memincness-mode 1508*16dce513Schristos "Whether the indirect operand is autoincrement" 1509*16dce513Schristos () 1510*16dce513Schristos MODEINCP_ 1511*16dce513Schristos f-memmode 1512*16dce513Schristos ("NO" "YES") 1513*16dce513Schristos) 1514*16dce513Schristos 1515*16dce513Schristos; Special semantics for multiply. 1516*16dce513Schristos(define-pmacro MODE_MULU MODE_INDIRECT) 1517*16dce513Schristos(define-pmacro MODE_MULS MODE_AUTOINCREMENT) 1518*16dce513Schristos 1519*16dce513Schristos(define-normal-insn-enum 1520*16dce513Schristos insn-signed-size 1521*16dce513Schristos "Signed instruction operand size" 1522*16dce513Schristos () 1523*16dce513Schristos SIGNED_ 1524*16dce513Schristos f-size 1525*16dce513Schristos ("UNDEF_SIZE_0" "UNDEF_SIZE_1" "BYTE" "WORD") 1526*16dce513Schristos) 1527*16dce513Schristos 1528*16dce513Schristos(define-normal-insn-enum 1529*16dce513Schristos insn-unsigned-size 1530*16dce513Schristos "Unsigned instruction operand size" 1531*16dce513Schristos () 1532*16dce513Schristos UNSIGNED_ 1533*16dce513Schristos f-size 1534*16dce513Schristos ("BYTE" "WORD" "UNDEF_SIZE_2" "UNDEF_SIZE_3") 1535*16dce513Schristos) 1536*16dce513Schristos 1537*16dce513Schristos; Rs := source operand, register addressing mode 1538*16dce513Schristos(dnop Rs "Source general register" () h-gr f-source) 1539*16dce513Schristos 1540*16dce513Schristos; [Rs] := source operand, indirect addressing mode 1541*16dce513Schristos; = MODE_INDIRECT Rs 1542*16dce513Schristos 1543*16dce513Schristos; [Rs+] := source operand, autoincrement addressing mode (see note!) 1544*16dce513Schristos; = MODE_AUTOINCREMENT Rs 1545*16dce513Schristos 1546*16dce513Schristos; The union of [Rs] and [Rs(+)] 1547*16dce513Schristos; = MODEMEMP_YES Rs 1548*16dce513Schristos 1549*16dce513Schristos; Whether an indirect operand is increment can be obtained as an operand by 1550*16dce513Schristos; = inc 1551*16dce513Schristos(dnop inc "Incrementness of indirect operand" () h-inc f-memmode) 1552*16dce513Schristos 1553*16dce513Schristos; or as an affirmative specifier 1554*16dce513Schristos; = MODEINCP_YES 1555*16dce513Schristos; (or MODEINCP_NO) 1556*16dce513Schristos 1557*16dce513Schristos; s := source operand, any of the modes Rs, [Rs] or [Rs+] 1558*16dce513Schristos; No common operand; each are handled separately, using the above definitions. 1559*16dce513Schristos 1560*16dce513Schristos; Ps := source operand, special register 1561*16dce513Schristos; It's in the field usually used for the destination. 1562*16dce513Schristos(dnop Ps "Source special register" () h-sr f-dest) 1563*16dce513Schristos 1564*16dce513Schristos; Ss := source operand, support register 1565*16dce513Schristos; It's in the field usually used for the destination. 1566*16dce513Schristos(dnop Ss "Source support register" (MACH-V32) h-supr f-dest) 1567*16dce513Schristos 1568*16dce513Schristos; Sd := source operand, support register 1569*16dce513Schristos(dnop Sd "Destination support register" (MACH-V32) h-supr f-dest) 1570*16dce513Schristos 1571*16dce513Schristos; i := 6-bit signed immediate operand 1572*16dce513Schristos(dnop i "Quick signed 6-bit" () h-sint f-s6) 1573*16dce513Schristos 1574*16dce513Schristos; j := 6-bit unsigned immediate operand 1575*16dce513Schristos(dnop j "Quick unsigned 6-bit" () h-uint f-u6) 1576*16dce513Schristos 1577*16dce513Schristos; c := 5-bit immediate shift value 1578*16dce513Schristos(dnop c "Quick unsigned 5-bit" () h-uint f-u5) 1579*16dce513Schristos 1580*16dce513Schristos; qo := 4-bit unsigned immediate operand 1581*16dce513Schristos(dnop qo "Quick unsigned 4-bit, PC-relative" (MACH-V32) h-addr f-qo) 1582*16dce513Schristos 1583*16dce513Schristos; Rd := destination operand, register addressing mode 1584*16dce513Schristos(dnop Rd "Destination general register" () h-gr f-dest) 1585*16dce513Schristos(define-pmacro Rd-sfield Rs) 1586*16dce513Schristos(define-pmacro Rs-dfield Rd) 1587*16dce513Schristos 1588*16dce513Schristos; [Rd] := destination operand, indirect addressing mode 1589*16dce513Schristos; = MODE_INDIRECT Rd 1590*16dce513Schristos 1591*16dce513Schristos; [Rd+] := destination operand, autoincrement addressing mode 1592*16dce513Schristos; = MODE_AUTOINCREMENT Rd 1593*16dce513Schristos 1594*16dce513Schristos; [PC+] := destination operand PC, autoincrement addressing mode 1595*16dce513Schristos; = MODE_AUTOINCREMENT (f-dest 15) X 1596*16dce513Schristos; where X is one of sconst8, uconst8, sconst16, uconst16 or const32. 1597*16dce513Schristos(dnop sconst8 "Signed byte [PC+]" () h-sint f-indir-pc+-byte) 1598*16dce513Schristos(dnop uconst8 "Unsigned byte [PC+]" () h-uint f-indir-pc+-byte) 1599*16dce513Schristos(dnop sconst16 "Signed word [PC+]" () h-sint f-indir-pc+-word) 1600*16dce513Schristos(dnop uconst16 "Unsigned word [PC+]" () h-uint f-indir-pc+-word) 1601*16dce513Schristos(dnop const32 "Dword [PC+]" () h-uint f-indir-pc+-dword) 1602*16dce513Schristos(dnop const32-pcrel "Dword [PC+]" () h-addr f-indir-pc+-dword-pcrel) 1603*16dce513Schristos 1604*16dce513Schristos; d := destination operand, any of the modes Rd, [Rd] or [Rd+] 1605*16dce513Schristos; No common operand; each are handled separately, using the above definitions. 1606*16dce513Schristos 1607*16dce513Schristos; Pd := destination operand, special register 1608*16dce513Schristos(dnop Pd "Destination special register" () h-sr f-dest) 1609*16dce513Schristos 1610*16dce513Schristos; o := 8-bit immediate offset value 1611*16dce513Schristos(dnop o "Signed 8-bit" () h-sint f-s8) 1612*16dce513Schristos 1613*16dce513Schristos; The division of operand semantics and insn fields in the CRIS 1614*16dce513Schristos; instruction set reference doesn't permit a simple mapping to a 1615*16dce513Schristos; simulator description, and the division of insn fields and 1616*16dce513Schristos; semantics in CGEN is not between the define-normal-ifield 1617*16dce513Schristos; vs. define-normal-operand. For example, the "o" operand is 1618*16dce513Schristos; PC-relative for branch insns, as described by the CGEN f-disp9 1619*16dce513Schristos; field. 1620*16dce513Schristos; See comment at f-disp9; thankfully the mach 1621*16dce513Schristos; attribute works here to have two different definitions by the 1622*16dce513Schristos; same name. 1623*16dce513Schristos(dnop o-pcrel "9-bit signed immediate PC-rel" 1624*16dce513Schristos () 1625*16dce513Schristos h-iaddr f-disp9) 1626*16dce513Schristos 1627*16dce513Schristos(dnop o-word-pcrel "16-bit signed immediate PC-rel" 1628*16dce513Schristos () 1629*16dce513Schristos h-iaddr f-indir-pc+-word-pcrel) 1630*16dce513Schristos 1631*16dce513Schristos; cc := condition code 1632*16dce513Schristos(dnop cc "Condition codes" () h-ccode f-dest) 1633*16dce513Schristos 1634*16dce513Schristos; n := 4 bit breakpoint exception vector index 1635*16dce513Schristos(dnop n "Quick unsigned 4-bit" () h-uint f-u4) 1636*16dce513Schristos 1637*16dce513Schristos; The "option" in the SWAP insn. 1638*16dce513Schristos(dnop swapoption "Swap option" () h-swap f-dest) 1639*16dce513Schristos 1640*16dce513Schristos(dnop list-of-flags "Flag bits as operand" () h-flagbits f-dstsrc) 1641*16dce513Schristos 1642*16dce513Schristos; Enumerations for insn codes, for use in insn definitions 1643*16dce513Schristos; instead of raw numbers. See it as operand definitions for the 1644*16dce513Schristos; opcode field. 1645*16dce513Schristos 1646*16dce513Schristos(define-normal-insn-enum 1647*16dce513Schristos insn-qi-opc 1648*16dce513Schristos "Insns for MODE_QUICK_IMMEDIATE" 1649*16dce513Schristos () 1650*16dce513Schristos Q_ 1651*16dce513Schristos f-opcode 1652*16dce513Schristos ("BCC_0" "BCC_1" "BCC_2" "BCC_3" 1653*16dce513Schristos "BDAP_0" "BDAP_1" "BDAP_2" "BDAP_3" 1654*16dce513Schristos "ADDQ" "MOVEQ" "SUBQ" "CMPQ" 1655*16dce513Schristos "ANDQ" "ORQ" "ASHQ" "LSHQ") 1656*16dce513Schristos) 1657*16dce513Schristos 1658*16dce513Schristos(define-normal-insn-enum 1659*16dce513Schristos insn-qihi-opc 1660*16dce513Schristos "Same as insn-qi-opc, though using only the high two bits of the opcode" 1661*16dce513Schristos () 1662*16dce513Schristos QHI_ 1663*16dce513Schristos f-opcode-hi 1664*16dce513Schristos ("BCC" "BDAP" "OTHER2" "OTHER3") 1665*16dce513Schristos) 1666*16dce513Schristos(define-pmacro QHI_ADDOQ QHI_BDAP) 1667*16dce513Schristos 1668*16dce513Schristos(define-normal-insn-enum 1669*16dce513Schristos insn-r-opc 1670*16dce513Schristos "Insns for MODE_REGISTER and either SIZE_BYTE, SIZE_WORD or SIZE_DWORD" 1671*16dce513Schristos () 1672*16dce513Schristos R_ 1673*16dce513Schristos f-opcode 1674*16dce513Schristos ("ADDX" "MOVX" "SUBX" "LSL" 1675*16dce513Schristos "ADDI" "BIAP" "NEG" "BOUND" 1676*16dce513Schristos "ADD" "MOVE" "SUB" "CMP" 1677*16dce513Schristos "AND" "OR" "ASR" "LSR") 1678*16dce513Schristos) 1679*16dce513Schristos(define-pmacro R_ADDI_ACR R_BIAP) 1680*16dce513Schristos 1681*16dce513Schristos(define-normal-insn-enum 1682*16dce513Schristos insn-rfix-opc 1683*16dce513Schristos "Insns for MODE_REGISTER and SIZE_FIXED" 1684*16dce513Schristos () 1685*16dce513Schristos RFIX_ 1686*16dce513Schristos f-opcode 1687*16dce513Schristos ("ADDX" "MOVX" "SUBX" "BTST" 1688*16dce513Schristos "SCC" "ADDC" "SETF" "CLEARF" 1689*16dce513Schristos "MOVE_R_S" "MOVE_S_R" "ABS" "DSTEP" 1690*16dce513Schristos "LZ" "SWAP" "XOR" "MSTEP") 1691*16dce513Schristos) 1692*16dce513Schristos(define-pmacro RFIX_MCP RFIX_MSTEP) 1693*16dce513Schristos 1694*16dce513Schristos(define-normal-insn-enum 1695*16dce513Schristos insn-indir-opc 1696*16dce513Schristos "Insns for (MODE_INDIRECT or MODE_AUTOINCREMENT) and either SIZE_BYTE, SIZE_WORD or SIZE_DWORD" 1697*16dce513Schristos () 1698*16dce513Schristos INDIR_ 1699*16dce513Schristos f-opcode 1700*16dce513Schristos ("ADDX" "MOVX" "SUBX" "CMPX" 1701*16dce513Schristos "MUL" "BDAP_M" "ADDC" "BOUND" 1702*16dce513Schristos "ADD" "MOVE_M_R" "SUB" "CMP" 1703*16dce513Schristos "AND" "OR" "TEST" "MOVE_R_M") 1704*16dce513Schristos) 1705*16dce513Schristos(define-pmacro INDIR_ADDO INDIR_BDAP_M) 1706*16dce513Schristos 1707*16dce513Schristos(define-normal-insn-enum 1708*16dce513Schristos insn-infix-opc 1709*16dce513Schristos "Insns for (MODE_INDIRECT or MODE_AUTOINCREMENT) and SIZE_FIXED" 1710*16dce513Schristos () 1711*16dce513Schristos INFIX_ 1712*16dce513Schristos f-opcode 1713*16dce513Schristos ("ADDX" "MOVX" "SUBX" "CMPX" 1714*16dce513Schristos "JUMP_M" "DIP" "JUMP_R" "BCC_M" 1715*16dce513Schristos "MOVE_M_S" "MOVE_S_M" "BMOD" "BSTORE" 1716*16dce513Schristos "RBF" "SBFS" "MOVEM_M_R" "MOVEM_R_M") 1717*16dce513Schristos) 1718*16dce513Schristos 1719*16dce513Schristos(define-pmacro INFIX_MOVE_SS INFIX_SBFS) 1720*16dce513Schristos(define-pmacro INFIX_LAPC INFIX_DIP) 1721*16dce513Schristos(define-pmacro INFIX_RFE INFIX_JUMP_M) 1722*16dce513Schristos(define-pmacro INFIX_RFN INFIX_JUMP_M) 1723*16dce513Schristos(define-pmacro INFIX_HALT INFIX_JUMP_M) 1724*16dce513Schristos(define-pmacro INFIX_SFE INFIX_JUMP_M) 1725*16dce513Schristos(define-pmacro INFIX_RFG INFIX_JUMP_M) 1726*16dce513Schristos(define-pmacro INFIX_JAS_R INFIX_JUMP_R) 1727*16dce513Schristos(define-pmacro INFIX_JAS_M INFIX_JUMP_R) 1728*16dce513Schristos(define-pmacro INFIX_JASC INFIX_RBF) 1729*16dce513Schristos(define-pmacro INFIX_JUMP_P INFIX_BCC_M) 1730*16dce513Schristos(define-pmacro INFIX_BAS INFIX_BMOD) 1731*16dce513Schristos(define-pmacro INFIX_BASC INFIX_BSTORE) 1732*16dce513Schristos(define-pmacro INFIX_BREAK INFIX_JUMP_M) 1733*16dce513Schristos(define-pmacro INFIX_FIDXI INFIX_JUMP_M) 1734*16dce513Schristos(define-pmacro INFIX_FIDXD INFIX_BAS) 1735*16dce513Schristos(define-pmacro INFIX_FTAGI INFIX_JUMP_M) 1736*16dce513Schristos(define-pmacro INFIX_FTAGD INFIX_BAS) 1737*16dce513Schristos 1738*16dce513Schristos; Classes of insns: 1739*16dce513Schristos; Move-to-register, move-to-memory, move-to/from-other-register, 1740*16dce513Schristos; logical, arithmetic, branch. 1741*16dce513Schristos; Classes of operands: 1742*16dce513Schristos; quick, register, memory-indirect, memory-postinc. 1743*16dce513Schristos 1744*16dce513Schristos 1745*16dce513Schristos;;;;;;;;;;;;;;;;;; -normal-insn 1746*16dce513Schristos 1747*16dce513Schristos(define-pmacro (dni-bwd-attr name comment attr syntax fmt fsem timing) 1748*16dce513Schristos (begin 1749*16dce513Schristos (dni (.sym name .b) (.str "byte " comment) attr (.str name ".b " syntax) 1750*16dce513Schristos (.splice (.unsplice fmt) SIZE_BYTE) 1751*16dce513Schristos (fsem QI) 1752*16dce513Schristos timing) 1753*16dce513Schristos (dni (.sym name .w) (.str "word " comment) attr (.str name ".w " syntax) 1754*16dce513Schristos (.splice (.unsplice fmt) SIZE_WORD) 1755*16dce513Schristos (fsem HI) 1756*16dce513Schristos timing) 1757*16dce513Schristos (dni (.sym name .d) (.str "dword " comment) attr (.str name ".d " syntax) 1758*16dce513Schristos (.splice (.unsplice fmt) SIZE_DWORD) 1759*16dce513Schristos (fsem SI) 1760*16dce513Schristos timing)) 1761*16dce513Schristos) 1762*16dce513Schristos 1763*16dce513Schristos(define-pmacro (dni-cdt-attr name comment attr syntax fmt semantics) 1764*16dce513Schristos "dni without specifying timing" 1765*16dce513Schristos (dni name comment attr syntax fmt semantics (cris-timing)) 1766*16dce513Schristos) 1767*16dce513Schristos 1768*16dce513Schristos(define-pmacro (dni-cdt-bwd-attr name comment attr syntax fmt fsem) 1769*16dce513Schristos (begin 1770*16dce513Schristos (dni-cdt-attr (.sym name .b-r) (.str "byte " comment) attr (.str name ".b " syntax) 1771*16dce513Schristos (.splice (.unsplice fmt) SIZE_BYTE) 1772*16dce513Schristos (fsem QI)) 1773*16dce513Schristos (dni-cdt-attr (.sym name .w-r) (.str "word " comment) attr (.str name ".w " syntax) 1774*16dce513Schristos (.splice (.unsplice fmt) SIZE_WORD) 1775*16dce513Schristos (fsem HI)) 1776*16dce513Schristos (dni-cdt-attr (.sym name .d-r) (.str "dword " comment) attr (.str name ".d " syntax) 1777*16dce513Schristos (.splice (.unsplice fmt) SIZE_DWORD) 1778*16dce513Schristos (fsem SI))) 1779*16dce513Schristos) 1780*16dce513Schristos 1781*16dce513Schristos; Some convenience macros based on the above ones. 1782*16dce513Schristos(define-pmacro (dni-cdt-bwd name comment syntax fmt fsem) 1783*16dce513Schristos (dni-cdt-bwd-attr name comment () syntax fmt fsem) 1784*16dce513Schristos) 1785*16dce513Schristos 1786*16dce513Schristos(define-pmacro (dni-bwd name comment syntax fmt fsem timing) 1787*16dce513Schristos (dni-bwd-attr comment () syntax fmt fsem timing) 1788*16dce513Schristos) 1789*16dce513Schristos 1790*16dce513Schristos(define-pmacro-map 1791*16dce513Schristos (((dni-cdt name comment syntax fmt semantics) 1792*16dce513Schristos (dni-cdt-attr name comment () syntax fmt semantics)) 1793*16dce513Schristos ((dni-c-QI-attr name comment attr syntax fmt fsem) 1794*16dce513Schristos (dni name comment attr syntax fmt fsem (cris-timing-const-QI))) 1795*16dce513Schristos ((dni-c-HI-attr name comment attr syntax fmt fsem) 1796*16dce513Schristos (dni name comment attr syntax fmt fsem (cris-timing-const-HI))) 1797*16dce513Schristos ((dni-c-SI-attr name comment attr syntax fmt fsem) 1798*16dce513Schristos (dni name comment attr syntax fmt fsem (cris-timing-const-SI)))) 1799*16dce513Schristos) 1800*16dce513Schristos 1801*16dce513Schristos(define-pmacro-map 1802*16dce513Schristos (((dni-c-QI name comment syntax fmt fsem) 1803*16dce513Schristos (dni-c-QI-attr name comment () syntax fmt fsem)) 1804*16dce513Schristos ((dni-c-HI name comment syntax fmt fsem) 1805*16dce513Schristos (dni-c-HI-attr name comment () syntax fmt fsem)) 1806*16dce513Schristos ((dni-c-SI name comment syntax fmt fsem) 1807*16dce513Schristos (dni-c-SI-attr name comment () syntax fmt fsem))) 1808*16dce513Schristos) 1809*16dce513Schristos 1810*16dce513Schristos; These flags are both cleared by all insns except prefixes (before 1811*16dce513Schristos; CRISv32) and "setf x", so we put them in a handy macro. 1812*16dce513Schristos(define-pmacro 1813*16dce513Schristos (reset-x-p) 1814*16dce513Schristos (sequence 1815*16dce513Schristos () 1816*16dce513Schristos (set xbit 0) 1817*16dce513Schristos (set prefix-set 0)) 1818*16dce513Schristos) 1819*16dce513Schristos 1820*16dce513Schristos; NOP | 0 0 0 0| 0 1| 0 1 0 0| 0 0| 1 1 1 1| 1821*16dce513Schristos; (For V32, "SETF" (no flags) is used.) 1822*16dce513Schristos(dni-cdt-attr 1823*16dce513Schristos nop "nop" (MACH-PC) "nop" 1824*16dce513Schristos (+ (f-operand2 0) R_ADDI MODE_REGISTER SIZE_BYTE (f-operand1 15)) 1825*16dce513Schristos (reset-x-p) 1826*16dce513Schristos) 1827*16dce513Schristos 1828*16dce513Schristos; Pre- and v32+ variants MOVE insns set flags differently. These two 1829*16dce513Schristos; macros for flag settings are meant to be used in all MOVE insns. 1830*16dce513Schristos(define-pmacro (setf-moveq value) 1831*16dce513Schristos (sequence 1832*16dce513Schristos () 1833*16dce513Schristos (set-quiet nbit-move (lt SI value 0)) 1834*16dce513Schristos (set-quiet zbit-move (andif BI (eq SI value 0) (if BI xbit zbit 1))) 1835*16dce513Schristos (set-quiet cbit-move 0) 1836*16dce513Schristos (set-quiet vbit-move 0) 1837*16dce513Schristos (reset-x-p)) 1838*16dce513Schristos) 1839*16dce513Schristos 1840*16dce513Schristos(define-pmacro (setf-move size value) 1841*16dce513Schristos (sequence 1842*16dce513Schristos () 1843*16dce513Schristos (set nbit (lt size value 0)) 1844*16dce513Schristos (set zbit (andif BI (eq size value 0) (if BI xbit zbit 1))) 1845*16dce513Schristos (set-quiet cbit-move 0) 1846*16dce513Schristos (set-quiet vbit-move 0) 1847*16dce513Schristos (reset-x-p)) 1848*16dce513Schristos) 1849*16dce513Schristos; The CGEN binop-with-bit operations are not documented well enough that I 1850*16dce513Schristos; trust their semantics to remain stable. Better define local ones: the 1851*16dce513Schristos; semantics become explicit. 1852*16dce513Schristos(define-pmacro-map 1853*16dce513Schristos (((add-overflow size R D S carry) 1854*16dce513Schristos (orif BI (andif BI (andif BI (lt size S 0) (lt size D 0)) (ge size R 0)) 1855*16dce513Schristos (andif BI (andif BI (ge size S 0) (ge size D 0)) (lt size R 0)))) 1856*16dce513Schristos ((add-carry size R D S carry) 1857*16dce513Schristos (orif BI (andif BI (lt size S 0) (lt size D 0)) 1858*16dce513Schristos (orif BI (andif BI (lt size D 0) (ge size R 0)) 1859*16dce513Schristos (andif BI (lt size S 0) (ge size R 0))))) 1860*16dce513Schristos ((sub-overflow size R D S carry) 1861*16dce513Schristos (orif BI (andif BI (andif BI (ge size S 0) (lt size D 0)) (ge size R 0)) 1862*16dce513Schristos (andif BI (andif BI (lt size S 0) (ge size D 0)) (lt size R 0)))) 1863*16dce513Schristos ((sub-carry size R D S carry) 1864*16dce513Schristos (orif BI (andif BI (lt size S 0) (ge size D 0)) 1865*16dce513Schristos (orif BI (andif BI (ge size D 0) (lt size R 0)) 1866*16dce513Schristos (andif BI (lt size S 0) (lt size R 0))))) 1867*16dce513Schristos ; Only valid for size := DI 1868*16dce513Schristos ((mulu-overflow size R D S carry) 1869*16dce513Schristos (ne DI R (zext DI (trunc SI R)))) 1870*16dce513Schristos ((mulu-carry size R D S carry) 1871*16dce513Schristos (andif current-mach-is-v32 carry)) 1872*16dce513Schristos ((muls-overflow size R D S carry) 1873*16dce513Schristos (ne DI R (ext DI (trunc SI R)))) 1874*16dce513Schristos ((muls-carry size R D S carry) 1875*16dce513Schristos (andif current-mach-is-v32 carry))) 1876*16dce513Schristos) 1877*16dce513Schristos 1878*16dce513Schristos(define-pmacro (setf-arit2 size op source1 source2 result carryin carryout) 1879*16dce513Schristos "Set no-prefix, x=0, carryout, v, z and n according to operation OP in size SIZE" 1880*16dce513Schristos (sequence 1881*16dce513Schristos () 1882*16dce513Schristos (set carryout ((.sym op -carry) size result source1 source2 carryin)) 1883*16dce513Schristos (set nbit (lt size result 0)) 1884*16dce513Schristos (set zbit (andif BI (eq size result 0) (orif BI zbit (not BI xbit)))) 1885*16dce513Schristos (set vbit ((.sym op -overflow) size result source1 source2 carryin)) 1886*16dce513Schristos (reset-x-p)) 1887*16dce513Schristos) 1888*16dce513Schristos(define-pmacro (setf-arit size op source1 source2 result carry) 1889*16dce513Schristos "Set no-prefix, x=0, c, v, z and n according to operation OP in size SIZE" 1890*16dce513Schristos (setf-arit2 size op source1 source2 result carry cbit) 1891*16dce513Schristos) 1892*16dce513Schristos 1893*16dce513Schristos; Let's have convienence macros for arithmetic, including evaluation of the 1894*16dce513Schristos; operation, destination modification, flag setting and carry propagation. 1895*16dce513Schristos(define-pmacro 1896*16dce513Schristos (cris-arit6-int arit size fdest fdest_op srcop1 srcop2 carryout carryin) 1897*16dce513Schristos "Core for performing some three-operand arithmetic with carry as parameter" 1898*16dce513Schristos (sequence 1899*16dce513Schristos ((size tmpopd) (size tmpops) (BI carry) (size newval)) 1900*16dce513Schristos (set tmpops srcop2) 1901*16dce513Schristos (set tmpopd srcop1) 1902*16dce513Schristos (set carry carryin) 1903*16dce513Schristos (set newval ((.sym arit c) tmpopd tmpops (if BI (eq xbit 0) 0 carry))) 1904*16dce513Schristos (fdest size fdest_op newval) 1905*16dce513Schristos (setf-arit2 size arit tmpopd tmpops newval carry carryout)) 1906*16dce513Schristos) 1907*16dce513Schristos 1908*16dce513Schristos(define-pmacro 1909*16dce513Schristos (cris-arit5-int arit size destregno srcop1 srcop2 carryout carryin) 1910*16dce513Schristos "As cris-arit6-int, but to set a part of a general register" 1911*16dce513Schristos (cris-arit6-int 1912*16dce513Schristos arit 1913*16dce513Schristos size 1914*16dce513Schristos (.pmacro (sz regno val) (set-subreg-gr sz regno val)) 1915*16dce513Schristos destregno 1916*16dce513Schristos srcop1 1917*16dce513Schristos srcop2 1918*16dce513Schristos carryout 1919*16dce513Schristos carryin) 1920*16dce513Schristos) 1921*16dce513Schristos 1922*16dce513Schristos(define-pmacro (cris-arit5 arit size destreg srcop1 srcop2 carryout carryin) 1923*16dce513Schristos "As cris-arit5-int, but takes a register as parameter, not register number" 1924*16dce513Schristos (cris-arit5-int arit size (regno destreg) srcop1 srcop2 carryout carryin) 1925*16dce513Schristos) 1926*16dce513Schristos(define-pmacro (cris-arit3-int arit size destregno srcop1 srcop2) 1927*16dce513Schristos "As cris-arit5-int, but with carry-in same as carry-out" 1928*16dce513Schristos (cris-arit5-int arit size destregno srcop1 srcop2 cbit cbit) 1929*16dce513Schristos) 1930*16dce513Schristos(define-pmacro (cris-arit3 arit size destreg srcop1 srcop2) 1931*16dce513Schristos "As cris-arit3-int, but takes a register as parameter, not register number" 1932*16dce513Schristos (cris-arit3-int arit size (regno destreg) srcop1 srcop2) 1933*16dce513Schristos) 1934*16dce513Schristos(define-pmacro (cris-arit arit size destreg srcop) 1935*16dce513Schristos "As cris-arit3, but with destination same as srcop1" 1936*16dce513Schristos (cris-arit3 arit size destreg destreg srcop) 1937*16dce513Schristos) 1938*16dce513Schristos(define-pmacro (cris-arit-3op arit size destsrcop2 srcop1 dest-3op) 1939*16dce513Schristos "Similar to cris-arit3-int, but for prefixed operand only" 1940*16dce513Schristos (cris-arit3-int arit size 1941*16dce513Schristos (if SI (andif prefix-set (not inc)) 1942*16dce513Schristos (regno dest-3op) 1943*16dce513Schristos (regno destsrcop2)) 1944*16dce513Schristos destsrcop2 srcop1) 1945*16dce513Schristos) 1946*16dce513Schristos 1947*16dce513Schristos; Convenience macros to select a part of a value and its complement, for 1948*16dce513Schristos; the <op>.b, <op>.w and <op>.d operations. 1949*16dce513Schristos(define-pmacro (QI-part val) (and SI val #xff)) 1950*16dce513Schristos(define-pmacro (non-QI-part val) (and SI val #xffffff00)) 1951*16dce513Schristos(define-pmacro (HI-part val) (and SI val #xffff)) 1952*16dce513Schristos(define-pmacro (non-HI-part val) (and SI val #xffff0000)) 1953*16dce513Schristos(define-pmacro (SI-part val) val) 1954*16dce513Schristos(define-pmacro (non-SI-part val) 0) 1955*16dce513Schristos(define-pmacro 1956*16dce513Schristos (set-subreg-gr-bw BWD gregno newval) 1957*16dce513Schristos "Set a byte or word part or full dword of a general register" 1958*16dce513Schristos (sequence 1959*16dce513Schristos ((SI oldregval)) 1960*16dce513Schristos (set oldregval (reg h-raw-gr gregno)) 1961*16dce513Schristos (set (reg h-gr gregno) 1962*16dce513Schristos (or SI ((.sym BWD -part) newval) ((.sym non- BWD -part) oldregval)))) 1963*16dce513Schristos) 1964*16dce513Schristos(define-pmacro (set-subreg-gr BWD gregno newval) 1965*16dce513Schristos ((.sym set-subreg-gr- BWD) BWD gregno newval) 1966*16dce513Schristos) 1967*16dce513Schristos(define-pmacro (set-subreg-gr-SI SI gregno newval) 1968*16dce513Schristos (set (reg h-gr gregno) newval) 1969*16dce513Schristos) 1970*16dce513Schristos(define-pmacro set-subreg-gr-HI set-subreg-gr-bw) 1971*16dce513Schristos(define-pmacro set-subreg-gr-QI set-subreg-gr-bw) 1972*16dce513Schristos 1973*16dce513Schristos; MOVE.m Rs,Rd [ Rd | 011001mm | Rs ] 1974*16dce513Schristos(dni-cdt-bwd 1975*16dce513Schristos move "move.m r,R" 1976*16dce513Schristos "move.m ${Rs},${Rd}" 1977*16dce513Schristos (+ Rd MODE_REGISTER R_MOVE Rs) 1978*16dce513Schristos (.pmacro 1979*16dce513Schristos (BWD) 1980*16dce513Schristos (sequence 1981*16dce513Schristos ((BWD newval)) 1982*16dce513Schristos (set newval Rs) 1983*16dce513Schristos (set-subreg-gr BWD (regno Rd) newval) 1984*16dce513Schristos (setf-move BWD newval))) 1985*16dce513Schristos) 1986*16dce513Schristos 1987*16dce513Schristos; MOVE.D PC,Rd [ Rd | 01100110 | 1111 ] 1988*16dce513Schristos; This insn is used in PIC code to find out the code address. It's an 1989*16dce513Schristos; exception to the (guarded) non-implementation of PC operands in this 1990*16dce513Schristos; file. 1991*16dce513Schristos(dni-cdt-attr 1992*16dce513Schristos movepcr "move.d PC,R" 1993*16dce513Schristos (MACH-PC UNCOND-CTI) 1994*16dce513Schristos "move.d PC,${Rd}" 1995*16dce513Schristos (+ Rd MODE_REGISTER R_MOVE SIZE_DWORD (f-source 15)) 1996*16dce513Schristos (sequence 1997*16dce513Schristos ((SI pcval)) 1998*16dce513Schristos (set pcval (add SI pc 2)) 1999*16dce513Schristos (set Rd pcval) 2000*16dce513Schristos (setf-move SI pcval)) 2001*16dce513Schristos) 2002*16dce513Schristos 2003*16dce513Schristos; MOVEQ i,Rd [ Rd | 001001 | i ] 2004*16dce513Schristos(dni-cdt 2005*16dce513Schristos moveq "moveq" 2006*16dce513Schristos "moveq $i,$Rd" 2007*16dce513Schristos (+ Rd MODE_QUICK_IMMEDIATE Q_MOVEQ i) 2008*16dce513Schristos (sequence 2009*16dce513Schristos ((SI newval)) 2010*16dce513Schristos (set newval i) 2011*16dce513Schristos (set Rd newval) 2012*16dce513Schristos (setf-moveq newval)) 2013*16dce513Schristos) 2014*16dce513Schristos 2015*16dce513Schristos(define-pmacro (dni-cdt-sbw name comment syntax fmt fsem) 2016*16dce513Schristos "Insn generator for insns with signed <op>.b and <op>.w variants" 2017*16dce513Schristos (begin 2018*16dce513Schristos (dni-cdt 2019*16dce513Schristos (.sym name .b-r) (.str "byte " comment) (.str name ".b " syntax) 2020*16dce513Schristos (.splice (.unsplice fmt) SIGNED_BYTE) 2021*16dce513Schristos (fsem QI)) 2022*16dce513Schristos (dni-cdt 2023*16dce513Schristos (.sym name .w-r) (.str "word " comment) (.str name ".w " syntax) 2024*16dce513Schristos (.splice (.unsplice fmt) SIGNED_WORD) 2025*16dce513Schristos (fsem HI))) 2026*16dce513Schristos) 2027*16dce513Schristos 2028*16dce513Schristos; MOVS.z Rs,Rd [ Rd | 0100011z | Rs ] 2029*16dce513Schristos(dni-cdt-sbw 2030*16dce513Schristos movs "movs.m r,R" 2031*16dce513Schristos "movs.m ${Rs},${Rd}" 2032*16dce513Schristos (+ Rd MODE_REGISTER R_MOVX Rs) 2033*16dce513Schristos (.pmacro 2034*16dce513Schristos (BW) 2035*16dce513Schristos (sequence 2036*16dce513Schristos ((BW tmpops) (SI newval)) 2037*16dce513Schristos (set tmpops Rs) 2038*16dce513Schristos (set newval (ext SI tmpops)) 2039*16dce513Schristos (set Rd newval) 2040*16dce513Schristos (setf-move SI newval))) 2041*16dce513Schristos) 2042*16dce513Schristos 2043*16dce513Schristos(define-pmacro (dni-cdt-ubw name comment syntax fmt fsem) 2044*16dce513Schristos "Similar to dni-cdt-sbw but for unsigned operations" 2045*16dce513Schristos (begin 2046*16dce513Schristos (dni-cdt 2047*16dce513Schristos (.sym name .b-r) (.str "byte " comment) (.str name ".b " syntax) 2048*16dce513Schristos (.splice (.unsplice fmt) UNSIGNED_BYTE) 2049*16dce513Schristos (fsem QI)) 2050*16dce513Schristos (dni-cdt 2051*16dce513Schristos (.sym name .w-r) (.str "word " comment) (.str name ".w " syntax) 2052*16dce513Schristos (.splice (.unsplice fmt) UNSIGNED_WORD) 2053*16dce513Schristos (fsem HI))) 2054*16dce513Schristos) 2055*16dce513Schristos 2056*16dce513Schristos; MOVU.z Rs,Rd [ Rd | 0100010z | Rs ] 2057*16dce513Schristos(dni-cdt-ubw 2058*16dce513Schristos movu "movu.m r,R" 2059*16dce513Schristos "movu.m ${Rs},${Rd}" 2060*16dce513Schristos (+ Rd MODE_REGISTER R_MOVX Rs) 2061*16dce513Schristos (.pmacro 2062*16dce513Schristos (BW) 2063*16dce513Schristos (sequence 2064*16dce513Schristos ((BW tmpops) (SI newval)) 2065*16dce513Schristos (set tmpops Rs) 2066*16dce513Schristos (set newval (zext SI tmpops)) 2067*16dce513Schristos (set Rd newval) 2068*16dce513Schristos (setf-move SI newval))) 2069*16dce513Schristos) 2070*16dce513Schristos 2071*16dce513Schristos; (MOVE.m [PC+],Rd [ Rd | 111001mm | 1111 ]) 2072*16dce513Schristos; For the moment, it doesn't seem worthwhile to make a dni-c-bwd macro; 2073*16dce513Schristos; too many places to parametrize. 2074*16dce513Schristos(dni-c-QI 2075*16dce513Schristos movecbr "move.b [PC+],R" 2076*16dce513Schristos "move.b ${sconst8},${Rd}" 2077*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_MOVE_M_R SIZE_BYTE (f-source 15) sconst8) 2078*16dce513Schristos (sequence 2079*16dce513Schristos ((QI newval)) 2080*16dce513Schristos (set newval sconst8) 2081*16dce513Schristos (set-subreg-gr QI (regno Rd) newval) 2082*16dce513Schristos (setf-move QI newval)) 2083*16dce513Schristos) 2084*16dce513Schristos 2085*16dce513Schristos(dni-c-HI 2086*16dce513Schristos movecwr "move.w [PC+],R" 2087*16dce513Schristos "move.w ${sconst16},${Rd}" 2088*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_MOVE_M_R SIZE_WORD (f-source 15) sconst16) 2089*16dce513Schristos (sequence 2090*16dce513Schristos ((HI newval)) 2091*16dce513Schristos (set newval sconst16) 2092*16dce513Schristos (set-subreg-gr HI (regno Rd) newval) 2093*16dce513Schristos (setf-move HI newval)) 2094*16dce513Schristos) 2095*16dce513Schristos 2096*16dce513Schristos(dni-c-SI 2097*16dce513Schristos movecdr "move.d [PC+],R" 2098*16dce513Schristos "move.d ${const32},${Rd}" 2099*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_MOVE_M_R SIZE_DWORD (f-source 15) const32) 2100*16dce513Schristos (sequence 2101*16dce513Schristos ((SI newval)) 2102*16dce513Schristos (set newval const32) 2103*16dce513Schristos (set Rd newval) 2104*16dce513Schristos (setf-move SI newval)) 2105*16dce513Schristos) 2106*16dce513Schristos 2107*16dce513Schristos; (MOVS.z [PC+],Rd [ Rd | 1100011z | 1111 ]) 2108*16dce513Schristos; Similarly, no likely net improvement for a dni-c-bw. 2109*16dce513Schristos(dni-c-QI 2110*16dce513Schristos movscbr "movs.b [PC+],R" 2111*16dce513Schristos "movs.b ${sconst8},${Rd}" 2112*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_MOVX SIGNED_BYTE (f-source 15) sconst8) 2113*16dce513Schristos (sequence 2114*16dce513Schristos ((SI newval)) 2115*16dce513Schristos ; FIXME: Make trunc unnecessary. 2116*16dce513Schristos (set newval (ext SI (trunc QI sconst8))) 2117*16dce513Schristos (set Rd newval) 2118*16dce513Schristos (setf-move SI newval)) 2119*16dce513Schristos) 2120*16dce513Schristos 2121*16dce513Schristos(dni-c-HI 2122*16dce513Schristos movscwr "movs.w [PC+],R" 2123*16dce513Schristos "movs.w ${sconst16},${Rd}" 2124*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_MOVX SIGNED_WORD (f-source 15) sconst16) 2125*16dce513Schristos (sequence 2126*16dce513Schristos ((SI newval)) 2127*16dce513Schristos ; FIXME: Make trunc unnecessary. 2128*16dce513Schristos (set newval (ext SI (trunc HI sconst16))) 2129*16dce513Schristos (set Rd newval) 2130*16dce513Schristos (setf-move SI newval)) 2131*16dce513Schristos) 2132*16dce513Schristos 2133*16dce513Schristos; (MOVU.z [PC+],Rd [ Rd | 1100010z | 1111 ]) 2134*16dce513Schristos(dni-c-QI 2135*16dce513Schristos movucbr "movu.b [PC+],R" 2136*16dce513Schristos "movu.b ${uconst8},${Rd}" 2137*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_MOVX UNSIGNED_BYTE (f-source 15) uconst8) 2138*16dce513Schristos (sequence 2139*16dce513Schristos ((SI newval)) 2140*16dce513Schristos ; FIXME: Make trunc unnecessary. 2141*16dce513Schristos (set newval (zext SI (trunc QI uconst8))) 2142*16dce513Schristos (set Rd newval) 2143*16dce513Schristos (setf-move SI newval)) 2144*16dce513Schristos) 2145*16dce513Schristos 2146*16dce513Schristos(dni-c-HI 2147*16dce513Schristos movucwr "movu.w [PC+],R" 2148*16dce513Schristos "movu.w ${uconst16},${Rd}" 2149*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_MOVX UNSIGNED_WORD (f-source 15) uconst16) 2150*16dce513Schristos (sequence 2151*16dce513Schristos ((SI newval)) 2152*16dce513Schristos ; FIXME: Make trunc unnecessary. 2153*16dce513Schristos (set newval (zext SI (trunc HI uconst16))) 2154*16dce513Schristos (set Rd newval) 2155*16dce513Schristos (setf-move SI newval)) 2156*16dce513Schristos) 2157*16dce513Schristos 2158*16dce513Schristos; ADDQ j,Rd [ Rd | 001000 | j ] 2159*16dce513Schristos(dni-cdt 2160*16dce513Schristos addq "addq j,Rd" 2161*16dce513Schristos "addq $j,$Rd" 2162*16dce513Schristos (+ Rd MODE_QUICK_IMMEDIATE Q_ADDQ j) 2163*16dce513Schristos (cris-arit add SI Rd j) 2164*16dce513Schristos) 2165*16dce513Schristos 2166*16dce513Schristos; SUBQ j,Rd [ Rd | 001010| j ] 2167*16dce513Schristos(dni-cdt 2168*16dce513Schristos subq "subq j,Rd" 2169*16dce513Schristos "subq $j,$Rd" 2170*16dce513Schristos (+ Rd MODE_QUICK_IMMEDIATE Q_SUBQ j) 2171*16dce513Schristos (cris-arit sub SI Rd j) 2172*16dce513Schristos) 2173*16dce513Schristos 2174*16dce513Schristos; Convenience macros for insns with a memory operand. 2175*16dce513Schristos(define-pmacro 2176*16dce513Schristos (dni-cmt-attr-tim name comment attr syntax fmt semantics timing) 2177*16dce513Schristos "dni with memory-access" 2178*16dce513Schristos (dni name comment attr syntax 2179*16dce513Schristos ; Specifying MODE_INDIRECT and MODE_AUTOINCREMENT in this 2180*16dce513Schristos ; manner makes the autoincrementness handily available. 2181*16dce513Schristos ; It also effectively excludes non-memory use of dni-cmt. 2182*16dce513Schristos (.splice (.unsplice fmt) MODEMEMP_YES inc) 2183*16dce513Schristos semantics 2184*16dce513Schristos timing) 2185*16dce513Schristos) 2186*16dce513Schristos 2187*16dce513Schristos(define-pmacro (dni-cmt-attr name comment attr syntax fmt semantics) 2188*16dce513Schristos "dni with read memory-access timing" 2189*16dce513Schristos (dni-cmt-attr-tim name comment attr syntax fmt semantics 2190*16dce513Schristos (cris-mem-timing)) 2191*16dce513Schristos) 2192*16dce513Schristos 2193*16dce513Schristos(define-pmacro (dni-cmwt-attr name comment attr syntax fmt semantics) 2194*16dce513Schristos "dni with write memory-access timing" 2195*16dce513Schristos (dni-cmt-attr-tim name comment attr syntax fmt semantics 2196*16dce513Schristos (cris-mem-write-timing)) 2197*16dce513Schristos) 2198*16dce513Schristos 2199*16dce513Schristos(define-pmacro QI-size 1) 2200*16dce513Schristos(define-pmacro HI-size 2) 2201*16dce513Schristos(define-pmacro SI-size 4) 2202*16dce513Schristos 2203*16dce513Schristos(define-pmacro (cris-get-mem size regop) 2204*16dce513Schristos "Handle reading memory in <size>, with source address register\ 2205*16dce513Schristos (read once, maybe set once) in <regop> or prefixed" 2206*16dce513Schristos (sequence 2207*16dce513Schristos size 2208*16dce513Schristos ((SI addr) (size tmp-mem) (BI postinc)) 2209*16dce513Schristos 2210*16dce513Schristos ; Cache the incrementness of the operand. 2211*16dce513Schristos (set postinc inc) 2212*16dce513Schristos 2213*16dce513Schristos ; Get the address from somewhere. 2214*16dce513Schristos (set addr 2215*16dce513Schristos (if SI (eq prefix-set 0) 2216*16dce513Schristos ; If the insn was prefixed, it's in the prefix-register. 2217*16dce513Schristos regop 2218*16dce513Schristos prefixreg)) 2219*16dce513Schristos 2220*16dce513Schristos ; Get the memory contents. 2221*16dce513Schristos (set tmp-mem (mem size addr)) 2222*16dce513Schristos 2223*16dce513Schristos ; For non-prefixed post-increment, we increment the address by the 2224*16dce513Schristos ; size of the memory access. 2225*16dce513Schristos (if (ne postinc 0) 2226*16dce513Schristos (sequence 2227*16dce513Schristos () 2228*16dce513Schristos (if (eq prefix-set 0) 2229*16dce513Schristos (set addr (add addr (.sym size -size)))) 2230*16dce513Schristos ; Update the source-register for post-increments. 2231*16dce513Schristos (set regop addr))) 2232*16dce513Schristos 2233*16dce513Schristos ; Don't forget the return-value. 2234*16dce513Schristos tmp-mem) 2235*16dce513Schristos) 2236*16dce513Schristos 2237*16dce513Schristos(define-pmacro (cris-set-mem size regop value) 2238*16dce513Schristos "Handle writing <value> of <size> to memory, with memory address register\ 2239*16dce513Schristos (read once, maybe set once) in <regop> or prefixed." 2240*16dce513Schristos (sequence 2241*16dce513Schristos ((SI addr) (BI postinc)) 2242*16dce513Schristos 2243*16dce513Schristos ; Cache the incrementness of the operand. 2244*16dce513Schristos (set postinc inc) 2245*16dce513Schristos 2246*16dce513Schristos ; Get the address from somewhere. 2247*16dce513Schristos (set addr 2248*16dce513Schristos (if SI (eq prefix-set 0) 2249*16dce513Schristos ; If the insn was prefixed, it's in the prefix-register. 2250*16dce513Schristos regop 2251*16dce513Schristos prefixreg)) 2252*16dce513Schristos 2253*16dce513Schristos ; Set the memory contents. Integral-write semantics apply. 2254*16dce513Schristos ; FIXME: currently v32 only; when proper semantics needed, fix v10. 2255*16dce513Schristos (if (andif current-mach-is-v32 (ne xbit 0)) 2256*16dce513Schristos (if (eq pbit 0) 2257*16dce513Schristos (sequence 2258*16dce513Schristos () 2259*16dce513Schristos (set (mem size addr) value) 2260*16dce513Schristos ; Write failures are signalled (by whatever entity "sends 2261*16dce513Schristos ; the signal") by setting P at time of the write above, if X 2262*16dce513Schristos ; is set. Here, we just need to copy P into C. 2263*16dce513Schristos (set cbit pbit)) 2264*16dce513Schristos (set cbit 1)) 2265*16dce513Schristos (set (mem size addr) value)) 2266*16dce513Schristos 2267*16dce513Schristos ; For non-prefixed post-increment, we increment the address by the 2268*16dce513Schristos ; size of the memory access. As for the integral-write, this needs to 2269*16dce513Schristos ; be tweaked for pre-v32: increment should have been performed if 2270*16dce513Schristos ; there's a fault at the memory access above. 2271*16dce513Schristos (if (ne postinc 0) 2272*16dce513Schristos (sequence 2273*16dce513Schristos () 2274*16dce513Schristos (if (eq prefix-set 0) 2275*16dce513Schristos (set addr (add addr (.sym size -size)))) 2276*16dce513Schristos ; Update the source-register for post-increments. 2277*16dce513Schristos (set regop addr)))) 2278*16dce513Schristos) 2279*16dce513Schristos 2280*16dce513Schristos(define-pmacro 2281*16dce513Schristos (dni-cmt-bwd-attr-tim name comment attr syntax fmt fsem timing) 2282*16dce513Schristos "Core generator macro for insns with <op>.b, <op>.w and <op>.d variants\ 2283*16dce513Schristos and a memory operand." 2284*16dce513Schristos (begin 2285*16dce513Schristos (dni-cmt-attr-tim 2286*16dce513Schristos (.sym name .b-m) 2287*16dce513Schristos (.str "byte mem " comment) 2288*16dce513Schristos attr 2289*16dce513Schristos (.str name ".b " syntax) 2290*16dce513Schristos (.splice (.unsplice fmt) SIZE_BYTE) 2291*16dce513Schristos (fsem QI) 2292*16dce513Schristos timing) 2293*16dce513Schristos (dni-cmt-attr-tim 2294*16dce513Schristos (.sym name .w-m) 2295*16dce513Schristos (.str "word mem " comment) 2296*16dce513Schristos attr 2297*16dce513Schristos (.str name ".w " syntax) 2298*16dce513Schristos (.splice (.unsplice fmt) SIZE_WORD) 2299*16dce513Schristos (fsem HI) 2300*16dce513Schristos timing) 2301*16dce513Schristos (dni-cmt-attr-tim 2302*16dce513Schristos (.sym name .d-m) 2303*16dce513Schristos (.str "dword mem " comment) 2304*16dce513Schristos attr 2305*16dce513Schristos (.str name ".d " syntax) 2306*16dce513Schristos (.splice (.unsplice fmt) SIZE_DWORD) 2307*16dce513Schristos (fsem SI) 2308*16dce513Schristos timing)) 2309*16dce513Schristos) 2310*16dce513Schristos 2311*16dce513Schristos; Further refinement macros. 2312*16dce513Schristos(define-pmacro (dni-cmt-bwd-attr name comment attr syntax fmt fsem) 2313*16dce513Schristos (dni-cmt-bwd-attr-tim name comment attr syntax fmt fsem 2314*16dce513Schristos (cris-mem-timing)) 2315*16dce513Schristos) 2316*16dce513Schristos 2317*16dce513Schristos(define-pmacro (dni-cmwt-bwd name comment syntax fmt fsem) 2318*16dce513Schristos (dni-cmt-bwd-attr-tim name comment () syntax fmt fsem 2319*16dce513Schristos (cris-mem-write-timing)) 2320*16dce513Schristos) 2321*16dce513Schristos 2322*16dce513Schristos(define-pmacro (dni-cmt-bwd name comment syntax fmt fsem) 2323*16dce513Schristos (dni-cmt-bwd-attr name comment () syntax fmt fsem) 2324*16dce513Schristos) 2325*16dce513Schristos 2326*16dce513Schristos(define-pmacro (dni-cmt-sbw name comment syntax fmt fsem) 2327*16dce513Schristos "Core generator macro for insns with <op>.b and <op>.w variants\ 2328*16dce513Schristos and a signed memory operand." 2329*16dce513Schristos (begin 2330*16dce513Schristos (dni-cmt-attr 2331*16dce513Schristos (.sym name .b-m) (.str "byte mem " comment) 2332*16dce513Schristos () 2333*16dce513Schristos (.str name ".b " syntax) 2334*16dce513Schristos (.splice (.unsplice fmt) SIGNED_BYTE) 2335*16dce513Schristos (fsem QI)) 2336*16dce513Schristos (dni-cmt-attr 2337*16dce513Schristos (.sym name .w-m) (.str "word mem " comment) 2338*16dce513Schristos () 2339*16dce513Schristos (.str name ".w " syntax) 2340*16dce513Schristos (.splice (.unsplice fmt) SIGNED_WORD) 2341*16dce513Schristos (fsem HI))) 2342*16dce513Schristos) 2343*16dce513Schristos 2344*16dce513Schristos(define-pmacro (dni-cmt-ubw name comment syntax fmt fsem) 2345*16dce513Schristos "Core generator macro for insns with <op>.b and <op>.w variants\ 2346*16dce513Schristos and an unsigned memory operand." 2347*16dce513Schristos (begin 2348*16dce513Schristos (dni-cmt-attr 2349*16dce513Schristos (.sym name .b-m) (.str "byte mem " comment) 2350*16dce513Schristos () 2351*16dce513Schristos (.str name ".b " syntax) 2352*16dce513Schristos (.splice (.unsplice fmt) UNSIGNED_BYTE) 2353*16dce513Schristos (fsem QI)) 2354*16dce513Schristos (dni-cmt-attr 2355*16dce513Schristos (.sym name .w-m) (.str "word mem " comment) 2356*16dce513Schristos () 2357*16dce513Schristos (.str name ".w " syntax) 2358*16dce513Schristos (.splice (.unsplice fmt) UNSIGNED_WORD) 2359*16dce513Schristos (fsem HI))) 2360*16dce513Schristos) 2361*16dce513Schristos 2362*16dce513Schristos; CMP.m Rs,Rd [ Rd | 011011mm | Rs ] 2363*16dce513Schristos(dni-cdt-bwd 2364*16dce513Schristos cmp-r "compare register to register" 2365*16dce513Schristos "$Rs,$Rd" 2366*16dce513Schristos (+ Rd MODE_REGISTER R_CMP Rs) 2367*16dce513Schristos (.pmacro 2368*16dce513Schristos (BWD) 2369*16dce513Schristos (cris-arit6-int 2370*16dce513Schristos sub BWD (.pmacro (sz regno val) (nop)) 0 2371*16dce513Schristos Rd Rs cbit cbit)) 2372*16dce513Schristos) 2373*16dce513Schristos 2374*16dce513Schristos; CMP.m [Rs],Rd [ Rd | 101011mm | Rs ] 2375*16dce513Schristos; CMP.m [Rs+],Rd [ Rd | 111011mm | Rs ] 2376*16dce513Schristos(dni-cmt-bwd 2377*16dce513Schristos cmp-m "compare memory to register" 2378*16dce513Schristos "[${Rs}${inc}],${Rd}" 2379*16dce513Schristos (+ INDIR_CMP Rs Rd) 2380*16dce513Schristos (.pmacro 2381*16dce513Schristos (BWD) 2382*16dce513Schristos (cris-arit6-int 2383*16dce513Schristos sub BWD (.pmacro (sz regno val) (nop)) 0 2384*16dce513Schristos Rd (cris-get-mem BWD Rs) cbit cbit)) 2385*16dce513Schristos) 2386*16dce513Schristos 2387*16dce513Schristos; (CMP.m [PC+],Rd [ Rd | 111011mm | 1111 ]) 2388*16dce513Schristos(dni-c-QI 2389*16dce513Schristos cmpcbr "cmp constant byte to register" 2390*16dce513Schristos "cmp.b $sconst8,$Rd" 2391*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_CMP SIZE_BYTE (f-source 15) sconst8) 2392*16dce513Schristos (cris-arit6-int 2393*16dce513Schristos sub QI (.pmacro (sz regno val) (nop)) 0 2394*16dce513Schristos Rd (trunc QI sconst8) cbit cbit) 2395*16dce513Schristos) 2396*16dce513Schristos 2397*16dce513Schristos(dni-c-HI 2398*16dce513Schristos cmpcwr "cmp constant word to register" 2399*16dce513Schristos "cmp.w $sconst16,$Rd" 2400*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_CMP SIZE_WORD (f-source 15) sconst16) 2401*16dce513Schristos (cris-arit6-int 2402*16dce513Schristos sub HI (.pmacro (sz regno val) (nop)) 0 2403*16dce513Schristos Rd (trunc HI sconst16) cbit cbit) 2404*16dce513Schristos) 2405*16dce513Schristos 2406*16dce513Schristos(dni-c-SI 2407*16dce513Schristos cmpcdr "cmp constant dword to register" 2408*16dce513Schristos "cmp.d $const32,$Rd" 2409*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_CMP SIZE_DWORD (f-source 15) const32) 2410*16dce513Schristos (cris-arit6-int 2411*16dce513Schristos sub SI (.pmacro (sz regno val) (nop)) 0 2412*16dce513Schristos Rd const32 cbit cbit) 2413*16dce513Schristos) 2414*16dce513Schristos 2415*16dce513Schristos; CMPQ i,Rd [ Rd | 001011 | i ] 2416*16dce513Schristos(dni-cdt 2417*16dce513Schristos cmpq "cmpq i,Rd" 2418*16dce513Schristos "cmpq $i,$Rd" 2419*16dce513Schristos (+ Rd MODE_QUICK_IMMEDIATE Q_CMPQ i) 2420*16dce513Schristos (cris-arit6-int 2421*16dce513Schristos sub SI (.pmacro (sz regno val) (nop)) 0 2422*16dce513Schristos Rd i cbit cbit) 2423*16dce513Schristos) 2424*16dce513Schristos 2425*16dce513Schristos; CMPS.z [Rs],Rd [ Rd | 1000111z | Rs ] 2426*16dce513Schristos; CMPS.z [Rs+],Rd [ Rd | 1100111z | Rs ] 2427*16dce513Schristos(dni-cmt-sbw 2428*16dce513Schristos cmps-m "cmp sign-extended from memory to register" 2429*16dce513Schristos "[${Rs}${inc}],$Rd" 2430*16dce513Schristos (+ Rd INDIR_CMPX Rs) 2431*16dce513Schristos (.pmacro 2432*16dce513Schristos (BW) 2433*16dce513Schristos (cris-arit6-int 2434*16dce513Schristos sub SI (.pmacro (sz regno val) (nop)) 0 2435*16dce513Schristos Rd ((.sym BW -ext) (cris-get-mem BW Rs)) cbit cbit)) 2436*16dce513Schristos) 2437*16dce513Schristos 2438*16dce513Schristos; (CMPS.z [PC+],Rd [ Rd | 1100111z | 1111 ]) 2439*16dce513Schristos(dni-c-QI 2440*16dce513Schristos cmpscbr "cmp sign-extended constant byte to register" 2441*16dce513Schristos "[${Rs}${inc}],$Rd" 2442*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_CMPX SIGNED_BYTE (f-source 15) sconst8) 2443*16dce513Schristos (cris-arit6-int 2444*16dce513Schristos sub SI (.pmacro (sz regno val) (nop)) 0 2445*16dce513Schristos Rd (ext SI (trunc QI sconst8)) cbit cbit) 2446*16dce513Schristos) 2447*16dce513Schristos(dni-c-HI 2448*16dce513Schristos cmpscwr "cmp sign-extended constant word to register" 2449*16dce513Schristos "[${Rs}${inc}],$Rd" 2450*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_CMPX SIGNED_WORD (f-source 15) sconst16) 2451*16dce513Schristos (cris-arit6-int 2452*16dce513Schristos sub SI (.pmacro (sz regno val) (nop)) 0 2453*16dce513Schristos Rd (ext SI (trunc HI sconst16)) cbit cbit) 2454*16dce513Schristos) 2455*16dce513Schristos 2456*16dce513Schristos; CMPU.z [Rs],Rd [ Rd | 1000110z | Rs ] 2457*16dce513Schristos; CMPU.z [Rs+],Rd [ Rd | 1100110z | Rs ] 2458*16dce513Schristos(dni-cmt-ubw 2459*16dce513Schristos cmpu-m "cmp zero-extended from memory to register" 2460*16dce513Schristos "[${Rs}${inc}],$Rd" 2461*16dce513Schristos (+ Rd INDIR_CMPX Rs) 2462*16dce513Schristos (.pmacro 2463*16dce513Schristos (BW) 2464*16dce513Schristos (cris-arit6-int 2465*16dce513Schristos sub SI (.pmacro (sz regno val) (nop)) 0 2466*16dce513Schristos Rd ((.sym BW -zext) (cris-get-mem BW Rs)) cbit cbit)) 2467*16dce513Schristos) 2468*16dce513Schristos 2469*16dce513Schristos; (CMPU.z [PC+],Rd [ Rd | 1100110z | 1111 ]) 2470*16dce513Schristos(dni-c-QI 2471*16dce513Schristos cmpucbr "cmp zero-extended constant byte to register" 2472*16dce513Schristos "[${Rs}${inc}],$Rd" 2473*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_CMPX UNSIGNED_BYTE (f-source 15) uconst8) 2474*16dce513Schristos (cris-arit6-int 2475*16dce513Schristos sub SI (.pmacro (sz regno val) (nop)) 0 2476*16dce513Schristos Rd (zext SI (trunc QI uconst8)) cbit cbit) 2477*16dce513Schristos) 2478*16dce513Schristos(dni-c-HI 2479*16dce513Schristos cmpucwr "cmp zero-extended constant word to register" 2480*16dce513Schristos "[${Rs}${inc}],$Rd" 2481*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_CMPX UNSIGNED_WORD (f-source 15) uconst16) 2482*16dce513Schristos (cris-arit6-int 2483*16dce513Schristos sub SI (.pmacro (sz regno val) (nop)) 0 2484*16dce513Schristos Rd (zext SI (trunc HI uconst16)) cbit cbit) 2485*16dce513Schristos) 2486*16dce513Schristos 2487*16dce513Schristos; MOVE.m [Rs],Rd [ Rd | 101001mm | Rs ] 2488*16dce513Schristos; MOVE.m [Rs+],Rd [ Rd | 111001mm | Rs ] 2489*16dce513Schristos(dni-cmt-bwd 2490*16dce513Schristos move-m "move from memory to register" 2491*16dce513Schristos "[${Rs}${inc}],${Rd}" 2492*16dce513Schristos (+ INDIR_MOVE_M_R Rs Rd) 2493*16dce513Schristos (.pmacro 2494*16dce513Schristos (BWD) 2495*16dce513Schristos (sequence 2496*16dce513Schristos ((SI tmp)) 2497*16dce513Schristos (set tmp (cris-get-mem BWD Rs)) 2498*16dce513Schristos (set-subreg-gr 2499*16dce513Schristos BWD 2500*16dce513Schristos (if SI (andif prefix-set (not inc)) (regno Rs) (regno Rd)) 2501*16dce513Schristos tmp) 2502*16dce513Schristos (setf-move BWD tmp))) 2503*16dce513Schristos) 2504*16dce513Schristos 2505*16dce513Schristos; MOVS.z [Rs],Rd [ Rd | 1000011z | Rs ] 2506*16dce513Schristos; MOVS.z [Rs+],Rd [ Rd | 1100011z | Rs ] 2507*16dce513Schristos(dni-cmt-sbw 2508*16dce513Schristos movs-m "movs from memory to register" 2509*16dce513Schristos "[${Rs}${inc}],${Rd}" 2510*16dce513Schristos (+ INDIR_MOVX Rs Rd) 2511*16dce513Schristos (.pmacro 2512*16dce513Schristos (BW) 2513*16dce513Schristos (sequence 2514*16dce513Schristos ((SI tmp)) 2515*16dce513Schristos (set tmp (ext SI (cris-get-mem BW Rs))) 2516*16dce513Schristos (if (andif prefix-set (not inc)) 2517*16dce513Schristos (set Rs tmp) 2518*16dce513Schristos (set Rd tmp)) 2519*16dce513Schristos (setf-move SI tmp))) 2520*16dce513Schristos) 2521*16dce513Schristos 2522*16dce513Schristos; MOVU.z [Rs],Rd [ Rd | 1000010z | Rs ] 2523*16dce513Schristos; MOVU.z [Rs+],Rd [ Rd | 1100010z | Rs ] 2524*16dce513Schristos(dni-cmt-ubw 2525*16dce513Schristos movu-m "movu from memory to register" 2526*16dce513Schristos "[${Rs}${inc}],${Rd}" 2527*16dce513Schristos (+ INDIR_MOVX Rs Rd) 2528*16dce513Schristos (.pmacro 2529*16dce513Schristos (BW) 2530*16dce513Schristos (sequence 2531*16dce513Schristos ((SI tmp)) 2532*16dce513Schristos (set tmp (zext SI (cris-get-mem BW Rs))) 2533*16dce513Schristos (if (andif prefix-set (not inc)) 2534*16dce513Schristos (set Rs tmp) 2535*16dce513Schristos (set Rd tmp)) 2536*16dce513Schristos (setf-move SI tmp))) 2537*16dce513Schristos) 2538*16dce513Schristos 2539*16dce513Schristos; MOVE Rs,Pd [ Pd | 01100011 | Rs ] 2540*16dce513Schristos(.splice 2541*16dce513Schristos begin 2542*16dce513Schristos (.unsplice 2543*16dce513Schristos (.map 2544*16dce513Schristos (.pmacro 2545*16dce513Schristos (VER) 2546*16dce513Schristos (dni 2547*16dce513Schristos (.sym move-r-spr VER) 2548*16dce513Schristos "Move from general register to special register" 2549*16dce513Schristos ((MACH (.sym cris VER))) 2550*16dce513Schristos "move ${Rs},${Pd}" 2551*16dce513Schristos (+ RFIX_MOVE_R_S MODE_REGISTER SIZE_FIXED Rs Pd) 2552*16dce513Schristos (sequence 2553*16dce513Schristos ((SI tmp) (SI rno)) 2554*16dce513Schristos (set tmp Rs) 2555*16dce513Schristos (set rno (regno Pd)) 2556*16dce513Schristos (cond 2557*16dce513Schristos ; See reg-sr setter for most of the special-register semantics. 2558*16dce513Schristos ; The sanity check for known read-only registers is for program 2559*16dce513Schristos ; debug help; the real insn would be harmless and have no effect. 2560*16dce513Schristos ; CGEN-FIXME: regno of symbolic h-sr names doesn't work here. 2561*16dce513Schristos ((orif (orif (eq rno 0) (eq rno 1)) (orif (eq rno 4) (eq rno 8))) 2562*16dce513Schristos (error "move-r-spr: trying to set a read-only special register")) 2563*16dce513Schristos (else (set Pd tmp))) 2564*16dce513Schristos (reset-x-p)) 2565*16dce513Schristos (cris-reg-sr-timing))) 2566*16dce513Schristos (cris-cpu-models))) 2567*16dce513Schristos) 2568*16dce513Schristos 2569*16dce513Schristos(define-pmacro (dni-cdt-ver-attr name comment fattr syntax fmt fsem) 2570*16dce513Schristos "Generator for each MACH, using default timing." 2571*16dce513Schristos (.splice 2572*16dce513Schristos begin 2573*16dce513Schristos (.unsplice 2574*16dce513Schristos (.map 2575*16dce513Schristos (.pmacro (v) (dni-cdt-attr name comment (fattr v) syntax fmt (fsem v))) 2576*16dce513Schristos (cris-cpu-models)))) 2577*16dce513Schristos) 2578*16dce513Schristos 2579*16dce513Schristos; MOVE Ps,Rd [ Ps | 01100111 | Rd ] 2580*16dce513Schristos; Note that in the insn format, the Rd operand is in the Rs field (the 2581*16dce513Schristos; Rd field by the definition used everywhere else is the Ps position in 2582*16dce513Schristos; this insn). 2583*16dce513Schristos; It gets a little weird here because we can't get this insn into a 2584*16dce513Schristos; define-pmacro unless we make named pmacros for e.g. a separate attr 2585*16dce513Schristos; function and a semantics function: a .pmacro can't refer to the 2586*16dce513Schristos; parameters of the outer define-pmacro. (The manual refers to this as 2587*16dce513Schristos; not implementing "lexical scoping"). 2588*16dce513Schristos(.splice 2589*16dce513Schristos begin 2590*16dce513Schristos (.unsplice 2591*16dce513Schristos (.map 2592*16dce513Schristos (.pmacro 2593*16dce513Schristos (VER) 2594*16dce513Schristos (dni-cdt-attr 2595*16dce513Schristos (.sym move-spr-r VER) 2596*16dce513Schristos "Move from special register to general register" 2597*16dce513Schristos ((MACH (.sym cris VER))) 2598*16dce513Schristos "move ${Ps},${Rd-sfield}" 2599*16dce513Schristos (+ Ps RFIX_MOVE_S_R MODE_REGISTER SIZE_FIXED Rd-sfield) 2600*16dce513Schristos (sequence 2601*16dce513Schristos ((SI grno) (SI prno) (SI newval)) 2602*16dce513Schristos (set prno (regno Ps)) 2603*16dce513Schristos ; CGEN-FIXME: Can't use the following and then "grno" below because 2604*16dce513Schristos ; CGEN will emit a "tmp_grno" *also* in decodev32.c:crisv32f_decode 2605*16dce513Schristos ; (set grno (regno Rd-sfield)) 2606*16dce513Schristos (set newval Ps) 2607*16dce513Schristos (.splice 2608*16dce513Schristos cond 2609*16dce513Schristos (.unsplice 2610*16dce513Schristos (.map 2611*16dce513Schristos (.pmacro 2612*16dce513Schristos (r) 2613*16dce513Schristos ((eq prno (.cadr2 r)) 2614*16dce513Schristos (set-subreg-gr (.car2 r) (regno Rd-sfield) newval))) 2615*16dce513Schristos ((.sym cris-implemented-readable-specregs- VER)))) 2616*16dce513Schristos (else (error "move-spr-r from unimplemented register"))) 2617*16dce513Schristos (reset-x-p)))) 2618*16dce513Schristos (cris-cpu-models))) 2619*16dce513Schristos) 2620*16dce513Schristos 2621*16dce513Schristos; MOVE Ps,PC [ Ps | 01100111 | 1111 ] 2622*16dce513Schristos; The move-special-register-to-pc insns are return-type instructions and 2623*16dce513Schristos; have to be special-cased to get the delay-slot and avoid being indicated 2624*16dce513Schristos; as invalid. 2625*16dce513Schristos(dni-cdt-attr 2626*16dce513Schristos ret-type 2627*16dce513Schristos "ret-type" 2628*16dce513Schristos (MACH-PC) 2629*16dce513Schristos "ret/reti/retb" 2630*16dce513Schristos (+ Ps MODE_REGISTER RFIX_MOVE_S_R SIZE_FIXED (f-source 15)) 2631*16dce513Schristos (sequence 2632*16dce513Schristos ((SI retaddr)) 2633*16dce513Schristos (set retaddr Ps) 2634*16dce513Schristos (reset-x-p) 2635*16dce513Schristos (delay 1 (set pc retaddr))) 2636*16dce513Schristos) 2637*16dce513Schristos 2638*16dce513Schristos; MOVE [Rs],Pd [ Pd | 10100011 | Rs ] 2639*16dce513Schristos; MOVE [Rs+],Pd [ Pd | 11100011 | Rs ] 2640*16dce513Schristos; We make variants that loads constants or memory for each MACH version, 2641*16dce513Schristos; since each consider some subset of the "special registers" to have 2642*16dce513Schristos; different sizes. FIXME: Should be able to simplify this. 2643*16dce513Schristos(.splice 2644*16dce513Schristos begin 2645*16dce513Schristos (.unsplice 2646*16dce513Schristos (.map 2647*16dce513Schristos (.pmacro 2648*16dce513Schristos (VER) 2649*16dce513Schristos (dni 2650*16dce513Schristos (.sym move-m-spr VER) 2651*16dce513Schristos "Move from memory to special register" 2652*16dce513Schristos ((MACH (.sym cris VER))) 2653*16dce513Schristos "move [${Rs}${inc}],${Pd}" 2654*16dce513Schristos (+ Pd INFIX_MOVE_M_S MODEMEMP_YES inc SIZE_FIXED Rs) 2655*16dce513Schristos (sequence 2656*16dce513Schristos ((SI rno) (SI newval)) 2657*16dce513Schristos (set rno (regno Pd)) 2658*16dce513Schristos (.splice 2659*16dce513Schristos cond 2660*16dce513Schristos ; No sanity check for constant special register here, since the 2661*16dce513Schristos ; memory read side-effect or post-increment may be the goal, or 2662*16dce513Schristos ; for pre-v32 a prefix assignment side-effect. 2663*16dce513Schristos (.unsplice 2664*16dce513Schristos (.map 2665*16dce513Schristos (.pmacro 2666*16dce513Schristos (r) 2667*16dce513Schristos ((eq rno (.cadr2 r)) 2668*16dce513Schristos (set newval ((.sym (.car2 r) -ext) (cris-get-mem (.car2 r) Rs))))) 2669*16dce513Schristos ((.sym cris-implemented-writable-specregs- VER)))) 2670*16dce513Schristos (else (error "Trying to set unimplemented special register"))) 2671*16dce513Schristos (set Pd newval) 2672*16dce513Schristos (reset-x-p)) 2673*16dce513Schristos (cris-mem-sr-timing))) 2674*16dce513Schristos (cris-cpu-models))) 2675*16dce513Schristos) 2676*16dce513Schristos 2677*16dce513Schristos(define-pmacro QI-operand sconst8) 2678*16dce513Schristos(define-pmacro HI-operand sconst16) 2679*16dce513Schristos(define-pmacro SI-operand const32) 2680*16dce513Schristos 2681*16dce513Schristos(define-pmacro 2682*16dce513Schristos (cris-move-c-spr VER VERFN) 2683*16dce513Schristos "Generator for loading constant into special register" 2684*16dce513Schristos (.splice 2685*16dce513Schristos begin 2686*16dce513Schristos (.unsplice 2687*16dce513Schristos (.map 2688*16dce513Schristos (.pmacro 2689*16dce513Schristos (srdef v) 2690*16dce513Schristos (dni 2691*16dce513Schristos (.sym move-c-spr v -p (.cadr2 srdef)) 2692*16dce513Schristos (.str "Move constant to special register p" (.cadr2 srdef)) 2693*16dce513Schristos ((MACH (.sym cris v))) 2694*16dce513Schristos (.str "move ${" (.sym (.car2 srdef) -operand) "},${Pd}") 2695*16dce513Schristos ; We use Pd in semantics without naming it in the format (which 2696*16dce513Schristos ; would CGEN-FIXME: cause a CGEN error for some reason, likely 2697*16dce513Schristos ; related to specifying an insn field multiple times). This 2698*16dce513Schristos ; currently works and is guarded with test-cases (specifically 2699*16dce513Schristos ; wrt. the timing model) but may need to be tweaked in the future. 2700*16dce513Schristos ; Note that using instead (ifield f-dest) causes incorrect timing 2701*16dce513Schristos ; model to be generated; the timing model requires that Pd is set. 2702*16dce513Schristos (+ (f-dest (.cadr2 srdef)) MODE_AUTOINCREMENT INFIX_MOVE_M_S SIZE_FIXED 2703*16dce513Schristos (f-source 15) (.sym (.car2 srdef) -operand)) 2704*16dce513Schristos (sequence 2705*16dce513Schristos () 2706*16dce513Schristos (set Pd (.sym (.car2 srdef) -operand)) ; (reg h-sr (.cadr2 srdef)) 2707*16dce513Schristos (reset-x-p)) 2708*16dce513Schristos ((.sym cris-timing-const-sr- (.car2 srdef))))) 2709*16dce513Schristos ((.sym cris-implemented-specregs-const- VER)) 2710*16dce513Schristos (.map VERFN ((.sym cris-implemented-specregs-const- VER)))))) 2711*16dce513Schristos) 2712*16dce513Schristos 2713*16dce513Schristos; CGEN-FIXME: 2714*16dce513Schristos; Unfortunately we can't iterate over the list of models due to the 2715*16dce513Schristos; problem with referring to the parameters of a surrounding pmacro from 2716*16dce513Schristos; within an enclosed .pmacro (perhaps related to "lexical scoping"). 2717*16dce513Schristos; We get e.g. 'insn already defined:: (move-c-sprvn-p0)' with this: 2718*16dce513Schristos;(.splice 2719*16dce513Schristos; begin (.unsplice (.map (.pmacro (vn) (cris-move-c-spr vn (.pmacro (x) vn))) 2720*16dce513Schristos; (cris-cpu-models))) 2721*16dce513Schristos;) 2722*16dce513Schristos(cris-move-c-spr v0 (.pmacro (x) v0)) 2723*16dce513Schristos(cris-move-c-spr v3 (.pmacro (x) v3)) 2724*16dce513Schristos(cris-move-c-spr v8 (.pmacro (x) v8)) 2725*16dce513Schristos(cris-move-c-spr v10 (.pmacro (x) v10)) 2726*16dce513Schristos(cris-move-c-spr v32 (.pmacro (x) v32)) 2727*16dce513Schristos 2728*16dce513Schristos; MOVE Ps,[Rd] [ Ps | 10100111 | Rd ] 2729*16dce513Schristos; MOVE Ps,[Rd+] [ Ps | 11100111 | Rd ] 2730*16dce513Schristos(.splice 2731*16dce513Schristos begin 2732*16dce513Schristos (.unsplice 2733*16dce513Schristos (.map 2734*16dce513Schristos (.pmacro 2735*16dce513Schristos (VER) 2736*16dce513Schristos (dni-cmwt-attr 2737*16dce513Schristos (.sym move-spr-m VER) 2738*16dce513Schristos "Move from special register to memory" 2739*16dce513Schristos ((MACH (.sym cris VER))) 2740*16dce513Schristos "move ${Ps},[${Rd-sfield}${inc}]" 2741*16dce513Schristos (+ INFIX_MOVE_S_M SIZE_FIXED Rd-sfield Ps) 2742*16dce513Schristos (sequence 2743*16dce513Schristos ((SI rno)) 2744*16dce513Schristos (set rno (regno Ps)) 2745*16dce513Schristos (.splice 2746*16dce513Schristos cond 2747*16dce513Schristos (.unsplice 2748*16dce513Schristos (.map 2749*16dce513Schristos (.pmacro 2750*16dce513Schristos (r) 2751*16dce513Schristos ((eq rno (.cadr2 r)) 2752*16dce513Schristos (cris-set-mem (.car2 r) Rd-sfield Ps))) 2753*16dce513Schristos ((.sym cris-implemented-readable-specregs- VER)))) 2754*16dce513Schristos (else (error "write from unimplemented special register"))) 2755*16dce513Schristos (reset-x-p)))) 2756*16dce513Schristos (cris-cpu-models))) 2757*16dce513Schristos) 2758*16dce513Schristos 2759*16dce513Schristos; SBFS [Rs(+)] 2760*16dce513Schristos; Instruction format: |0 0 1 1 1 m 1 1 0 1 1 1| Dest. | 2761*16dce513Schristos(dni-cdt-attr 2762*16dce513Schristos sbfs 2763*16dce513Schristos "sbfs" 2764*16dce513Schristos ((MACH crisv10)) 2765*16dce513Schristos "sbfs [${Rd-sfield}${inc}]" 2766*16dce513Schristos (+ (f-dest 3) INFIX_SBFS SIZE_FIXED MODEMEMP_YES inc Rd-sfield) 2767*16dce513Schristos (error "SBFS isn't implemented") 2768*16dce513Schristos) 2769*16dce513Schristos 2770*16dce513Schristos; MOVE Ss,Rd [ Ss | 11110111 | Rd ] 2771*16dce513Schristos(dni-cdt-attr 2772*16dce513Schristos move-ss-r 2773*16dce513Schristos "move from support register to general register" 2774*16dce513Schristos (MACH-V32) 2775*16dce513Schristos "move ${Ss},${Rd-sfield}" 2776*16dce513Schristos (+ Ss INFIX_MOVE_SS SIZE_FIXED (f-mode 3) Rd-sfield) 2777*16dce513Schristos (sequence 2778*16dce513Schristos () 2779*16dce513Schristos (set Rd-sfield Ss) 2780*16dce513Schristos (reset-x-p)) 2781*16dce513Schristos) 2782*16dce513Schristos 2783*16dce513Schristos; MOVE Rs,Sd [ Sd | 10110111 | Rs ] 2784*16dce513Schristos(dni-cdt-attr 2785*16dce513Schristos move-r-ss 2786*16dce513Schristos "move from general register to support register" 2787*16dce513Schristos (MACH-V32) 2788*16dce513Schristos "move ${Rs},${Sd}" 2789*16dce513Schristos (+ Sd INFIX_MOVE_SS SIZE_FIXED (f-mode 2) Rs) 2790*16dce513Schristos (sequence 2791*16dce513Schristos () 2792*16dce513Schristos (set Sd Rs) 2793*16dce513Schristos (reset-x-p)) 2794*16dce513Schristos) 2795*16dce513Schristos 2796*16dce513Schristos; MOVEM Rs,[Rd] [ Rs | 10111111 | Rd ] 2797*16dce513Schristos; MOVEM Rs,[Rd+] [ Rs | 11111111 | Rd ] 2798*16dce513Schristos 2799*16dce513Schristos(define-pmacro (movem-to-mem-step regn) 2800*16dce513Schristos ; Without the SI attribute, UINT is generated, which isn't supported by 2801*16dce513Schristos ; the sim framework. 2802*16dce513Schristos (if (ge SI (regno Rs-dfield) regn) 2803*16dce513Schristos (sequence 2804*16dce513Schristos ((SI tmp)) 2805*16dce513Schristos (set tmp (reg h-gr regn)) 2806*16dce513Schristos (set (mem SI addr) tmp) 2807*16dce513Schristos (set addr (add addr 4)))) 2808*16dce513Schristos) 2809*16dce513Schristos 2810*16dce513Schristos(dni 2811*16dce513Schristos movem-r-m 2812*16dce513Schristos "movem to memory" 2813*16dce513Schristos (MACH-PRE-V32) 2814*16dce513Schristos "movem ${Rs-dfield},[${Rd-sfield}${inc}]" 2815*16dce513Schristos (+ INFIX_MOVEM_R_M MODEMEMP_YES inc SIZE_FIXED Rs-dfield Rd-sfield) 2816*16dce513Schristos (sequence 2817*16dce513Schristos ((SI addr) (BI postinc)) 2818*16dce513Schristos ; FIXME: A copy of what's in cris-get-mem. 2819*16dce513Schristos 2820*16dce513Schristos ; Cache the incrementness of the operand. 2821*16dce513Schristos (set postinc inc) 2822*16dce513Schristos 2823*16dce513Schristos ; CGEN-FIXME: Kludge to work around a CGEN bug: it doesn't see that 2824*16dce513Schristos ; Rs-dfield is used as an input, causing the timing model to be wrong. 2825*16dce513Schristos (sequence ((SI dummy)) (set dummy Rs-dfield)) 2826*16dce513Schristos 2827*16dce513Schristos ; Get the address from somewhere. If the insn was prefixed, it's in 2828*16dce513Schristos ; the prefix-register. 2829*16dce513Schristos (set addr 2830*16dce513Schristos (if SI (eq prefix-set 0) 2831*16dce513Schristos Rd-sfield 2832*16dce513Schristos prefixreg)) 2833*16dce513Schristos 2834*16dce513Schristos (.splice 2835*16dce513Schristos sequence () 2836*16dce513Schristos (.unsplice (.map movem-to-mem-step (.iota 16 15 -1)))) 2837*16dce513Schristos 2838*16dce513Schristos ; Update the source-register for post-increments. 2839*16dce513Schristos (if (ne postinc 0) 2840*16dce513Schristos (set Rd-sfield 2841*16dce513Schristos (if SI (eq prefix-set 0) addr prefixreg))) 2842*16dce513Schristos (reset-x-p)) 2843*16dce513Schristos (simplecris-movem-timing) 2844*16dce513Schristos) 2845*16dce513Schristos 2846*16dce513Schristos(dni 2847*16dce513Schristos movem-r-m-v32 2848*16dce513Schristos "movem to memory" 2849*16dce513Schristos (MACH-V32) 2850*16dce513Schristos "movem ${Rs-dfield},[${Rd-sfield}${inc}]" 2851*16dce513Schristos (+ INFIX_MOVEM_R_M MODEMEMP_YES inc SIZE_FIXED Rs-dfield Rd-sfield) 2852*16dce513Schristos (sequence 2853*16dce513Schristos ((SI addr) (BI postinc)) 2854*16dce513Schristos ; FIXME: Mostly a copy of what's in cris-get-mem. 2855*16dce513Schristos 2856*16dce513Schristos ; Cache the incrementness of the operand. 2857*16dce513Schristos (set postinc inc) 2858*16dce513Schristos 2859*16dce513Schristos ; CGEN-FIXME: See movem-r-m. 2860*16dce513Schristos (sequence ((SI dummy)) (set dummy Rs-dfield)) 2861*16dce513Schristos 2862*16dce513Schristos (set addr Rd-sfield) 2863*16dce513Schristos 2864*16dce513Schristos (.splice 2865*16dce513Schristos sequence () 2866*16dce513Schristos (.unsplice (.map movem-to-mem-step (.iota 16)))) 2867*16dce513Schristos 2868*16dce513Schristos ; Update the source-register for post-increments. 2869*16dce513Schristos (if (ne postinc 0) 2870*16dce513Schristos (set Rd-sfield addr)) 2871*16dce513Schristos (reset-x-p)) 2872*16dce513Schristos ; Unit u-mem must be specified before the u-movem-* for memory address 2873*16dce513Schristos ; register stall count to be right. 2874*16dce513Schristos ((crisv32 (unit u-mem) (unit u-movem-rtom) (unit u-exec-movem) 2875*16dce513Schristos (unit u-mem-w))) 2876*16dce513Schristos) 2877*16dce513Schristos 2878*16dce513Schristos; MOVEM [Rs],Rd [ Rd | 10111011 | Rs ] 2879*16dce513Schristos; MOVEM [Rs+],Rd [ Rd | 11111011 | Rs ] 2880*16dce513Schristos 2881*16dce513Schristos(define-pmacro 2882*16dce513Schristos (movem-to-reg-step regn) 2883*16dce513Schristos ; Without the SI attribute, UINT is generated, which isn't supported by 2884*16dce513Schristos ; the sim framework. 2885*16dce513Schristos (if (ge SI (regno Rd) regn) 2886*16dce513Schristos (sequence 2887*16dce513Schristos ((SI tmp)) 2888*16dce513Schristos (set tmp (mem SI addr)) 2889*16dce513Schristos (set (reg h-gr regn) tmp) 2890*16dce513Schristos (set addr (add addr 4)))) 2891*16dce513Schristos) 2892*16dce513Schristos 2893*16dce513Schristos(dni 2894*16dce513Schristos movem-m-r 2895*16dce513Schristos "movem to register" 2896*16dce513Schristos (MACH-PRE-V32) 2897*16dce513Schristos "movem [${Rs}${inc}],${Rd}" 2898*16dce513Schristos (+ Rd INFIX_MOVEM_M_R MODEMEMP_YES inc SIZE_FIXED Rs) 2899*16dce513Schristos (sequence 2900*16dce513Schristos ((SI addr) (BI postinc)) 2901*16dce513Schristos ; FIXME: Mostly a copy of what's in cris-get-mem. 2902*16dce513Schristos 2903*16dce513Schristos ; Cache the incrementness of the operand. 2904*16dce513Schristos (set postinc inc) 2905*16dce513Schristos 2906*16dce513Schristos ; Get the address from somewhere. If the insn was prefixed, it's in 2907*16dce513Schristos ; the prefix-register. 2908*16dce513Schristos (set addr 2909*16dce513Schristos (if SI (eq prefix-set 0) 2910*16dce513Schristos Rs 2911*16dce513Schristos prefixreg)) 2912*16dce513Schristos 2913*16dce513Schristos ; CGEN-FIXME: See movem-r-m. 2914*16dce513Schristos (sequence ((SI dummy)) (set dummy Rd)) 2915*16dce513Schristos 2916*16dce513Schristos (.splice 2917*16dce513Schristos sequence () 2918*16dce513Schristos ; The first movem step is left out because it can't happen; it's for 2919*16dce513Schristos ; PC destination. See the pattern below. 2920*16dce513Schristos (.unsplice (.map movem-to-reg-step (.iota 15 14 -1)))) 2921*16dce513Schristos 2922*16dce513Schristos ; Update the source-register for post-increments. 2923*16dce513Schristos ; FIXME: No postinc-prefixed for v0 IIRC. 2924*16dce513Schristos (if (ne postinc 0) 2925*16dce513Schristos (set Rs (if SI (eq prefix-set 0) addr prefixreg))) 2926*16dce513Schristos (reset-x-p)) 2927*16dce513Schristos (simplecris-movem-timing) 2928*16dce513Schristos) 2929*16dce513Schristos 2930*16dce513Schristos; (MOVEM [Rs],PC [ 1111 | 10111011 | Rs ]) 2931*16dce513Schristos; (MOVEM [Rs+],PC [ 1111 | 11111011 | Rs ]) 2932*16dce513Schristos; We have to special-case it for PC destination; used in longjump. 2933*16dce513Schristos; We shouldn't *have* to special-case it; the main reason is (FIXME:) 2934*16dce513Schristos; misgeneration of the simulator when the PC case is folded into the 2935*16dce513Schristos; generic PRE-V32 movem; possibly related to then being a COND-CTI rather 2936*16dce513Schristos; than an UNCOND-CTI. 2937*16dce513Schristos(dni-cmt-attr 2938*16dce513Schristos movem-m-pc 2939*16dce513Schristos "movem to register, ending with PC" 2940*16dce513Schristos (MACH-PRE-V32) 2941*16dce513Schristos "movem [${Rs}${inc}],${Rd}" 2942*16dce513Schristos (+ (f-dest 15) INFIX_MOVEM_M_R SIZE_FIXED Rs) 2943*16dce513Schristos (sequence 2944*16dce513Schristos ((SI addr) (BI postinc)) 2945*16dce513Schristos ; FIXME: Mostly a copy of what's in cris-get-mem. 2946*16dce513Schristos 2947*16dce513Schristos ; Cache the incrementness of the operand. 2948*16dce513Schristos (set postinc inc) 2949*16dce513Schristos 2950*16dce513Schristos ; Get the address from somewhere. If the insn was prefixed, it's in 2951*16dce513Schristos ; the prefix-register. 2952*16dce513Schristos (set addr 2953*16dce513Schristos (if SI (eq prefix-set 0) 2954*16dce513Schristos Rs 2955*16dce513Schristos prefixreg)) 2956*16dce513Schristos 2957*16dce513Schristos ; FIXME: Add kludge here too *and* a test-case. 2958*16dce513Schristos 2959*16dce513Schristos (.splice 2960*16dce513Schristos sequence () 2961*16dce513Schristos ; The first movem step is for PC destination, used in longjmp. 2962*16dce513Schristos (set pc (mem SI addr)) 2963*16dce513Schristos (set addr (add addr 4)) 2964*16dce513Schristos (.unsplice 2965*16dce513Schristos (.map 2966*16dce513Schristos (.pmacro 2967*16dce513Schristos (regn) 2968*16dce513Schristos (sequence 2969*16dce513Schristos ((SI tmp)) 2970*16dce513Schristos (set tmp (mem SI addr)) 2971*16dce513Schristos (set (reg h-gr regn) tmp) 2972*16dce513Schristos (set addr (add addr 4)))) 2973*16dce513Schristos (.iota 15 14 -1)))) 2974*16dce513Schristos 2975*16dce513Schristos ; Update the source-register for post-increments. 2976*16dce513Schristos ; FIXME: No postinc-prefixed for v0. 2977*16dce513Schristos (if (ne postinc 0) 2978*16dce513Schristos (set Rs (if SI (eq prefix-set 0) addr prefixreg))) 2979*16dce513Schristos (reset-x-p)) 2980*16dce513Schristos) 2981*16dce513Schristos 2982*16dce513Schristos(dni 2983*16dce513Schristos movem-m-r-v32 2984*16dce513Schristos "movem to register" 2985*16dce513Schristos (MACH-V32) 2986*16dce513Schristos "movem [${Rs}${inc}],${Rd}" 2987*16dce513Schristos (+ INFIX_MOVEM_M_R MODEMEMP_YES inc SIZE_FIXED Rs Rd) 2988*16dce513Schristos (sequence 2989*16dce513Schristos ((SI addr) (BI postinc)) 2990*16dce513Schristos ; FIXME: A copy of what's in cris-get-mem 2991*16dce513Schristos 2992*16dce513Schristos ; Cache the incrementness of the operand. 2993*16dce513Schristos (set postinc inc) 2994*16dce513Schristos 2995*16dce513Schristos ; Get the address from somewhere. 2996*16dce513Schristos (set addr Rs) 2997*16dce513Schristos 2998*16dce513Schristos ; CGEN-FIXME: See movem-r-m. 2999*16dce513Schristos (sequence ((SI dummy)) (set dummy Rd)) 3000*16dce513Schristos 3001*16dce513Schristos (.splice 3002*16dce513Schristos sequence () 3003*16dce513Schristos (.unsplice (.map movem-to-reg-step (.iota 16)))) 3004*16dce513Schristos 3005*16dce513Schristos ; Update the source-register for post-increments. 3006*16dce513Schristos ; FIXME: No postinc-prefixed for v0 IIRC. 3007*16dce513Schristos (if (ne postinc 0) 3008*16dce513Schristos (set Rs addr)) 3009*16dce513Schristos (reset-x-p)) 3010*16dce513Schristos ; u-mem must be specified before the u-movem-* for memory source 3011*16dce513Schristos ; register stall count to be right. 3012*16dce513Schristos ((crisv32 (unit u-mem) (unit u-mem-r) (unit u-movem-mtor) 3013*16dce513Schristos (unit u-exec-movem))) 3014*16dce513Schristos) 3015*16dce513Schristos 3016*16dce513Schristos; ADD.m Rs,Rd [ Rd | 011000mm | Rs ] 3017*16dce513Schristos(dni-cdt-bwd 3018*16dce513Schristos add "add from register to register" 3019*16dce513Schristos "$Rs,$Rd" 3020*16dce513Schristos (+ Rd MODE_REGISTER R_ADD Rs) 3021*16dce513Schristos (.pmacro (BWD) (cris-arit add BWD Rd Rs)) 3022*16dce513Schristos) 3023*16dce513Schristos 3024*16dce513Schristos; ADD.m [Rs],Rd [ Rd | 101000mm | Rs ] 3025*16dce513Schristos; ADD.m [Rs+],Rd [ Rd | 111000mm | Rs ] 3026*16dce513Schristos(dni-cmt-bwd 3027*16dce513Schristos add-m "add from memory to register" 3028*16dce513Schristos "[${Rs}${inc}],${Rd}" 3029*16dce513Schristos (+ INDIR_ADD Rs Rd) 3030*16dce513Schristos (.pmacro (BWD) (cris-arit-3op add BWD Rd (cris-get-mem BWD Rs) Rs)) 3031*16dce513Schristos) 3032*16dce513Schristos; (ADD.m [PC+],Rd [ Rd | 111000mm | 1111 ]) 3033*16dce513Schristos(dni-c-QI 3034*16dce513Schristos addcbr "add constant byte to register" 3035*16dce513Schristos "add.b ${sconst8}],${Rd}" 3036*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADD SIZE_BYTE (f-source 15) sconst8) 3037*16dce513Schristos (cris-arit add QI Rd sconst8) 3038*16dce513Schristos) 3039*16dce513Schristos 3040*16dce513Schristos(dni-c-HI 3041*16dce513Schristos addcwr "add constant word to register" 3042*16dce513Schristos "add.w ${sconst16}],${Rd}" 3043*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADD SIZE_WORD (f-source 15) sconst16) 3044*16dce513Schristos (cris-arit add HI Rd sconst16) 3045*16dce513Schristos) 3046*16dce513Schristos 3047*16dce513Schristos(dni-c-SI 3048*16dce513Schristos addcdr "add constant dword to register" 3049*16dce513Schristos "add.d ${const32}],${Rd}" 3050*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADD SIZE_DWORD (f-source 15) const32) 3051*16dce513Schristos (cris-arit add SI Rd const32) 3052*16dce513Schristos) 3053*16dce513Schristos 3054*16dce513Schristos; (ADD.D [PC+],PC [ 1111 | 11100010 | 1111 ]) 3055*16dce513Schristos; This insn is used for DSO-local jumps in PIC code. 3056*16dce513Schristos(dni 3057*16dce513Schristos addcpc "Relative jump by adding constant to PC" 3058*16dce513Schristos (MACH-PC) 3059*16dce513Schristos "add.d ${sconst32},PC" 3060*16dce513Schristos (+ (f-dest 15) MODE_AUTOINCREMENT INDIR_ADD SIZE_DWORD (f-source 15) const32) 3061*16dce513Schristos (sequence 3062*16dce513Schristos ((SI newpc) (SI oldpc) (SI offs)) 3063*16dce513Schristos (set offs const32) 3064*16dce513Schristos (set oldpc (add SI pc 6)) 3065*16dce513Schristos (set newpc (add SI oldpc offs)) 3066*16dce513Schristos (set pc newpc) 3067*16dce513Schristos (setf-arit SI add oldpc offs newpc cbit)) 3068*16dce513Schristos (simplecris-common-timing ((unit u-const32) (unit u-stall) (unit u-exec))) 3069*16dce513Schristos) 3070*16dce513Schristos 3071*16dce513Schristos; ADDS.z Rs,Rd [ Rd | 0100001z | Rs ] 3072*16dce513Schristos(dni-cdt-sbw 3073*16dce513Schristos adds "add sign-extended from register to register" 3074*16dce513Schristos "$Rs,$Rd" 3075*16dce513Schristos (+ Rd MODE_REGISTER R_ADDX Rs) 3076*16dce513Schristos (.pmacro (BW) (cris-arit add SI Rd ((.sym BW -ext) (trunc BW Rs)))) 3077*16dce513Schristos) 3078*16dce513Schristos 3079*16dce513Schristos; ADDS.z [Rs],Rd [ Rd | 1000001z | Rs ] 3080*16dce513Schristos; ADDS.z [Rs+],Rd [ Rd | 1100001z | Rs ] 3081*16dce513Schristos(dni-cmt-sbw 3082*16dce513Schristos adds-m "add sign-extended from memory to register" 3083*16dce513Schristos "[${Rs}${inc}],$Rd" 3084*16dce513Schristos (+ Rd INDIR_ADDX Rs) 3085*16dce513Schristos (.pmacro (BW) (cris-arit-3op add SI Rd ((.sym BW -ext) (cris-get-mem BW Rs)) Rs)) 3086*16dce513Schristos) 3087*16dce513Schristos 3088*16dce513Schristos; (ADDS.z [PC+],Rd [ Rd | 1100001z | 1111 ]) 3089*16dce513Schristos(dni-c-QI 3090*16dce513Schristos addscbr "add sign-extended constant byte to register" 3091*16dce513Schristos "[${Rs}${inc}],$Rd" 3092*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADDX SIGNED_BYTE (f-source 15) sconst8) 3093*16dce513Schristos (cris-arit add SI Rd (ext SI (trunc QI sconst8))) 3094*16dce513Schristos) 3095*16dce513Schristos(dni-c-HI 3096*16dce513Schristos addscwr "add sign-extended constant word to register" 3097*16dce513Schristos "[${Rs}${inc}],$Rd" 3098*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADDX SIGNED_WORD (f-source 15) sconst16) 3099*16dce513Schristos (cris-arit add SI Rd (ext SI (trunc HI sconst16))) 3100*16dce513Schristos) 3101*16dce513Schristos 3102*16dce513Schristos; (ADDS.w [],PC [ 1111 | 10000011 | 1111 ]) 3103*16dce513Schristos; For a PC destination, we support only the two-operand case 3104*16dce513Schristos; (dest == src), which is used in switch/case statements. 3105*16dce513Schristos; FIXME: Should implement ADD.D [PC],PC and ADDS.B [PC],PC for use if/when 3106*16dce513Schristos; implementing CASE_VECTOR_SHORTEN_MODE. 3107*16dce513Schristos(dni 3108*16dce513Schristos addspcpc "add sign-extended prefixed arg to PC" 3109*16dce513Schristos (MACH-PC) 3110*16dce513Schristos "adds.w [PC],PC" 3111*16dce513Schristos (+ (f-dest 15) MODE_INDIRECT INDIR_ADDX SIGNED_WORD (f-source 15)) 3112*16dce513Schristos (sequence 3113*16dce513Schristos ((SI newpc) (SI oldpc) (HI offs)) 3114*16dce513Schristos (if (not prefix-set) 3115*16dce513Schristos (error "Unexpected adds.w [PC],PC without prefix")) 3116*16dce513Schristos ; We don't use cris-get-mem but instead special-case this one, since we 3117*16dce513Schristos ; have most instruction fields fixed where cris-get-mem expects 3118*16dce513Schristos ; field-parametrization by certain names. 3119*16dce513Schristos (set offs (mem HI prefixreg)) 3120*16dce513Schristos (set oldpc (add SI pc 2)) 3121*16dce513Schristos (set newpc (add SI oldpc offs)) 3122*16dce513Schristos (set pc newpc) 3123*16dce513Schristos (setf-arit SI add oldpc (ext SI offs) newpc cbit)) 3124*16dce513Schristos (simplecris-common-timing ((unit u-mem) (unit u-stall) (unit u-exec))) 3125*16dce513Schristos) 3126*16dce513Schristos 3127*16dce513Schristos; ADDU.z Rs,Rd [ Rd | 0100000z | Rs ] 3128*16dce513Schristos(dni-cdt-ubw 3129*16dce513Schristos addu "add zero-extended from register to register" 3130*16dce513Schristos "$Rs,$Rd" 3131*16dce513Schristos (+ Rd MODE_REGISTER R_ADDX Rs) 3132*16dce513Schristos (.pmacro (BW) (cris-arit add SI Rd ((.sym BW -zext) (trunc BW Rs)))) 3133*16dce513Schristos) 3134*16dce513Schristos 3135*16dce513Schristos; ADDU.z [Rs],Rd [ Rd | 1000000z | Rs ] 3136*16dce513Schristos; ADDU.z [Rs+],Rd [ Rd | 1100000z | Rs ] 3137*16dce513Schristos(dni-cmt-ubw 3138*16dce513Schristos addu-m "add zero-extended from memory to register" 3139*16dce513Schristos "[${Rs}${inc}],$Rd" 3140*16dce513Schristos (+ Rd INDIR_ADDX Rs) 3141*16dce513Schristos (.pmacro (BW) 3142*16dce513Schristos (cris-arit-3op add SI Rd ((.sym BW -zext) (cris-get-mem BW Rs)) Rs)) 3143*16dce513Schristos) 3144*16dce513Schristos 3145*16dce513Schristos; (ADDU.z [PC+],Rd [ Rd | 1100000z | 1111 ]) 3146*16dce513Schristos(dni-c-QI 3147*16dce513Schristos adducbr "add zero-extended constant byte to register" 3148*16dce513Schristos "[${Rs}${inc}],$Rd" 3149*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADDX UNSIGNED_BYTE (f-source 15) sconst8) 3150*16dce513Schristos (cris-arit add SI Rd (zext SI (trunc QI sconst8))) 3151*16dce513Schristos) 3152*16dce513Schristos(dni-c-HI 3153*16dce513Schristos adducwr "add zero-extended constant word to register" 3154*16dce513Schristos "[${Rs}${inc}],$Rd" 3155*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADDX UNSIGNED_WORD (f-source 15) sconst16) 3156*16dce513Schristos (cris-arit add SI Rd (zext SI (trunc HI sconst16))) 3157*16dce513Schristos) 3158*16dce513Schristos 3159*16dce513Schristos; SUB.m Rs,Rd [ Rd | 011010mm | Rs ] 3160*16dce513Schristos(dni-cdt-bwd 3161*16dce513Schristos sub "subtract from register to register" 3162*16dce513Schristos "$Rs,$Rd" 3163*16dce513Schristos (+ Rd MODE_REGISTER R_SUB Rs) 3164*16dce513Schristos (.pmacro (BWD) (cris-arit sub BWD Rd Rs)) 3165*16dce513Schristos) 3166*16dce513Schristos 3167*16dce513Schristos; SUB.m [Rs],Rd [ Rd | 101010mm | Rs ] 3168*16dce513Schristos; SUB.m [Rs+],Rd [ Rd | 111010mm | Rs ] 3169*16dce513Schristos(dni-cmt-bwd 3170*16dce513Schristos sub-m "subtract from memory to register" 3171*16dce513Schristos "[${Rs}${inc}],${Rd}" 3172*16dce513Schristos (+ INDIR_SUB Rs Rd) 3173*16dce513Schristos (.pmacro (BWD) (cris-arit-3op sub BWD Rd (cris-get-mem BWD Rs) Rs)) 3174*16dce513Schristos) 3175*16dce513Schristos 3176*16dce513Schristos; (SUB.m [PC+],Rd [ Rd | 111010mm | 1111 ] 3177*16dce513Schristos(dni-c-QI 3178*16dce513Schristos subcbr "subtract constant byte from register" 3179*16dce513Schristos "sub.b ${sconst8}],${Rd}" 3180*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_SUB SIZE_BYTE (f-source 15) sconst8) 3181*16dce513Schristos (cris-arit sub QI Rd sconst8) 3182*16dce513Schristos) 3183*16dce513Schristos 3184*16dce513Schristos(dni-c-HI 3185*16dce513Schristos subcwr "subtract constant word from register" 3186*16dce513Schristos "sub.w ${sconst16}],${Rd}" 3187*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_SUB SIZE_WORD (f-source 15) sconst16) 3188*16dce513Schristos (cris-arit sub HI Rd sconst16) 3189*16dce513Schristos) 3190*16dce513Schristos 3191*16dce513Schristos(dni-c-SI 3192*16dce513Schristos subcdr "subtract constant dword from register" 3193*16dce513Schristos "sub.d ${const32}],${Rd}" 3194*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_SUB SIZE_DWORD (f-source 15) const32) 3195*16dce513Schristos (cris-arit sub SI Rd const32) 3196*16dce513Schristos) 3197*16dce513Schristos 3198*16dce513Schristos; SUBS.z Rs,Rd [ Rd | 0100101z | Rs ] 3199*16dce513Schristos(dni-cdt-sbw 3200*16dce513Schristos subs "sub sign-extended from register to register" 3201*16dce513Schristos "$Rs,$Rd" 3202*16dce513Schristos (+ Rd MODE_REGISTER R_SUBX Rs) 3203*16dce513Schristos (.pmacro (BW) (cris-arit sub SI Rd ((.sym BW -ext) (trunc BW Rs)))) 3204*16dce513Schristos) 3205*16dce513Schristos 3206*16dce513Schristos; SUBS.z [Rs],Rd [ Rd | 1000101z | Rs ] 3207*16dce513Schristos; SUBS.z [Rs+],Rd [ Rd | 1100101z | Rs ] 3208*16dce513Schristos(dni-cmt-sbw 3209*16dce513Schristos subs-m "sub sign-extended from memory to register" 3210*16dce513Schristos "[${Rs}${inc}],$Rd" 3211*16dce513Schristos (+ Rd INDIR_SUBX Rs) 3212*16dce513Schristos (.pmacro (BW) 3213*16dce513Schristos (cris-arit-3op sub SI Rd ((.sym BW -ext) (cris-get-mem BW Rs)) Rs)) 3214*16dce513Schristos) 3215*16dce513Schristos 3216*16dce513Schristos; (SUBS.z [PC+],Rd [ Rd | 1100101z | 1111 ]) 3217*16dce513Schristos(dni-c-QI 3218*16dce513Schristos subscbr "sub sign-extended constant byte to register" 3219*16dce513Schristos "[${Rs}${inc}],$Rd" 3220*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_SUBX SIGNED_BYTE (f-source 15) sconst8) 3221*16dce513Schristos (cris-arit sub SI Rd (ext SI (trunc QI sconst8))) 3222*16dce513Schristos) 3223*16dce513Schristos(dni-c-HI 3224*16dce513Schristos subscwr "sub sign-extended constant word to register" 3225*16dce513Schristos "[${Rs}${inc}],$Rd" 3226*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_SUBX SIGNED_WORD (f-source 15) sconst16) 3227*16dce513Schristos (cris-arit sub SI Rd (ext SI (trunc HI sconst16))) 3228*16dce513Schristos) 3229*16dce513Schristos 3230*16dce513Schristos; SUBU.z Rs,Rd [ Rd | 0100100z | Rs ] 3231*16dce513Schristos(dni-cdt-ubw 3232*16dce513Schristos subu "sub zero-extended from register to register" 3233*16dce513Schristos "$Rs,$Rd" 3234*16dce513Schristos (+ Rd MODE_REGISTER R_SUBX Rs) 3235*16dce513Schristos (.pmacro (BW) (cris-arit sub SI Rd ((.sym BW -zext) (trunc BW Rs)))) 3236*16dce513Schristos) 3237*16dce513Schristos 3238*16dce513Schristos; SUBU.z [Rs],Rd [ Rd | 1000100z | Rs ] 3239*16dce513Schristos; SUBU.z [Rs+],Rd [ Rd | 1100100z | Rs ] 3240*16dce513Schristos(dni-cmt-ubw 3241*16dce513Schristos subu-m "sub zero-extended from memory to register" 3242*16dce513Schristos "[${Rs}${inc}],$Rd" 3243*16dce513Schristos (+ Rd INDIR_SUBX Rs) 3244*16dce513Schristos (.pmacro (BW) 3245*16dce513Schristos (cris-arit-3op sub SI Rd ((.sym BW -zext) (cris-get-mem BW Rs)) Rs)) 3246*16dce513Schristos) 3247*16dce513Schristos 3248*16dce513Schristos; (SUBU.z [PC+],Rd [ Rd | 1100100z | 1111 ]) 3249*16dce513Schristos(dni-c-QI 3250*16dce513Schristos subucbr "sub zero-extended constant byte to register" 3251*16dce513Schristos "[${Rs}${inc}],$Rd" 3252*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_SUBX UNSIGNED_BYTE (f-source 15) sconst8) 3253*16dce513Schristos (cris-arit sub SI Rd (zext SI (trunc QI sconst8))) 3254*16dce513Schristos) 3255*16dce513Schristos(dni-c-HI 3256*16dce513Schristos subucwr "sub zero-extended constant word to register" 3257*16dce513Schristos "[${Rs}${inc}],$Rd" 3258*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_SUBX UNSIGNED_WORD (f-source 15) sconst16) 3259*16dce513Schristos (cris-arit sub SI Rd (zext SI (trunc HI sconst16))) 3260*16dce513Schristos) 3261*16dce513Schristos 3262*16dce513Schristos; ADDC Rs,Rd [ Rd | 01010111 | Rs ] 3263*16dce513Schristos(dni-cdt-attr 3264*16dce513Schristos addc-r "addc from register to register" 3265*16dce513Schristos (MACH-V32) 3266*16dce513Schristos "addc $Rs,$Rd" 3267*16dce513Schristos (+ Rd MODE_REGISTER RFIX_ADDC SIZE_FIXED Rs) 3268*16dce513Schristos ; Since this is equivalent to "ax" plus "add.d Rs,Rd", we'll just do 3269*16dce513Schristos ; that, semantically. 3270*16dce513Schristos (sequence 3271*16dce513Schristos () 3272*16dce513Schristos (set-quiet xbit 1) 3273*16dce513Schristos (cris-arit add SI Rd Rs)) 3274*16dce513Schristos) 3275*16dce513Schristos 3276*16dce513Schristos; ADDC [Rs],Rd [ Rd | 10011010 | Rs ] 3277*16dce513Schristos; ADDC [Rs+],Rd [ Rd | 11011010 | Rs ] 3278*16dce513Schristos(dni-cmt-attr 3279*16dce513Schristos addc-m "addc from memory to register" 3280*16dce513Schristos (MACH-V32) 3281*16dce513Schristos "addc [${Rs}${inc}],${Rd}" 3282*16dce513Schristos (+ Rd INDIR_ADDC SIZE_DWORD Rs) 3283*16dce513Schristos (sequence 3284*16dce513Schristos () 3285*16dce513Schristos (set-quiet xbit 1) 3286*16dce513Schristos (cris-arit add SI Rd (cris-get-mem SI Rs))) 3287*16dce513Schristos) 3288*16dce513Schristos 3289*16dce513Schristos; (ADDC [Rs+],Rd [ Rd | 11011010 | 1111 ]) 3290*16dce513Schristos(dni-c-SI-attr 3291*16dce513Schristos addc-c "addc constant to register" 3292*16dce513Schristos (MACH-V32) 3293*16dce513Schristos "addc ${const32},${Rd}" 3294*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADDC SIZE_DWORD (f-source 15) const32) 3295*16dce513Schristos (sequence 3296*16dce513Schristos () 3297*16dce513Schristos (set-quiet xbit 1) 3298*16dce513Schristos (cris-arit add SI Rd const32)) 3299*16dce513Schristos) 3300*16dce513Schristos 3301*16dce513Schristos; LAPC [PC+],Rd [ Rd | 11010111 1111 ] 3302*16dce513Schristos(dni-c-SI-attr 3303*16dce513Schristos lapc-d "lapc.d" 3304*16dce513Schristos (MACH-V32) 3305*16dce513Schristos "lapc.d ${const32-pcrel},${Rd}" 3306*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INFIX_LAPC SIZE_FIXED (f-source 15) const32-pcrel) 3307*16dce513Schristos (sequence 3308*16dce513Schristos () 3309*16dce513Schristos (set Rd const32-pcrel) 3310*16dce513Schristos (reset-x-p)) 3311*16dce513Schristos) 3312*16dce513Schristos 3313*16dce513Schristos; LAPCQ qo,Rd [ Rd | 10010111 | qo ] 3314*16dce513Schristos(dni-cdt-attr 3315*16dce513Schristos lapcq "lapcq" 3316*16dce513Schristos (MACH-V32) 3317*16dce513Schristos "lapcq ${qo},${Rd}" 3318*16dce513Schristos (+ Rd MODE_INDIRECT INFIX_LAPC SIZE_FIXED qo) 3319*16dce513Schristos (sequence 3320*16dce513Schristos () 3321*16dce513Schristos (set Rd qo) 3322*16dce513Schristos (reset-x-p)) 3323*16dce513Schristos) 3324*16dce513Schristos 3325*16dce513Schristos; ADDI Rs.m,Rd [ Rs | 010100mm | Rd ] 3326*16dce513Schristos(dni-cdt-bwd 3327*16dce513Schristos addi "addi" 3328*16dce513Schristos "${Rs-dfield}.m,${Rd-sfield}" 3329*16dce513Schristos (+ Rd-sfield MODE_REGISTER R_ADDI Rs-dfield) 3330*16dce513Schristos (.pmacro 3331*16dce513Schristos (BWD) 3332*16dce513Schristos (sequence 3333*16dce513Schristos () 3334*16dce513Schristos (set Rd-sfield (add SI Rd-sfield (mul Rs-dfield (.sym BWD -size)))) 3335*16dce513Schristos (reset-x-p))) 3336*16dce513Schristos) 3337*16dce513Schristos 3338*16dce513Schristos; NEG.m Rs,Rd [ Rd | 010110mm | Rs ] 3339*16dce513Schristos(dni-cdt-bwd 3340*16dce513Schristos neg "neg.m Rs,Rd" 3341*16dce513Schristos "$Rs,$Rd" 3342*16dce513Schristos (+ Rd MODE_REGISTER R_NEG Rs) 3343*16dce513Schristos (.pmacro (BWD) (cris-arit3 sub BWD Rd 0 Rs)) 3344*16dce513Schristos) 3345*16dce513Schristos 3346*16dce513Schristos; TEST.m [Rs] [ 0000101110mm | Rs ] 3347*16dce513Schristos; TEST.m [Rs+] [ 0000111110mm | Rs ] 3348*16dce513Schristos(dni-cmt-bwd 3349*16dce513Schristos test-m "test.m [Rs(+)]" 3350*16dce513Schristos "[${Rs}${inc}]" 3351*16dce513Schristos (+ (f-dest 0) INDIR_TEST Rs) 3352*16dce513Schristos (.pmacro 3353*16dce513Schristos (BWD) 3354*16dce513Schristos (sequence 3355*16dce513Schristos ((BWD tmpd)) 3356*16dce513Schristos (set tmpd (cris-get-mem BWD Rs)) 3357*16dce513Schristos ; This is supposed to be the same result as for cmpq 0,X, hence same code. 3358*16dce513Schristos (cris-arit6-int 3359*16dce513Schristos sub BWD (.pmacro (sz regno val) (nop)) 0 tmpd 0 cbit cbit))) 3360*16dce513Schristos) 3361*16dce513Schristos 3362*16dce513Schristos; MOVE.m Rs,[Rd] [ Rs | 101111mm | Rd ] 3363*16dce513Schristos; MOVE.m Rs,[Rd+] [ Rs | 111111mm | Rd ] 3364*16dce513Schristos 3365*16dce513Schristos(dni-cmwt-bwd 3366*16dce513Schristos move-r-m "move.m R,[]" 3367*16dce513Schristos "${Rs-dfield},[${Rd-sfield}${inc}]" 3368*16dce513Schristos (+ Rs-dfield INDIR_MOVE_R_M Rd-sfield) 3369*16dce513Schristos (.pmacro 3370*16dce513Schristos (BWD) 3371*16dce513Schristos (sequence 3372*16dce513Schristos ((BWD tmpd)) 3373*16dce513Schristos (set tmpd Rs-dfield) 3374*16dce513Schristos (cris-set-mem BWD Rd-sfield tmpd) 3375*16dce513Schristos (reset-x-p))) 3376*16dce513Schristos) 3377*16dce513Schristos 3378*16dce513Schristos; MULS.m Rs,Rd [ Rd | 110100mm | Rs ] 3379*16dce513Schristos(dni-bwd-attr 3380*16dce513Schristos muls "muls.m Rs,Rd" 3381*16dce513Schristos ((MACH crisv10,crisv32)) 3382*16dce513Schristos "$Rs,$Rd" 3383*16dce513Schristos (+ Rd MODE_MULS INDIR_MUL Rs) 3384*16dce513Schristos (.pmacro 3385*16dce513Schristos (BWD) 3386*16dce513Schristos (sequence 3387*16dce513Schristos ((DI src1) (DI src2) (DI tmpr)) 3388*16dce513Schristos (set src1 (ext DI (trunc BWD Rs))) 3389*16dce513Schristos (set src2 (ext DI (trunc BWD Rd))) 3390*16dce513Schristos (set tmpr (mul src1 src2)) 3391*16dce513Schristos (set Rd (trunc SI tmpr)) 3392*16dce513Schristos (set mof (trunc SI (srl tmpr 32))) 3393*16dce513Schristos (setf-arit DI muls src1 src2 tmpr cbit))) 3394*16dce513Schristos ((crisv10 (unit u-multiply) (unit u-exec)) 3395*16dce513Schristos (crisv32 (unit u-multiply) (unit u-exec))) 3396*16dce513Schristos) 3397*16dce513Schristos 3398*16dce513Schristos; MULU.m Rs,Rd [ Rd | 100100mm | Rs ] 3399*16dce513Schristos(dni-bwd-attr 3400*16dce513Schristos mulu "mulu.m Rs,Rd" 3401*16dce513Schristos ((MACH crisv10,crisv32)) 3402*16dce513Schristos "$Rs,$Rd" 3403*16dce513Schristos (+ Rd MODE_MULU INDIR_MUL Rs) 3404*16dce513Schristos (.pmacro 3405*16dce513Schristos (BWD) 3406*16dce513Schristos (sequence 3407*16dce513Schristos ((DI src1) (DI src2) (DI tmpr)) 3408*16dce513Schristos (set src1 (zext DI (trunc BWD Rs))) 3409*16dce513Schristos (set src2 (zext DI (trunc BWD Rd))) 3410*16dce513Schristos (set tmpr (mul src1 src2)) 3411*16dce513Schristos (set Rd (trunc SI tmpr)) 3412*16dce513Schristos (set mof (trunc SI (srl tmpr 32))) 3413*16dce513Schristos (setf-arit DI mulu src1 src2 tmpr cbit))) 3414*16dce513Schristos ((crisv10 (unit u-multiply) (unit u-exec)) 3415*16dce513Schristos (crisv32 (unit u-multiply) (unit u-exec))) 3416*16dce513Schristos) 3417*16dce513Schristos 3418*16dce513Schristos; MCP Ps,Rd [ Ps | 01111111 | Rd ] 3419*16dce513Schristos(dni-cdt-attr 3420*16dce513Schristos mcp "Multiply Carry Propagation" 3421*16dce513Schristos (MACH-V32) 3422*16dce513Schristos "mcp $Ps,$Rd" 3423*16dce513Schristos (+ Ps MODE_REGISTER RFIX_MCP SIZE_FIXED Rd-sfield) 3424*16dce513Schristos (sequence 3425*16dce513Schristos () 3426*16dce513Schristos (set-quiet xbit 1) 3427*16dce513Schristos (set-quiet zbit 1) 3428*16dce513Schristos (cris-arit5 add SI Rd-sfield Rd-sfield Ps rbit rbit)) 3429*16dce513Schristos) 3430*16dce513Schristos 3431*16dce513Schristos; MSTEP Rs,Rd [ Rd | 01111111 | Rs ] 3432*16dce513Schristos(dni-cdt-attr 3433*16dce513Schristos mstep "Multiply step" 3434*16dce513Schristos (MACH-PRE-V32) 3435*16dce513Schristos "mstep $Rs,$Rd" 3436*16dce513Schristos (+ Rd MODE_REGISTER RFIX_MSTEP SIZE_FIXED Rs) 3437*16dce513Schristos (sequence 3438*16dce513Schristos ((SI tmpd) (SI tmps)) 3439*16dce513Schristos (set tmps Rs) 3440*16dce513Schristos (set tmpd (add (sll Rd 1) (if SI nbit tmps 0))) 3441*16dce513Schristos (set Rd tmpd) 3442*16dce513Schristos (setf-move SI tmpd)) 3443*16dce513Schristos) 3444*16dce513Schristos 3445*16dce513Schristos; DSTEP Rs,Rd [ Rd | 01101111 | Rs ] 3446*16dce513Schristos(dni-cdt 3447*16dce513Schristos dstep "Division step" 3448*16dce513Schristos "dstep $Rs,$Rd" 3449*16dce513Schristos (+ Rd MODE_REGISTER RFIX_DSTEP SIZE_FIXED Rs) 3450*16dce513Schristos (sequence 3451*16dce513Schristos ((SI tmp) (SI tmps) (SI tmpd)) 3452*16dce513Schristos (set tmps Rs) 3453*16dce513Schristos (set tmp (sll Rd 1)) 3454*16dce513Schristos (set tmpd (if SI (geu tmp tmps) (sub tmp tmps) tmp)) 3455*16dce513Schristos (set Rd tmpd) 3456*16dce513Schristos (setf-move SI tmpd)) 3457*16dce513Schristos) 3458*16dce513Schristos 3459*16dce513Schristos; ABS Rs,Rd [ Rd | 01101011 | Rs ] 3460*16dce513Schristos(dni-cdt 3461*16dce513Schristos abs "Absolut Instruction" 3462*16dce513Schristos "abs $Rs,$Rd" 3463*16dce513Schristos (+ Rd MODE_REGISTER RFIX_ABS SIZE_FIXED Rs) 3464*16dce513Schristos (sequence 3465*16dce513Schristos ((SI tmpd)) 3466*16dce513Schristos (set tmpd (abs Rs)) 3467*16dce513Schristos (set Rd tmpd) 3468*16dce513Schristos (setf-move SI tmpd)) 3469*16dce513Schristos) 3470*16dce513Schristos 3471*16dce513Schristos; AND.m Rs,Rd [ Rd | 011100mm | Rs ] 3472*16dce513Schristos(dni-cdt-bwd 3473*16dce513Schristos and "And from register to register" 3474*16dce513Schristos "$Rs,$Rd" 3475*16dce513Schristos (+ Rd MODE_REGISTER R_AND Rs) 3476*16dce513Schristos (.pmacro 3477*16dce513Schristos (BWD) 3478*16dce513Schristos (sequence 3479*16dce513Schristos ((BWD tmpd)) 3480*16dce513Schristos (set tmpd (and BWD Rd Rs)) 3481*16dce513Schristos (set-subreg-gr BWD (regno Rd) tmpd) 3482*16dce513Schristos (setf-move BWD tmpd))) 3483*16dce513Schristos) 3484*16dce513Schristos 3485*16dce513Schristos; AND.m [Rs],Rd [ Rd | 101100mm | Rs ] 3486*16dce513Schristos; AND.m [Rs+],Rd [ Rd | 111100mm | Rs ] 3487*16dce513Schristos(dni-cmt-bwd 3488*16dce513Schristos and-m "And from memory to register" 3489*16dce513Schristos "[${Rs}${inc}],${Rd}" 3490*16dce513Schristos (+ INDIR_AND Rs Rd) 3491*16dce513Schristos (.pmacro 3492*16dce513Schristos (BWD) 3493*16dce513Schristos (sequence 3494*16dce513Schristos ((BWD tmpd)) 3495*16dce513Schristos (set tmpd (and BWD Rd (cris-get-mem BWD Rs))) 3496*16dce513Schristos (set-subreg-gr 3497*16dce513Schristos BWD 3498*16dce513Schristos (if SI (andif prefix-set (not inc)) (regno Rs) (regno Rd)) 3499*16dce513Schristos tmpd) 3500*16dce513Schristos (setf-move BWD tmpd))) 3501*16dce513Schristos) 3502*16dce513Schristos 3503*16dce513Schristos; (AND.m [PC+],Rd [ Rd | 111100mm | 1111 ]) 3504*16dce513Schristos(dni-c-QI 3505*16dce513Schristos andcbr "And constant byte to register" 3506*16dce513Schristos "and.b ${sconst8}],${Rd}" 3507*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_AND SIZE_BYTE (f-source 15) sconst8) 3508*16dce513Schristos (sequence 3509*16dce513Schristos ((QI tmpd)) 3510*16dce513Schristos (set tmpd (and QI Rd sconst8)) 3511*16dce513Schristos (set-subreg-gr QI (regno Rd) tmpd) 3512*16dce513Schristos (setf-move QI tmpd)) 3513*16dce513Schristos) 3514*16dce513Schristos 3515*16dce513Schristos(dni-c-HI 3516*16dce513Schristos andcwr "And constant word to register" 3517*16dce513Schristos "and.w ${sconst16}],${Rd}" 3518*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_AND SIZE_WORD (f-source 15) sconst16) 3519*16dce513Schristos (sequence 3520*16dce513Schristos ((HI tmpd)) 3521*16dce513Schristos (set tmpd (and HI Rd sconst16)) 3522*16dce513Schristos (set-subreg-gr HI (regno Rd) tmpd) 3523*16dce513Schristos (setf-move HI tmpd)) 3524*16dce513Schristos) 3525*16dce513Schristos 3526*16dce513Schristos(dni-c-SI 3527*16dce513Schristos andcdr "And constant dword to register" 3528*16dce513Schristos "and.d ${const32}],${Rd}" 3529*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_AND SIZE_DWORD (f-source 15) const32) 3530*16dce513Schristos (sequence 3531*16dce513Schristos ((SI tmpd)) 3532*16dce513Schristos (set tmpd (and SI Rd const32)) 3533*16dce513Schristos (set-subreg-gr SI (regno Rd) tmpd) 3534*16dce513Schristos (setf-move SI tmpd)) 3535*16dce513Schristos) 3536*16dce513Schristos 3537*16dce513Schristos; ANDQ i,Rd [ Rd | 001100 | i ] 3538*16dce513Schristos(dni-cdt 3539*16dce513Schristos andq "And quick-immediate to register" 3540*16dce513Schristos "andq $i,$Rd" 3541*16dce513Schristos (+ Rd MODE_QUICK_IMMEDIATE Q_ANDQ i) 3542*16dce513Schristos (sequence 3543*16dce513Schristos ((SI tmpd)) 3544*16dce513Schristos (set tmpd (and SI Rd i)) 3545*16dce513Schristos (set-subreg-gr SI (regno Rd) tmpd) 3546*16dce513Schristos (setf-move SI tmpd)) 3547*16dce513Schristos) 3548*16dce513Schristos 3549*16dce513Schristos; OR.m Rs,Rd [ Rd | 011101mm | Rs ] 3550*16dce513Schristos(dni-cdt-bwd 3551*16dce513Schristos orr "Or from register to register" 3552*16dce513Schristos "$Rs,$Rd" 3553*16dce513Schristos (+ Rd MODE_REGISTER R_OR Rs) 3554*16dce513Schristos (.pmacro 3555*16dce513Schristos (BWD) 3556*16dce513Schristos (sequence 3557*16dce513Schristos ((BWD tmpd)) 3558*16dce513Schristos (set tmpd (or BWD Rd Rs)) 3559*16dce513Schristos (set-subreg-gr BWD (regno Rd) tmpd) 3560*16dce513Schristos (setf-move BWD tmpd))) 3561*16dce513Schristos) 3562*16dce513Schristos 3563*16dce513Schristos; OR.m [Rs],Rd [ Rd | 101101mm | Rs ] 3564*16dce513Schristos; OR.m [Rs+],Rd [ Rd | 111101mm | Rs ] 3565*16dce513Schristos(dni-cmt-bwd 3566*16dce513Schristos or-m "Or from memory to register" 3567*16dce513Schristos "[${Rs}${inc}],${Rd}" 3568*16dce513Schristos (+ INDIR_OR Rs Rd) 3569*16dce513Schristos (.pmacro 3570*16dce513Schristos (BWD) 3571*16dce513Schristos (sequence 3572*16dce513Schristos ((BWD tmpd)) 3573*16dce513Schristos (set tmpd (or BWD Rd (cris-get-mem BWD Rs))) 3574*16dce513Schristos (set-subreg-gr 3575*16dce513Schristos BWD 3576*16dce513Schristos (if SI (andif prefix-set (not inc)) (regno Rs) (regno Rd)) 3577*16dce513Schristos tmpd) 3578*16dce513Schristos (setf-move BWD tmpd))) 3579*16dce513Schristos) 3580*16dce513Schristos 3581*16dce513Schristos; (OR.m [PC+],Rd [ Rd | 111101mm | 1111 ]) 3582*16dce513Schristos(dni-c-QI 3583*16dce513Schristos orcbr "Or constant byte to register" 3584*16dce513Schristos "or.b ${sconst8}],${Rd}" 3585*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_OR SIZE_BYTE (f-source 15) sconst8) 3586*16dce513Schristos (sequence 3587*16dce513Schristos ((QI tmpd)) 3588*16dce513Schristos (set tmpd (or QI Rd sconst8)) 3589*16dce513Schristos (set-subreg-gr QI (regno Rd) tmpd) 3590*16dce513Schristos (setf-move QI tmpd)) 3591*16dce513Schristos) 3592*16dce513Schristos 3593*16dce513Schristos(dni-c-HI 3594*16dce513Schristos orcwr "Or constant word to register" 3595*16dce513Schristos "or.w ${sconst16}],${Rd}" 3596*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_OR SIZE_WORD (f-source 15) sconst16) 3597*16dce513Schristos (sequence 3598*16dce513Schristos ((HI tmpd)) 3599*16dce513Schristos (set tmpd (or HI Rd sconst16)) 3600*16dce513Schristos (set-subreg-gr HI (regno Rd) tmpd) 3601*16dce513Schristos (setf-move HI tmpd)) 3602*16dce513Schristos) 3603*16dce513Schristos 3604*16dce513Schristos(dni-c-SI 3605*16dce513Schristos orcdr "Or constant dword to register" 3606*16dce513Schristos "or.d ${const32}],${Rd}" 3607*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_OR SIZE_DWORD (f-source 15) const32) 3608*16dce513Schristos (sequence 3609*16dce513Schristos ((SI tmpd)) 3610*16dce513Schristos (set tmpd (or SI Rd const32)) 3611*16dce513Schristos (set-subreg-gr SI (regno Rd) tmpd) 3612*16dce513Schristos (setf-move SI tmpd)) 3613*16dce513Schristos) 3614*16dce513Schristos 3615*16dce513Schristos; ORQ i,Rd [ Rd | 001101 | i ] 3616*16dce513Schristos(dni-cdt 3617*16dce513Schristos orq "Or quick-immediate to register" 3618*16dce513Schristos "orq $i,$Rd" 3619*16dce513Schristos (+ Rd MODE_QUICK_IMMEDIATE Q_ORQ i) 3620*16dce513Schristos (sequence 3621*16dce513Schristos ((SI tmpd)) 3622*16dce513Schristos (set tmpd (or SI Rd i)) 3623*16dce513Schristos (set-subreg-gr SI (regno Rd) tmpd) 3624*16dce513Schristos (setf-move SI tmpd)) 3625*16dce513Schristos) 3626*16dce513Schristos 3627*16dce513Schristos; XOR Rs,Rd [ Rd | 01111011 | Rs ] 3628*16dce513Schristos(dni-cdt 3629*16dce513Schristos xor "Xor from register to register" 3630*16dce513Schristos "xor $Rs,$Rd" 3631*16dce513Schristos (+ Rd MODE_REGISTER RFIX_XOR SIZE_FIXED Rs) 3632*16dce513Schristos (sequence 3633*16dce513Schristos ((SI tmpd)) 3634*16dce513Schristos (set tmpd (xor SI Rd Rs)) 3635*16dce513Schristos (set Rd tmpd) 3636*16dce513Schristos (setf-move SI tmpd)) 3637*16dce513Schristos) 3638*16dce513Schristos 3639*16dce513Schristos(define-pmacro (swap-r x) 3640*16dce513Schristos "Perform bit-wise swap within each byte" 3641*16dce513Schristos (sequence 3642*16dce513Schristos SI 3643*16dce513Schristos ((SI tmpr)) 3644*16dce513Schristos (set tmpr x) 3645*16dce513Schristos (or (sll (and tmpr #x1010101) 7) 3646*16dce513Schristos (or (sll (and tmpr #x2020202) 5) 3647*16dce513Schristos (or (sll (and tmpr #x4040404) 3) 3648*16dce513Schristos (or (sll (and tmpr #x8080808) 1) 3649*16dce513Schristos (or (srl (and tmpr #x10101010) 1) 3650*16dce513Schristos (or (srl (and tmpr #x20202020) 3) 3651*16dce513Schristos (or (srl (and tmpr #x40404040) 5) 3652*16dce513Schristos (srl (and tmpr #x80808080) 7))))))))) 3653*16dce513Schristos) 3654*16dce513Schristos 3655*16dce513Schristos(define-pmacro (swap-b x) 3656*16dce513Schristos "Perform byte-wise swap within each word" 3657*16dce513Schristos (sequence 3658*16dce513Schristos SI 3659*16dce513Schristos ((SI tmpb)) 3660*16dce513Schristos (set tmpb x) 3661*16dce513Schristos (or (and (sll tmpb 8) #xff00ff00) 3662*16dce513Schristos (and (srl tmpb 8) #xff00ff))) 3663*16dce513Schristos) 3664*16dce513Schristos 3665*16dce513Schristos(define-pmacro (swap-w x) 3666*16dce513Schristos "Perform word-wise swap within each dword" 3667*16dce513Schristos (sequence 3668*16dce513Schristos SI 3669*16dce513Schristos ((SI tmpb)) 3670*16dce513Schristos (set tmpb x) 3671*16dce513Schristos (or (and (sll tmpb 16) #xffff0000) 3672*16dce513Schristos (and (srl tmpb 16) #xffff))) 3673*16dce513Schristos) 3674*16dce513Schristos 3675*16dce513Schristos(define-pmacro (swap-_ x) 3676*16dce513Schristos "Do nothing swap-wise" 3677*16dce513Schristos (error SI "SWAP without swap modifier isn't implemented") 3678*16dce513Schristos) 3679*16dce513Schristos 3680*16dce513Schristos(define-pmacro (swap-n x) 3681*16dce513Schristos "Perform bitwise not (that is, perform a not, not not perform)" 3682*16dce513Schristos (inv x) 3683*16dce513Schristos) 3684*16dce513Schristos 3685*16dce513Schristos(define-pmacro (swap-br x) "Combine swap-r and swap-b" (swap-r (swap-b x))) 3686*16dce513Schristos(define-pmacro (swap-wr x) "Combine swap-r and swap-w" (swap-r (swap-w x))) 3687*16dce513Schristos(define-pmacro (swap-wb x) "Combine swap-b and swap-w" (swap-b (swap-w x))) 3688*16dce513Schristos(define-pmacro (swap-wbr x) "Combine swap-r and swap-wb" (swap-r (swap-wb x))) 3689*16dce513Schristos(define-pmacro (swap-nr x) "Combine swap-r and swap-n" (swap-r (swap-n x))) 3690*16dce513Schristos(define-pmacro (swap-nb x) "Combine swap-n and swap-b" (swap-b (swap-n x))) 3691*16dce513Schristos(define-pmacro (swap-nbr x) "Combine swap-r and swap-nb" (swap-r (swap-nb x))) 3692*16dce513Schristos(define-pmacro (swap-nw x) "Combine swap-n and swap-w" (swap-w (swap-n x))) 3693*16dce513Schristos(define-pmacro (swap-nwr x) "Combine swap-r and swap-nw" (swap-r (swap-nw x))) 3694*16dce513Schristos(define-pmacro (swap-nwb x) "Combine swap-b and swap-nw" (swap-b (swap-nw x))) 3695*16dce513Schristos(define-pmacro (swap-nwbr x) "Combine swap-r and swap-nwb" (swap-r (swap-nwb x))) 3696*16dce513Schristos 3697*16dce513Schristos(define-pmacro (cris-swap swapcode val) 3698*16dce513Schristos (sequence 3699*16dce513Schristos SI 3700*16dce513Schristos ((SI tmpcode) (SI tmpval) (SI tmpres)) 3701*16dce513Schristos (set tmpcode swapcode) 3702*16dce513Schristos (set tmpval val) 3703*16dce513Schristos (.splice 3704*16dce513Schristos cond 3705*16dce513Schristos (.unsplice 3706*16dce513Schristos (.map 3707*16dce513Schristos (.pmacro 3708*16dce513Schristos (x-swapcode x-swap) 3709*16dce513Schristos ((eq tmpcode x-swapcode) 3710*16dce513Schristos (set tmpres ((.sym swap- x-swap) tmpval)))) 3711*16dce513Schristos (.iota 16) 3712*16dce513Schristos (.splice _ (.unsplice cris-swap-codes))))) 3713*16dce513Schristos tmpres) 3714*16dce513Schristos) 3715*16dce513Schristos 3716*16dce513Schristos; NOT Rd alias for SWAPN Rd 3717*16dce513Schristos(dni-cdt-attr 3718*16dce513Schristos not "Not" 3719*16dce513Schristos ((MACH crisv0,crisv3)) 3720*16dce513Schristos "not ${Rs}" 3721*16dce513Schristos (+ (f-dest 8) RFIX_SWAP MODE_REGISTER SIZE_FIXED Rd-sfield) 3722*16dce513Schristos (sequence 3723*16dce513Schristos ((SI tmp) (SI tmpd)) 3724*16dce513Schristos (set tmp Rd-sfield) 3725*16dce513Schristos (set tmpd (cris-swap 8 tmp)) 3726*16dce513Schristos (set Rd-sfield tmpd) 3727*16dce513Schristos (setf-move SI tmpd)) 3728*16dce513Schristos) 3729*16dce513Schristos 3730*16dce513Schristos; SWAP<option> Rd [ N W B R | 01110111 | Rd ] 3731*16dce513Schristos(dni-cdt-attr 3732*16dce513Schristos swap "Swap" 3733*16dce513Schristos ((MACH crisv8,crisv10,crisv32)) 3734*16dce513Schristos "swap${swapoption} ${Rs}" 3735*16dce513Schristos (+ swapoption RFIX_SWAP MODE_REGISTER SIZE_FIXED Rd-sfield) 3736*16dce513Schristos (sequence 3737*16dce513Schristos ((SI tmps) (SI tmpd)) 3738*16dce513Schristos (set tmps Rd-sfield) 3739*16dce513Schristos (set tmpd (cris-swap swapoption tmps)) 3740*16dce513Schristos (set Rd-sfield tmpd) 3741*16dce513Schristos (setf-move SI tmpd)) 3742*16dce513Schristos) 3743*16dce513Schristos 3744*16dce513Schristos; ASR.m Rs,Rd [ Rd | 011110mm | Rs ] 3745*16dce513Schristos(dni-cdt-bwd 3746*16dce513Schristos asrr "Arithmetic shift right register count" 3747*16dce513Schristos "$Rs,$Rd" 3748*16dce513Schristos (+ Rd MODE_REGISTER R_ASR Rs) 3749*16dce513Schristos (.pmacro 3750*16dce513Schristos (BWD) 3751*16dce513Schristos (sequence 3752*16dce513Schristos ((BWD tmpd) (SI cnt1) (SI cnt2)) 3753*16dce513Schristos (set cnt1 Rs) 3754*16dce513Schristos (set cnt2 (if SI (ne (and cnt1 32) 0) 31 (and cnt1 31))) 3755*16dce513Schristos (set tmpd (sra SI (ext SI (trunc BWD Rd)) cnt2)) 3756*16dce513Schristos (set-subreg-gr BWD (regno Rd) tmpd) 3757*16dce513Schristos (setf-move BWD tmpd))) 3758*16dce513Schristos) 3759*16dce513Schristos 3760*16dce513Schristos; ASRQ c,Rd [ Rd | 0011101 | c ] 3761*16dce513Schristos(dni-cdt 3762*16dce513Schristos asrq "Arithmetic shift right quick-immediate count" 3763*16dce513Schristos "asrq $c,${Rd}" 3764*16dce513Schristos (+ Rd Q_ASHQ MODE_QUICK_IMMEDIATE (f-b5 1) c) 3765*16dce513Schristos (sequence 3766*16dce513Schristos ((SI tmpd)) 3767*16dce513Schristos (set tmpd (sra Rd c)) 3768*16dce513Schristos (set Rd tmpd) 3769*16dce513Schristos (setf-move SI tmpd)) 3770*16dce513Schristos) 3771*16dce513Schristos 3772*16dce513Schristos; LSR.m Rs,Rd [ Rd | 011111mm | Rs ] 3773*16dce513Schristos(dni-cdt-bwd 3774*16dce513Schristos lsrr "Logical shift right register count" 3775*16dce513Schristos "$Rs,$Rd" 3776*16dce513Schristos (+ Rd MODE_REGISTER R_LSR Rs) 3777*16dce513Schristos (.pmacro 3778*16dce513Schristos (BWD) 3779*16dce513Schristos (sequence 3780*16dce513Schristos ((SI tmpd) (SI cnt)) 3781*16dce513Schristos (set cnt (and Rs 63)) 3782*16dce513Schristos (set 3783*16dce513Schristos tmpd 3784*16dce513Schristos (if SI (ne (and cnt 32) 0) 3785*16dce513Schristos 0 3786*16dce513Schristos (srl SI (zext SI (trunc BWD Rd)) (and cnt 31)))) 3787*16dce513Schristos (set-subreg-gr BWD (regno Rd) tmpd) 3788*16dce513Schristos (setf-move BWD tmpd))) 3789*16dce513Schristos) 3790*16dce513Schristos 3791*16dce513Schristos; LSRQ c,Rd [ Rd | 0011111 | c ] 3792*16dce513Schristos(dni-cdt 3793*16dce513Schristos lsrq "Logical shift right quick-immediate count" 3794*16dce513Schristos "lsrq $c,${Rd}" 3795*16dce513Schristos (+ Rd Q_LSHQ MODE_QUICK_IMMEDIATE (f-b5 1) c) 3796*16dce513Schristos (sequence 3797*16dce513Schristos ((SI tmpd)) 3798*16dce513Schristos (set tmpd (srl Rd c)) 3799*16dce513Schristos (set Rd tmpd) 3800*16dce513Schristos (setf-move SI tmpd)) 3801*16dce513Schristos) 3802*16dce513Schristos 3803*16dce513Schristos; LSL.m Rs,Rd [ Rd | 010011mm | Rs ] 3804*16dce513Schristos(dni-cdt-bwd 3805*16dce513Schristos lslr "Logical shift left register count" 3806*16dce513Schristos "$Rs,$Rd" 3807*16dce513Schristos (+ Rd MODE_REGISTER R_LSL Rs) 3808*16dce513Schristos (.pmacro 3809*16dce513Schristos (BWD) 3810*16dce513Schristos (sequence 3811*16dce513Schristos ((SI tmpd) (SI cnt)) 3812*16dce513Schristos (set cnt (and Rs 63)) 3813*16dce513Schristos (set 3814*16dce513Schristos tmpd 3815*16dce513Schristos (if SI (ne (and cnt 32) 0) 3816*16dce513Schristos 0 3817*16dce513Schristos (sll SI (zext SI (trunc BWD Rd)) (and cnt 31)))) 3818*16dce513Schristos (set-subreg-gr BWD (regno Rd) tmpd) 3819*16dce513Schristos (setf-move BWD tmpd))) 3820*16dce513Schristos) 3821*16dce513Schristos 3822*16dce513Schristos; LSLQ c,Rd [ Rd | 0011110 | c ] 3823*16dce513Schristos(dni-cdt 3824*16dce513Schristos lslq "Logical shift left quick-immediate count" 3825*16dce513Schristos "lslq $c,${Rd}" 3826*16dce513Schristos (+ Rd Q_LSHQ MODE_QUICK_IMMEDIATE (f-b5 0) c) 3827*16dce513Schristos (sequence 3828*16dce513Schristos ((SI tmpd)) 3829*16dce513Schristos (set tmpd (sll Rd c)) 3830*16dce513Schristos (set Rd tmpd) 3831*16dce513Schristos (setf-move SI tmpd)) 3832*16dce513Schristos) 3833*16dce513Schristos 3834*16dce513Schristos; BTST Rs,Rd [ Rd | 01001111 | Rs ] 3835*16dce513Schristos(dni-cdt 3836*16dce513Schristos btst "Bit test register number" 3837*16dce513Schristos "$Rs,$Rd" 3838*16dce513Schristos (+ Rd MODE_REGISTER RFIX_BTST SIZE_FIXED Rs) 3839*16dce513Schristos (sequence 3840*16dce513Schristos ((SI tmpd) (SI cnt)) 3841*16dce513Schristos (set tmpd (sll Rd (sub 31 (and Rs 31)))) 3842*16dce513Schristos (setf-move SI tmpd)) 3843*16dce513Schristos) 3844*16dce513Schristos 3845*16dce513Schristos; BTSTQ c,Rd [ Rd | 0011100 | c ] 3846*16dce513Schristos(dni-cdt 3847*16dce513Schristos btstq "Bit test quick-immediate number" 3848*16dce513Schristos "btstq $c,${Rd}" 3849*16dce513Schristos (+ Rd Q_ASHQ MODE_QUICK_IMMEDIATE (f-b5 0) c) 3850*16dce513Schristos (sequence 3851*16dce513Schristos ((SI tmpd)) 3852*16dce513Schristos (set tmpd (sll Rd (sub 31 c))) 3853*16dce513Schristos (setf-move SI tmpd)) 3854*16dce513Schristos) 3855*16dce513Schristos 3856*16dce513Schristos; SETF <list of flags> [ P U I X | 01011011 | N Z V C ] 3857*16dce513Schristos(dni-cdt 3858*16dce513Schristos setf "Set condition code flags explicitly" 3859*16dce513Schristos "setf ${list-of-flags}" 3860*16dce513Schristos ; The zero-flags case gets flag operands wrong; there's a "_" 3861*16dce513Schristos ; where there should have been nothing. Also, flags are in 3862*16dce513Schristos ; assembly code allowed to be specified in any order, which 3863*16dce513Schristos ; doesn't match the "flagbits" settings. Luckily we don't 3864*16dce513Schristos ; use this field for assembly. 3865*16dce513Schristos (+ RFIX_SETF MODE_REGISTER SIZE_FIXED list-of-flags) 3866*16dce513Schristos (.splice 3867*16dce513Schristos sequence 3868*16dce513Schristos ((SI tmp)) 3869*16dce513Schristos (set tmp list-of-flags) 3870*16dce513Schristos (.unsplice 3871*16dce513Schristos (.map 3872*16dce513Schristos (.pmacro (ccbit) 3873*16dce513Schristos (if (ne (and tmp (sll 1 (.sym ccbit -bitnumber))) 0) 3874*16dce513Schristos (set (.sym ccbit bit) 1))) 3875*16dce513Schristos cris-flagnames)) 3876*16dce513Schristos (set prefix-set 0) 3877*16dce513Schristos ; Unless x was specified to be set, set it to 0. 3878*16dce513Schristos (if (eq (and tmp (sll 1 x-bitnumber)) 0) 3879*16dce513Schristos (set xbit 0))) 3880*16dce513Schristos) 3881*16dce513Schristos 3882*16dce513Schristos; CLEARF <list of flags> [ P U I X | 01011111 | N Z V C ] 3883*16dce513Schristos(dni-cdt 3884*16dce513Schristos clearf "Clear condition code flags explicitly" 3885*16dce513Schristos "clearf ${list-of-flags}" 3886*16dce513Schristos ; The zero-flags case gets flag operands wrong; there's a "_" 3887*16dce513Schristos ; where there should have been nothing. Also, flags are in 3888*16dce513Schristos ; assembly code allowed to be specified in any order, which 3889*16dce513Schristos ; doesn't match the "flagbits" settings. Luckily we don't 3890*16dce513Schristos ; use this field for assembly. 3891*16dce513Schristos (+ RFIX_CLEARF MODE_REGISTER SIZE_FIXED list-of-flags) 3892*16dce513Schristos (.splice 3893*16dce513Schristos sequence 3894*16dce513Schristos ((SI tmp)) 3895*16dce513Schristos (set tmp list-of-flags) 3896*16dce513Schristos (.unsplice 3897*16dce513Schristos (.map 3898*16dce513Schristos (.pmacro (ccbit) 3899*16dce513Schristos (if (ne (and tmp (sll 1 (.sym ccbit -bitnumber))) 0) 3900*16dce513Schristos (set (.sym ccbit bit) 0))) 3901*16dce513Schristos cris-flagnames)) 3902*16dce513Schristos (reset-x-p)) 3903*16dce513Schristos) 3904*16dce513Schristos 3905*16dce513Schristos(define-pmacro 3906*16dce513Schristos (rfe-rfn-guts) 3907*16dce513Schristos "Common parts of RFE and RFN" 3908*16dce513Schristos (sequence 3909*16dce513Schristos ((USI oldccs) (USI samebits) (USI shiftbits) (USI keepmask) (BI p1)) 3910*16dce513Schristos (set oldccs ccs) 3911*16dce513Schristos ; Keeping U, S and I in user mode is handled by the CCS setter, so we 3912*16dce513Schristos ; don't have to bother. Actually Q and M are handled too. The reason 3913*16dce513Schristos ; to mask those out is to not have them shifted down into the second 3914*16dce513Schristos ; flags level. 3915*16dce513Schristos (set keepmask #xc0000000) 3916*16dce513Schristos (set samebits (and oldccs keepmask)) 3917*16dce513Schristos ; The P bit has its own equation. 3918*16dce513Schristos (set shiftbits (and (srl (and oldccs #x3ffdfc00) 10) (inv keepmask))) 3919*16dce513Schristos (set p1 (ne 0 (and oldccs #x20000))) 3920*16dce513Schristos (set ccs (or (or samebits shiftbits) 3921*16dce513Schristos (if SI (and rbit (not p1)) 0 #x80)))) 3922*16dce513Schristos) 3923*16dce513Schristos 3924*16dce513Schristos; RFE [ 0010 10010011 0000 ] 3925*16dce513Schristos(dni-cdt-attr 3926*16dce513Schristos rfe 3927*16dce513Schristos "RFE" 3928*16dce513Schristos (MACH-V32) 3929*16dce513Schristos "rfe" 3930*16dce513Schristos (+ (f-dest 2) MODE_INDIRECT INFIX_RFE SIZE_FIXED (f-source 0)) 3931*16dce513Schristos (rfe-rfn-guts) 3932*16dce513Schristos) 3933*16dce513Schristos 3934*16dce513Schristos; SFE [ 0011 10010011 0000 ] 3935*16dce513Schristos(dni-cdt-attr 3936*16dce513Schristos sfe 3937*16dce513Schristos "SFE" 3938*16dce513Schristos (MACH-V32) 3939*16dce513Schristos "sfe" 3940*16dce513Schristos (+ (f-dest 3) MODE_INDIRECT INFIX_SFE SIZE_FIXED (f-source 0)) 3941*16dce513Schristos (sequence 3942*16dce513Schristos ((SI oldccs) (SI savemask)) 3943*16dce513Schristos (set savemask #xc0000000) 3944*16dce513Schristos (set oldccs ccs) 3945*16dce513Schristos (set ccs 3946*16dce513Schristos (or (and savemask oldccs) 3947*16dce513Schristos (and (inv savemask) (sll oldccs 10))))) 3948*16dce513Schristos) 3949*16dce513Schristos 3950*16dce513Schristos; RFG [ 0100 10010011 0000 ] 3951*16dce513Schristos(dni-cdt-attr 3952*16dce513Schristos rfg 3953*16dce513Schristos "RFG" 3954*16dce513Schristos (MACH-V32) 3955*16dce513Schristos "rfg" 3956*16dce513Schristos (+ (f-dest 4) MODE_INDIRECT INFIX_RFG SIZE_FIXED (f-source 0)) 3957*16dce513Schristos (c-call VOID "@cpu@_rfg_handler" pc) 3958*16dce513Schristos) 3959*16dce513Schristos 3960*16dce513Schristos; RFN [ 0101 10010011 0000 ] 3961*16dce513Schristos(dni-cdt-attr 3962*16dce513Schristos rfn 3963*16dce513Schristos "RFN" 3964*16dce513Schristos (MACH-V32) 3965*16dce513Schristos "rfn" 3966*16dce513Schristos (+ (f-dest 5) MODE_INDIRECT INFIX_RFN SIZE_FIXED (f-source 0)) 3967*16dce513Schristos (sequence () (rfe-rfn-guts) (set mbit 1)) 3968*16dce513Schristos) 3969*16dce513Schristos 3970*16dce513Schristos; HALT [ 1111 10010011 0000 ] 3971*16dce513Schristos(dni-cdt-attr 3972*16dce513Schristos halt 3973*16dce513Schristos "HALT" 3974*16dce513Schristos (MACH-V32) 3975*16dce513Schristos "halt" 3976*16dce513Schristos (+ (f-dest 15) MODE_INDIRECT INFIX_HALT SIZE_FIXED (f-source 0)) 3977*16dce513Schristos (set pc (c-call USI "@cpu@_halt_handler" pc)) 3978*16dce513Schristos) 3979*16dce513Schristos 3980*16dce513Schristos; Bcc o [ cc | 0000 | o ] 3981*16dce513Schristos(dni 3982*16dce513Schristos bcc-b "bcc byte operand" 3983*16dce513Schristos () 3984*16dce513Schristos "b${cc} ${o-pcrel}" 3985*16dce513Schristos (+ cc QHI_BCC MODE_QUICK_IMMEDIATE o-pcrel) 3986*16dce513Schristos (sequence 3987*16dce513Schristos ((BI truthval)) 3988*16dce513Schristos (set truthval (cris-condition cc)) 3989*16dce513Schristos 3990*16dce513Schristos ; Amazing as it may seem, there's no simpler way to find out 3991*16dce513Schristos ; whether a branch is taken or not than to mark it through a kludge 3992*16dce513Schristos ; like this. 3993*16dce513Schristos (c-call VOID "@cpu@_branch_taken" pc o-pcrel truthval) 3994*16dce513Schristos 3995*16dce513Schristos (reset-x-p) 3996*16dce513Schristos (if truthval 3997*16dce513Schristos (delay 1 3998*16dce513Schristos (set pc o-pcrel)))) 3999*16dce513Schristos (.splice (.unsplice (simplecris-timing)) 4000*16dce513Schristos (crisv32 (unit u-branch) (unit u-exec))) 4001*16dce513Schristos) 4002*16dce513Schristos(dni 4003*16dce513Schristos ba-b "ba byte operand" 4004*16dce513Schristos () 4005*16dce513Schristos "ba ${o-pcrel}" 4006*16dce513Schristos (+ (f-dest 14) QHI_BCC MODE_QUICK_IMMEDIATE o-pcrel) 4007*16dce513Schristos (sequence 4008*16dce513Schristos () 4009*16dce513Schristos (reset-x-p) 4010*16dce513Schristos (delay 1 4011*16dce513Schristos (set pc o-pcrel))) 4012*16dce513Schristos ((crisv32 (unit u-jump) (unit u-exec))) 4013*16dce513Schristos) 4014*16dce513Schristos 4015*16dce513Schristos; Bcc [PC+] [ cc | 11011111 1111 ] 4016*16dce513Schristos; (We don't implement the generic for pre-V32 but unused variant 4017*16dce513Schristos; "Bcc [Rn(+)]" where n != 15.) 4018*16dce513Schristos(dni 4019*16dce513Schristos bcc-w "bcc, word operand" 4020*16dce513Schristos () 4021*16dce513Schristos "b${cc} ${o-word-pcrel}" 4022*16dce513Schristos (+ cc MODE_AUTOINCREMENT INFIX_BCC_M SIZE_FIXED (f-source 15) o-word-pcrel) 4023*16dce513Schristos (sequence 4024*16dce513Schristos ((BI truthval)) 4025*16dce513Schristos (set truthval (cris-condition cc)) 4026*16dce513Schristos 4027*16dce513Schristos ; Amazing as it may seem, there's no simpler way to find out 4028*16dce513Schristos ; whether a branch is taken or not than to mark it through a kludge 4029*16dce513Schristos ; like this. 4030*16dce513Schristos (c-call VOID "@cpu@_branch_taken" pc o-word-pcrel truthval) 4031*16dce513Schristos 4032*16dce513Schristos (reset-x-p) 4033*16dce513Schristos (if truthval 4034*16dce513Schristos (delay 1 4035*16dce513Schristos (set pc o-word-pcrel)))) 4036*16dce513Schristos (.splice 4037*16dce513Schristos (.unsplice (simplecris-common-timing ((unit u-const16) (unit u-exec)))) 4038*16dce513Schristos (crisv32 (unit u-const16) (unit u-branch) (unit u-exec))) 4039*16dce513Schristos) 4040*16dce513Schristos(dni 4041*16dce513Schristos ba-w "ba word operand" 4042*16dce513Schristos () 4043*16dce513Schristos "ba ${o-word-pcrel}" 4044*16dce513Schristos (+ (f-dest 14) MODE_AUTOINCREMENT INFIX_BCC_M SIZE_FIXED (f-source 15) o-word-pcrel) 4045*16dce513Schristos (sequence 4046*16dce513Schristos () 4047*16dce513Schristos (reset-x-p) 4048*16dce513Schristos (delay 1 4049*16dce513Schristos (set pc o-word-pcrel))) 4050*16dce513Schristos (.splice 4051*16dce513Schristos (.unsplice (simplecris-common-timing ((unit u-const16) (unit u-exec)))) 4052*16dce513Schristos (crisv32 (unit u-const16) (unit u-jump) (unit u-exec))) 4053*16dce513Schristos) 4054*16dce513Schristos 4055*16dce513Schristos; JAS Rs,Pd [ Pd | 10011011 | Rs ] 4056*16dce513Schristos(dni 4057*16dce513Schristos jas-r "JAS register" 4058*16dce513Schristos (MACH-V32) 4059*16dce513Schristos "jas ${Rs},${Pd}" 4060*16dce513Schristos (+ Pd MODE_INDIRECT INFIX_JAS_R SIZE_FIXED Rs) 4061*16dce513Schristos (sequence 4062*16dce513Schristos () 4063*16dce513Schristos (reset-x-p) 4064*16dce513Schristos (if (andif (eq (regno Rs) 1) (eq (regno Pd) 11)) 4065*16dce513Schristos ; We use this as a trigger; a normally reasonably rare instruction 4066*16dce513Schristos ; used in the v32 trampoline. See comment at bdapqpc. 4067*16dce513Schristos ; CGEN-FIXME: can't use (regno srp) [== (regno (reg h-sr 11))] 4068*16dce513Schristos (c-call VOID "cris_flush_simulator_decode_cache" pc)) 4069*16dce513Schristos (delay 1 4070*16dce513Schristos (sequence 4071*16dce513Schristos () 4072*16dce513Schristos (set Pd (add SI pc 4)) 4073*16dce513Schristos (set pc Rs)))) 4074*16dce513Schristos ((crisv32 (unit u-jump-r) (unit u-jump) (unit u-exec))) 4075*16dce513Schristos) 4076*16dce513Schristos; Same semantics in pre-V32, except no delay-slot. 4077*16dce513Schristos; FIXME: Missing JIRC/JSRC/JBRC. 4078*16dce513Schristos(dni-cdt-attr 4079*16dce513Schristos jump-r "JUMP/JSR/JIR register" 4080*16dce513Schristos (MACH-PC) 4081*16dce513Schristos "jump/jsr/jir ${Rs}" 4082*16dce513Schristos (+ Pd MODE_INDIRECT INFIX_JUMP_R SIZE_FIXED Rs) 4083*16dce513Schristos (sequence 4084*16dce513Schristos () 4085*16dce513Schristos (set Pd (add SI pc 2)) 4086*16dce513Schristos (set pc Rs) 4087*16dce513Schristos (reset-x-p)) 4088*16dce513Schristos) 4089*16dce513Schristos 4090*16dce513Schristos; JAS [PC+],Pd [ Pd | 11011011 1111 ] 4091*16dce513Schristos(dni 4092*16dce513Schristos jas-c "JAS constant" 4093*16dce513Schristos (MACH-V32) 4094*16dce513Schristos "jas ${const32},${Pd}" 4095*16dce513Schristos (+ Pd MODE_AUTOINCREMENT INFIX_JAS_M SIZE_FIXED (f-source 15) const32) 4096*16dce513Schristos (sequence 4097*16dce513Schristos () 4098*16dce513Schristos (reset-x-p) 4099*16dce513Schristos (delay 1 4100*16dce513Schristos (sequence 4101*16dce513Schristos () 4102*16dce513Schristos (set Pd (add SI pc 8)) 4103*16dce513Schristos (set pc const32)))) 4104*16dce513Schristos ((crisv32 (unit u-const32) (unit u-jump) (unit u-exec))) 4105*16dce513Schristos) 4106*16dce513Schristos 4107*16dce513Schristos; JUMP/JSR/JIR | Special r.| 1 m| 0 1 0 0| 1 1| Source | 4108*16dce513Schristos(dni-cmt-attr 4109*16dce513Schristos jump-m "JUMP/JSR/JIR memory" 4110*16dce513Schristos (MACH-PC) 4111*16dce513Schristos "jump/jsr/jir [${Rs}${inc}]" 4112*16dce513Schristos (+ Pd INFIX_JUMP_M SIZE_FIXED Rs) 4113*16dce513Schristos (sequence 4114*16dce513Schristos () 4115*16dce513Schristos (set Pd (add SI pc 2)) 4116*16dce513Schristos (set pc (cris-get-mem SI Rs)) 4117*16dce513Schristos (reset-x-p)) 4118*16dce513Schristos) 4119*16dce513Schristos(dni-c-SI-attr 4120*16dce513Schristos jump-c "JUMP/JSR/JIR constant" 4121*16dce513Schristos (MACH-PC) 4122*16dce513Schristos "jump/jsr/jir ${const32}" 4123*16dce513Schristos (+ Pd MODE_AUTOINCREMENT INFIX_JUMP_M SIZE_FIXED (f-source 15) const32) 4124*16dce513Schristos (sequence 4125*16dce513Schristos () 4126*16dce513Schristos (set Pd (add SI pc 6)) 4127*16dce513Schristos (set pc const32) 4128*16dce513Schristos (reset-x-p)) 4129*16dce513Schristos) 4130*16dce513Schristos 4131*16dce513Schristos; JUMP Ps [ Ps | 10011111 0000 ] 4132*16dce513Schristos(dni 4133*16dce513Schristos jump-p "JUMP special register" 4134*16dce513Schristos (MACH-V32) 4135*16dce513Schristos "jump ${Ps}" 4136*16dce513Schristos (+ Ps MODE_INDIRECT INFIX_JUMP_P SIZE_FIXED (f-source 0)) 4137*16dce513Schristos (sequence 4138*16dce513Schristos () 4139*16dce513Schristos (reset-x-p) 4140*16dce513Schristos (delay 1 4141*16dce513Schristos (set pc Ps))) 4142*16dce513Schristos ((crisv32 (unit u-jump-sr) 4143*16dce513Schristos (unit u-exec))) 4144*16dce513Schristos) 4145*16dce513Schristos 4146*16dce513Schristos; BAS [PC+],Pd [ Pd | 11101011 1111 ] 4147*16dce513Schristos(dni 4148*16dce513Schristos bas-c "BAS constant" 4149*16dce513Schristos (MACH-V32) 4150*16dce513Schristos "bas ${const32},${Pd}" 4151*16dce513Schristos (+ Pd MODE_AUTOINCREMENT INFIX_BAS SIZE_FIXED (f-source 15) const32-pcrel) 4152*16dce513Schristos (sequence 4153*16dce513Schristos () 4154*16dce513Schristos (reset-x-p) 4155*16dce513Schristos (delay 1 4156*16dce513Schristos (sequence 4157*16dce513Schristos () 4158*16dce513Schristos (set Pd (add SI pc 8)) 4159*16dce513Schristos (set pc const32-pcrel)))) 4160*16dce513Schristos ((crisv32 (unit u-const32) (unit u-jump) (unit u-exec))) 4161*16dce513Schristos) 4162*16dce513Schristos 4163*16dce513Schristos; JASC Rs,Pd [ Pd | 10110011 | Rs ] 4164*16dce513Schristos(dni 4165*16dce513Schristos jasc-r "JASC register" 4166*16dce513Schristos (MACH-V32) 4167*16dce513Schristos "jasc ${Rs},${Pd}" 4168*16dce513Schristos (+ Pd MODE_INDIRECT INFIX_JASC SIZE_FIXED Rs) 4169*16dce513Schristos (sequence 4170*16dce513Schristos () 4171*16dce513Schristos (reset-x-p) 4172*16dce513Schristos (delay 1 4173*16dce513Schristos (sequence 4174*16dce513Schristos () 4175*16dce513Schristos (set Pd (add SI pc 8)) 4176*16dce513Schristos (set pc Rs)))) 4177*16dce513Schristos ((crisv32 (unit u-jump-r) (unit u-skip4) (unit u-jump) (unit u-exec))) 4178*16dce513Schristos) 4179*16dce513Schristos 4180*16dce513Schristos; JASC [PC+],Pd [ Pd | 11110011 1111 ] 4181*16dce513Schristos(dni 4182*16dce513Schristos jasc-c "JASC constant" 4183*16dce513Schristos (MACH-V32) 4184*16dce513Schristos "jasc ${const32},${Pd}" 4185*16dce513Schristos (+ Pd MODE_AUTOINCREMENT INFIX_JASC SIZE_FIXED (f-source 15) const32) 4186*16dce513Schristos (sequence 4187*16dce513Schristos () 4188*16dce513Schristos (reset-x-p) 4189*16dce513Schristos (delay 1 4190*16dce513Schristos (sequence 4191*16dce513Schristos () 4192*16dce513Schristos (set Pd (add SI pc 12)) 4193*16dce513Schristos (set pc const32)))) 4194*16dce513Schristos ((crisv32 (unit u-const32) (unit u-skip4) (unit u-jump) (unit u-exec))) 4195*16dce513Schristos) 4196*16dce513Schristos 4197*16dce513Schristos; BASC [PC+],Pd [ Pd | 11101111 1111 ] 4198*16dce513Schristos(dni 4199*16dce513Schristos basc-c "BASC constant" 4200*16dce513Schristos (MACH-V32) 4201*16dce513Schristos "basc ${const32},${Pd}" 4202*16dce513Schristos (+ Pd MODE_AUTOINCREMENT INFIX_BASC SIZE_FIXED (f-source 15) const32-pcrel) 4203*16dce513Schristos (sequence 4204*16dce513Schristos () 4205*16dce513Schristos (reset-x-p) 4206*16dce513Schristos (delay 1 4207*16dce513Schristos (sequence 4208*16dce513Schristos () 4209*16dce513Schristos (set Pd (add SI pc 12)) 4210*16dce513Schristos (set pc const32-pcrel)))) 4211*16dce513Schristos ((crisv32 (unit u-const32) (unit u-skip4) (unit u-jump) (unit u-exec))) 4212*16dce513Schristos) 4213*16dce513Schristos 4214*16dce513Schristos; BREAK n [ 1110 | 10010011 | n ] 4215*16dce513Schristos 4216*16dce513Schristos(dni-cdt 4217*16dce513Schristos break "break" 4218*16dce513Schristos "break $n" 4219*16dce513Schristos (+ (f-operand2 #xe) MODE_INDIRECT INFIX_BREAK SIZE_FIXED n) 4220*16dce513Schristos (sequence () (reset-x-p) (set pc (c-call USI "@cpu@_break_handler" n pc))) 4221*16dce513Schristos) 4222*16dce513Schristos 4223*16dce513Schristos; BOUND.m Rs,Rd [ Rd | 010111mm | Rs ] 4224*16dce513Schristos(dni-cdt-bwd 4225*16dce513Schristos bound-r "Bound register" 4226*16dce513Schristos "${Rs},${Rd}" 4227*16dce513Schristos (+ Rd R_BOUND MODE_REGISTER Rs) 4228*16dce513Schristos (.pmacro 4229*16dce513Schristos (BWD) 4230*16dce513Schristos (sequence 4231*16dce513Schristos ((SI tmpopd) (SI tmpops) (SI newval)) 4232*16dce513Schristos (set tmpops ((.sym BWD -zext) (trunc BWD Rs))) 4233*16dce513Schristos (set tmpopd Rd) 4234*16dce513Schristos (set newval (if SI (ltu tmpops tmpopd) tmpops tmpopd)) 4235*16dce513Schristos (set Rd newval) 4236*16dce513Schristos (setf-move SI newval))) 4237*16dce513Schristos) 4238*16dce513Schristos 4239*16dce513Schristos; BOUND.m [Rs],Rd [ Rd | 100111mm | Rs ] 4240*16dce513Schristos; BOUND.m [Rs+],Rd [ Rd | 110111mm | Rs ] 4241*16dce513Schristos(dni-cmt-bwd-attr 4242*16dce513Schristos bound-m "Bound memory" 4243*16dce513Schristos (MACH-PRE-V32) 4244*16dce513Schristos "[${Rs}${inc}],${Rd}" 4245*16dce513Schristos (+ Rd INDIR_BOUND Rs) 4246*16dce513Schristos (.pmacro 4247*16dce513Schristos (BWD) 4248*16dce513Schristos (sequence 4249*16dce513Schristos ((SI tmpopd) (SI tmpops) (SI newval)) 4250*16dce513Schristos (set tmpops ((.sym BWD -zext) (cris-get-mem BWD Rs))) 4251*16dce513Schristos (set tmpopd Rd) 4252*16dce513Schristos (set newval (if SI (ltu tmpops tmpopd) tmpops tmpopd)) 4253*16dce513Schristos (if (andif prefix-set (not inc)) 4254*16dce513Schristos (set Rs newval) 4255*16dce513Schristos (set Rd newval)) 4256*16dce513Schristos (setf-move SI newval))) 4257*16dce513Schristos) 4258*16dce513Schristos 4259*16dce513Schristos; (BOUND.m [PC+],Rd [ Rd | 110111mm | 1111 ]) 4260*16dce513Schristos(dni-c-QI 4261*16dce513Schristos bound-cb "Bound constant byte" 4262*16dce513Schristos "bound.b [PC+],${Rd}" 4263*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_BOUND SIZE_BYTE (f-source 15) uconst8) 4264*16dce513Schristos (sequence 4265*16dce513Schristos ((SI tmpopd) (SI tmpops) (SI newval)) 4266*16dce513Schristos (set tmpops (zext SI (trunc QI uconst8))) 4267*16dce513Schristos (set tmpopd Rd) 4268*16dce513Schristos (set newval (if SI (ltu tmpops tmpopd) tmpops tmpopd)) 4269*16dce513Schristos (set Rd newval) 4270*16dce513Schristos (setf-move SI newval)) 4271*16dce513Schristos) 4272*16dce513Schristos(dni-c-HI 4273*16dce513Schristos bound-cw "Bound constant word" 4274*16dce513Schristos "bound.w [PC+],${Rd}" 4275*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_BOUND SIZE_WORD (f-source 15) uconst16) 4276*16dce513Schristos (sequence 4277*16dce513Schristos ((SI tmpopd) (SI tmpops) (SI newval)) 4278*16dce513Schristos (set tmpops (zext SI uconst16)) 4279*16dce513Schristos (set tmpopd Rd) 4280*16dce513Schristos (set newval (if SI (ltu tmpops tmpopd) tmpops tmpopd)) 4281*16dce513Schristos (set Rd newval) 4282*16dce513Schristos (setf-move SI newval)) 4283*16dce513Schristos) 4284*16dce513Schristos(dni-c-SI 4285*16dce513Schristos bound-cd "Bound constant dword" 4286*16dce513Schristos "bound.d [PC+],${Rd}" 4287*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_BOUND SIZE_DWORD (f-source 15) const32) 4288*16dce513Schristos (sequence 4289*16dce513Schristos ((SI tmpopd) (SI tmpops) (SI newval)) 4290*16dce513Schristos (set tmpops const32) 4291*16dce513Schristos (set tmpopd Rd) 4292*16dce513Schristos (set newval (if SI (ltu tmpops tmpopd) tmpops tmpopd)) 4293*16dce513Schristos (set Rd newval) 4294*16dce513Schristos (setf-move SI newval)) 4295*16dce513Schristos) 4296*16dce513Schristos 4297*16dce513Schristos; Scc Rd [ cc | 01010011 | Rd ] 4298*16dce513Schristos(dni-cdt 4299*16dce513Schristos scc "scc" 4300*16dce513Schristos "s${cc} ${Rd-sfield}" 4301*16dce513Schristos (+ cc MODE_REGISTER RFIX_SCC SIZE_FIXED Rd-sfield) 4302*16dce513Schristos (sequence 4303*16dce513Schristos ((BI truthval)) 4304*16dce513Schristos (set truthval (cris-condition cc)) 4305*16dce513Schristos (set Rd-sfield (zext SI truthval)) 4306*16dce513Schristos (reset-x-p)) 4307*16dce513Schristos) 4308*16dce513Schristos 4309*16dce513Schristos; LZ Rs,Rd [ Rd | 01110011 | Rs ] 4310*16dce513Schristos(dni-cdt-attr 4311*16dce513Schristos lz "lz" 4312*16dce513Schristos (MACH-V3-UP) 4313*16dce513Schristos "lz ${Rs},${Rd}" 4314*16dce513Schristos (+ Rd MODE_REGISTER RFIX_LZ SIZE_FIXED Rs) 4315*16dce513Schristos (sequence 4316*16dce513Schristos ((SI tmpd) (SI tmp)) 4317*16dce513Schristos (set tmp Rs) 4318*16dce513Schristos (set tmpd 0) 4319*16dce513Schristos (.splice 4320*16dce513Schristos sequence 4321*16dce513Schristos () 4322*16dce513Schristos (.unsplice 4323*16dce513Schristos (.map 4324*16dce513Schristos (.pmacro (n) 4325*16dce513Schristos (if (ge tmp 0) 4326*16dce513Schristos (sequence 4327*16dce513Schristos () 4328*16dce513Schristos (set tmp (sll tmp 1)) 4329*16dce513Schristos (set tmpd (add tmpd 1))))) 4330*16dce513Schristos (.iota 32)))) 4331*16dce513Schristos (set Rd tmpd) 4332*16dce513Schristos (setf-move SI tmpd)) 4333*16dce513Schristos) 4334*16dce513Schristos 4335*16dce513Schristos; ADDOQ o,Rs,ACR [ Rs | 0001 | o ] 4336*16dce513Schristos(dni-cdt 4337*16dce513Schristos addoq "addoq" 4338*16dce513Schristos "addoq $o,$Rs,ACR" 4339*16dce513Schristos (+ Rs-dfield MODE_QUICK_IMMEDIATE QHI_ADDOQ o) 4340*16dce513Schristos (sequence 4341*16dce513Schristos () 4342*16dce513Schristos (set prefixreg (add SI Rs-dfield o)) 4343*16dce513Schristos (set prefix-set 1)) 4344*16dce513Schristos) 4345*16dce513Schristos 4346*16dce513Schristos; (BDAPQ o,PC [ 1111 | 0001 | o ]) 4347*16dce513Schristos; This [PC+I] prefix is used in trampolines. 4348*16dce513Schristos(dni-cdt-attr 4349*16dce513Schristos bdapqpc "bdapq pc operand" 4350*16dce513Schristos (MACH-PC UNCOND-CTI) 4351*16dce513Schristos "bdapq $o,PC" 4352*16dce513Schristos (+ (f-dest 15) MODE_QUICK_IMMEDIATE QHI_BDAP o) 4353*16dce513Schristos (sequence 4354*16dce513Schristos () 4355*16dce513Schristos (set prefixreg (add SI (add SI pc 2) o)) 4356*16dce513Schristos (set prefix-set 1) 4357*16dce513Schristos ; When this *rare* instruction is seen, we're may be about to write 4358*16dce513Schristos ; into code to be executed soon, *probably* covering addresses decoded 4359*16dce513Schristos ; and executed before. If the simulator does not implement snooping 4360*16dce513Schristos ; and automatic decoder flush, it will execute old code. This call 4361*16dce513Schristos ; is a kludge for such simulators, asking it to abandon such cached 4362*16dce513Schristos ; information. Anyway, it is hopefully enough to make CGEN-sim not 4363*16dce513Schristos ; hork on gcc trampolines. 4364*16dce513Schristos ; We mark this insn as UNCOND-CTI so this insn will end a simulator 4365*16dce513Schristos ; basic block (the atomic unit of translation). 4366*16dce513Schristos (c-call VOID "cris_flush_simulator_decode_cache" pc)) 4367*16dce513Schristos) 4368*16dce513Schristos 4369*16dce513Schristos; (BDAP.D [PC+],PC [ 1111 | 11010110 | 1111 ] 4370*16dce513Schristos; This [PC+I] prefix is used for DSO-local jumps in PIC code, together with 4371*16dce513Schristos; move-m-pcplus-p0: "move [pc=pc+N],p0" 4372*16dce513Schristos(dni-c-SI-attr 4373*16dce513Schristos bdap-32-pc "bdap.d [PC+],PC" 4374*16dce513Schristos (MACH-PC) 4375*16dce513Schristos "bdap ${sconst32},PC" 4376*16dce513Schristos (+ (f-dest 15) MODE_AUTOINCREMENT INDIR_BDAP_M SIZE_DWORD (f-source 15) const32) 4377*16dce513Schristos (sequence 4378*16dce513Schristos ((SI newpc) (SI oldpc) (SI offs)) 4379*16dce513Schristos (set offs const32) 4380*16dce513Schristos (set oldpc (add SI pc 6)) 4381*16dce513Schristos (set newpc (add SI oldpc offs)) 4382*16dce513Schristos (set prefixreg newpc) 4383*16dce513Schristos (set prefix-set 1)) 4384*16dce513Schristos) 4385*16dce513Schristos 4386*16dce513Schristos; (MOVE [PC+],P0 [ 0000 | 11100011 | 1111 ]) 4387*16dce513Schristos; This insn is used for DSO-local jumps in PIC code. See bdap-32-pc. 4388*16dce513Schristos(dni ; Must not use dni-cmt-* because we force MODE_AUTOINCREMENT. 4389*16dce513Schristos move-m-pcplus-p0 "move [PC+],P0" 4390*16dce513Schristos (MACH-PC) 4391*16dce513Schristos "move [PC+],P0" 4392*16dce513Schristos (+ (f-dest 0) MODE_AUTOINCREMENT INFIX_MOVE_M_S SIZE_FIXED (f-source 15)) 4393*16dce513Schristos (if prefix-set 4394*16dce513Schristos (sequence 4395*16dce513Schristos ((QI dummy)) 4396*16dce513Schristos ; We model the memory read, but throw the result away, as the 4397*16dce513Schristos ; destination register is read-only. We need to assign the result of 4398*16dce513Schristos ; cris-get-mem though, as CGEN-FIXME: invalid C code will otherwise 4399*16dce513Schristos ; be generated. 4400*16dce513Schristos (set dummy (cris-get-mem QI pc)) 4401*16dce513Schristos (reset-x-p)) 4402*16dce513Schristos (error "move [PC+],P0 without prefix is not implemented")) 4403*16dce513Schristos (cris-mem-timing) 4404*16dce513Schristos) 4405*16dce513Schristos 4406*16dce513Schristos; This insn is used in Linux in the form "move [$sp=$sp+16],$p8"; it's 4407*16dce513Schristos; similar to move-m-pcplus-p0 above. The same comments apply here. 4408*16dce513Schristos(dni 4409*16dce513Schristos move-m-spplus-p8 "move [SP+],P8" 4410*16dce513Schristos (MACH-PC) 4411*16dce513Schristos "move [SP+],P8" 4412*16dce513Schristos (+ (f-dest 8) MODE_AUTOINCREMENT INFIX_MOVE_M_S SIZE_FIXED (f-source 14)) 4413*16dce513Schristos (if prefix-set 4414*16dce513Schristos (sequence 4415*16dce513Schristos ((SI dummy)) 4416*16dce513Schristos (set dummy (cris-get-mem SI sp)) 4417*16dce513Schristos (reset-x-p)) 4418*16dce513Schristos (error "move [SP+],P8 without prefix is not implemented")) 4419*16dce513Schristos (cris-mem-timing) 4420*16dce513Schristos) 4421*16dce513Schristos 4422*16dce513Schristos; ADDO.m [Rs],Rd,ACR [ Rd | 100101mm | Rs ] 4423*16dce513Schristos; ADDO.m [Rs+],Rd,ACR [ Rd | 110101mm | Rs ] 4424*16dce513Schristos(dni-cmt-bwd 4425*16dce513Schristos addo-m "addo.m memory" 4426*16dce513Schristos "[${Rs}${inc}],$Rd,ACR" 4427*16dce513Schristos (+ Rd INDIR_ADDO Rs) 4428*16dce513Schristos (.pmacro 4429*16dce513Schristos (BWD) 4430*16dce513Schristos (sequence 4431*16dce513Schristos ((BWD tmps)) 4432*16dce513Schristos (set tmps (cris-get-mem BWD Rs)) 4433*16dce513Schristos (set prefixreg (add SI Rd ((.sym BWD -ext) tmps))) 4434*16dce513Schristos (set prefix-set 1))) 4435*16dce513Schristos) 4436*16dce513Schristos 4437*16dce513Schristos; (ADDO.m [PC+],Rd,ACR [ Rd | 110101mm | 1111 ] 4438*16dce513Schristos(dni-c-QI 4439*16dce513Schristos addo-cb "addo.b const" 4440*16dce513Schristos "addo.b [PC+],$Rd,ACR" 4441*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADDO SIZE_BYTE (f-source 15) sconst8) 4442*16dce513Schristos (sequence 4443*16dce513Schristos () 4444*16dce513Schristos (set prefixreg (add SI Rd (ext SI (trunc QI sconst8)))) 4445*16dce513Schristos (set prefix-set 1)) 4446*16dce513Schristos) 4447*16dce513Schristos(dni-c-HI 4448*16dce513Schristos addo-cw "addo.w const" 4449*16dce513Schristos "addo.w [PC+],$Rd,ACR" 4450*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADDO SIZE_WORD (f-source 15) sconst16) 4451*16dce513Schristos (sequence 4452*16dce513Schristos () 4453*16dce513Schristos (set prefixreg (add SI Rd (ext SI (trunc HI sconst16)))) 4454*16dce513Schristos (set prefix-set 1)) 4455*16dce513Schristos) 4456*16dce513Schristos(dni-c-SI 4457*16dce513Schristos addo-cd "addo.d const" 4458*16dce513Schristos "addo.d [PC+],$Rd,ACR" 4459*16dce513Schristos (+ Rd MODE_AUTOINCREMENT INDIR_ADDO SIZE_DWORD (f-source 15) const32) 4460*16dce513Schristos (sequence 4461*16dce513Schristos () 4462*16dce513Schristos (set prefixreg (add SI Rd const32)) 4463*16dce513Schristos (set prefix-set 1)) 4464*16dce513Schristos) 4465*16dce513Schristos 4466*16dce513Schristos; DIP [] | 0 0 0 0| 1 m| 0 1 0 1| 1 1| Source | 4467*16dce513Schristos 4468*16dce513Schristos(dni-cmt-attr 4469*16dce513Schristos dip-m "dip mem" 4470*16dce513Schristos (MACH-PRE-V32) 4471*16dce513Schristos "dip [${Rs}${inc}]" 4472*16dce513Schristos (+ (f-dest 0) INFIX_DIP SIZE_FIXED Rs) 4473*16dce513Schristos (sequence 4474*16dce513Schristos ((SI tmps)) 4475*16dce513Schristos (set tmps (cris-get-mem SI Rs)) 4476*16dce513Schristos (set prefixreg tmps) 4477*16dce513Schristos (set prefix-set 1)) 4478*16dce513Schristos) 4479*16dce513Schristos 4480*16dce513Schristos; (DIP [] | 0 0 0 0| 1 m| 0 1 0 1| 1 1| Source | ) 4481*16dce513Schristos(dni-c-SI-attr 4482*16dce513Schristos dip-c "dip [PC+]" 4483*16dce513Schristos (MACH-PC) 4484*16dce513Schristos "dip [PC+]" 4485*16dce513Schristos (+ (f-dest 0) MODE_AUTOINCREMENT INFIX_DIP SIZE_FIXED (f-source 15) const32) 4486*16dce513Schristos (sequence 4487*16dce513Schristos () 4488*16dce513Schristos (set prefixreg const32) 4489*16dce513Schristos (set prefix-set 1)) 4490*16dce513Schristos) 4491*16dce513Schristos 4492*16dce513Schristos; ADDI Rs.m,Rd,ACR [ Rs | 010101mm | Rd ] 4493*16dce513Schristos; a.k.a. biap 4494*16dce513Schristos(dni-cdt-bwd 4495*16dce513Schristos addi-acr "addi prefix" 4496*16dce513Schristos "${Rs-dfield}.m,${Rd-sfield},ACR" 4497*16dce513Schristos (+ Rd-sfield MODE_REGISTER R_ADDI_ACR Rs-dfield) 4498*16dce513Schristos (.pmacro 4499*16dce513Schristos (BWD) 4500*16dce513Schristos (sequence 4501*16dce513Schristos () 4502*16dce513Schristos (set prefixreg (add SI Rd-sfield (mul Rs-dfield (.sym BWD -size)))) 4503*16dce513Schristos (set prefix-set 1))) 4504*16dce513Schristos) 4505*16dce513Schristos 4506*16dce513Schristos(dni-cdt-bwd-attr 4507*16dce513Schristos biap-pc "biap.m ${Rs-dfield},PC" 4508*16dce513Schristos (MACH-PC) 4509*16dce513Schristos "${Rs-dfield}.m,PC" 4510*16dce513Schristos (+ Rs-dfield MODE_REGISTER R_ADDI_ACR (f-source 15)) 4511*16dce513Schristos (.pmacro 4512*16dce513Schristos (BWD) 4513*16dce513Schristos (sequence 4514*16dce513Schristos () 4515*16dce513Schristos (set prefixreg (add SI (add SI pc 4) (mul Rs-dfield (.sym BWD -size)))) 4516*16dce513Schristos (set prefix-set 1))) 4517*16dce513Schristos) 4518*16dce513Schristos 4519*16dce513Schristos; FIDXI [Rs] [ 0000 | 11010011 | Rs ] 4520*16dce513Schristos(dni-cdt-attr 4521*16dce513Schristos fidxi "fidxi [Rs]" 4522*16dce513Schristos (MACH-V32) 4523*16dce513Schristos "fidxi [$Rs]" 4524*16dce513Schristos (+ (f-dest 0) MODE_AUTOINCREMENT INFIX_FIDXI SIZE_FIXED Rs) 4525*16dce513Schristos (set pc (c-call USI "@cpu@_fidxi_handler" pc Rs)) 4526*16dce513Schristos) 4527*16dce513Schristos 4528*16dce513Schristos; FTAGI [Rs] [ 0001 | 11010011 | Rs ] 4529*16dce513Schristos(dni-cdt-attr 4530*16dce513Schristos ftagi "ftagi [Rs]" 4531*16dce513Schristos (MACH-V32) 4532*16dce513Schristos "fidxi [$Rs]" 4533*16dce513Schristos (+ (f-dest 1) MODE_AUTOINCREMENT INFIX_FTAGI SIZE_FIXED Rs) 4534*16dce513Schristos (set pc (c-call USI "@cpu@_ftagi_handler" pc Rs)) 4535*16dce513Schristos) 4536*16dce513Schristos 4537*16dce513Schristos; FIDXD [Rs] [ 0000 | 10101011 | Rs ] 4538*16dce513Schristos(dni-cdt-attr 4539*16dce513Schristos fidxd "fidxd [Rs]" 4540*16dce513Schristos (MACH-V32) 4541*16dce513Schristos "fidxd [$Rs]" 4542*16dce513Schristos (+ (f-dest 0) MODE_INDIRECT INFIX_FIDXD SIZE_FIXED Rs) 4543*16dce513Schristos (set pc (c-call USI "@cpu@_fidxd_handler" pc Rs)) 4544*16dce513Schristos) 4545*16dce513Schristos 4546*16dce513Schristos; FTAGD [Rs] [ 0001 | 10101011 | Rs ] 4547*16dce513Schristos(dni-cdt-attr 4548*16dce513Schristos ftagd "ftagd [Rs]" 4549*16dce513Schristos (MACH-V32) 4550*16dce513Schristos "ftagd [$Rs]" 4551*16dce513Schristos (+ (f-dest 1) MODE_INDIRECT INFIX_FTAGD SIZE_FIXED Rs) 4552*16dce513Schristos (set pc (c-call USI "@cpu@_ftagd_handler" pc Rs)) 4553*16dce513Schristos) 4554