1b578a859Schristos; Lattice Mico32 CPU description. -*- Scheme -*- 205caefcfSchristos; Copyright 2008-2013 Free Software Foundation, Inc. 3b578a859Schristos; Contributed by Jon Beniston <jon@beniston.com> 4b578a859Schristos; 5b578a859Schristos; This file is part of the GNU Binutils. 6b578a859Schristos; 7b578a859Schristos; This program is free software; you can redistribute it and/or modify 8b578a859Schristos; it under the terms of the GNU General Public License as published by 9b578a859Schristos; the Free Software Foundation; either version 3 of the License, or 10b578a859Schristos; (at your option) any later version. 11b578a859Schristos; 12b578a859Schristos; This program is distributed in the hope that it will be useful, 13b578a859Schristos; but WITHOUT ANY WARRANTY; without even the implied warranty of 14b578a859Schristos; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15b578a859Schristos; GNU General Public License for more details. 16b578a859Schristos; 17b578a859Schristos; You should have received a copy of the GNU General Public License 18b578a859Schristos; along with this program; if not, write to the Free Software 19b578a859Schristos; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 20b578a859Schristos; MA 02110-1301, USA. 21b578a859Schristos 22b578a859Schristos(include "simplify.inc") 23b578a859Schristos 24b578a859Schristos(define-arch 25b578a859Schristos (name lm32) ; name of cpu family 26b578a859Schristos (comment "Lattice Mico32") 27b578a859Schristos (default-alignment aligned) 28b578a859Schristos (insn-lsb0? #t) 29b578a859Schristos (machs lm32) 30b578a859Schristos (isas lm32) 31b578a859Schristos) 32b578a859Schristos 33b578a859Schristos 34b578a859Schristos; Instruction sets. 35b578a859Schristos 36b578a859Schristos(define-isa 37b578a859Schristos (name lm32) 38b578a859Schristos (comment "Lattice Mico32 ISA") 39b578a859Schristos (default-insn-word-bitsize 32) 40b578a859Schristos (default-insn-bitsize 32) 41b578a859Schristos (base-insn-bitsize 32) 42b578a859Schristos (decode-assist (31 30 29 28 27 26)) 43b578a859Schristos) 44b578a859Schristos 45b578a859Schristos 46b578a859Schristos; Cpu family definitions. 47b578a859Schristos 48b578a859Schristos(define-cpu 49b578a859Schristos ; cpu names must be distinct from the architecture name and machine name 50b578a859Schristos (name lm32bf) 51b578a859Schristos (comment "Lattice Mico32 CPU") 52b578a859Schristos (endian big) 53b578a859Schristos (word-bitsize 32) 54b578a859Schristos) 55b578a859Schristos 56b578a859Schristos(define-mach 57b578a859Schristos (name lm32) 58b578a859Schristos (comment "Lattice Mico32 MACH") 59b578a859Schristos (cpu lm32bf) 60b578a859Schristos) 61b578a859Schristos 62b578a859Schristos(define-model 63b578a859Schristos (name lm32) 64b578a859Schristos (comment "Lattice Mico32 reference implementation") 65b578a859Schristos (mach lm32) 66b578a859Schristos (unit u-exec "Execution unit" () 67b578a859Schristos 1 1 () () () ()) 68b578a859Schristos) 69b578a859Schristos 70b578a859Schristos 71b578a859Schristos; Hardware elements. 72b578a859Schristos 73b578a859Schristos(dnh h-pc "Program counter" (PC) (pc) () () ()) 74b578a859Schristos 75b578a859Schristos(dnh h-gr "General purpose registers" 76b578a859Schristos () 77b578a859Schristos (register SI (32)) 78b578a859Schristos (keyword "" ( 79b578a859Schristos (gp 26) (fp 27) (sp 28) (ra 29) (ea 30) (ba 31) 80b578a859Schristos (r0 0) (r1 1) (r2 2) (r3 3) 81b578a859Schristos (r4 4) (r5 5) (r6 6) (r7 7) 82b578a859Schristos (r8 8) (r9 9) (r10 10) (r11 11) 83b578a859Schristos (r12 12) (r13 13) (r14 14) (r15 15) 84b578a859Schristos (r16 16) (r17 17) (r18 18) (r19 19) 85b578a859Schristos (r20 20) (r21 21) (r22 22) (r23 23) 86b578a859Schristos (r24 24) (r25 25) (r26 26) (r27 27) 87b578a859Schristos (r28 28) (r29 29) (r30 30) (r31 31) 88b578a859Schristos ) 89b578a859Schristos ) 90b578a859Schristos () () 91b578a859Schristos) 92b578a859Schristos 93b578a859Schristos(dnh h-csr "Control and status registers" 94b578a859Schristos () 95b578a859Schristos (register SI (32)) 96b578a859Schristos (keyword "" ( 97b578a859Schristos (IE 0) (IM 1) (IP 2) 98b578a859Schristos (ICC 3) (DCC 4) 99b578a859Schristos (CC 5) 100b578a859Schristos (CFG 6) 101b578a859Schristos (EBA 7) 102b578a859Schristos (DC 8) 103b578a859Schristos (DEBA 9) 10405caefcfSchristos (CFG2 10) 105b578a859Schristos (JTX 14) (JRX 15) 106b578a859Schristos (BP0 16) (BP1 17) (BP2 18) (BP3 19) 107b578a859Schristos (WP0 24) (WP1 25) (WP2 26) (WP3 27) 10805caefcfSchristos (PSW 29) (TLBVADDR 30) (TLBPADDR 31) (TLBBADVADDR 31) 109b578a859Schristos ) 110b578a859Schristos ) 111b578a859Schristos () () 112b578a859Schristos) 113b578a859Schristos 114b578a859Schristos 115b578a859Schristos; Instruction fields. 116b578a859Schristos 117b578a859Schristos(dnf f-opcode "opcode field" () 31 6) 118b578a859Schristos(dnf f-r0 "register index 0 field" () 25 5) 119b578a859Schristos(dnf f-r1 "register index 1 field" () 20 5) 120b578a859Schristos(dnf f-r2 "register index 2 field" () 15 5) 121b578a859Schristos(dnf f-resv0 "reserved" (RESERVED) 10 11) 122b578a859Schristos(dnf f-shift "shift amount field" () 4 5) 123b578a859Schristos(df f-imm "signed immediate field" () 15 16 INT #f #f) 124b578a859Schristos(dnf f-uimm "unsigned immediate field" () 15 16) 125b578a859Schristos(dnf f-csr "csr field" () 25 5) 126b578a859Schristos(dnf f-user "user defined field" () 10 11) 127b578a859Schristos(dnf f-exception "exception field" () 25 26) 128b578a859Schristos 129b578a859Schristos(df f-branch "branch offset field" (PCREL-ADDR) 15 16 INT 130b578a859Schristos ((value pc) (sra SI (sub SI value pc) 2)) 131*f7172901Schristos ((value pc) (add SI pc (sub (xor (sll (and value #xffff) 2) 132*f7172901Schristos #x20000) 133*f7172901Schristos #x20000))) 134b578a859Schristos) 135b578a859Schristos(df f-call "call offset field" (PCREL-ADDR) 25 26 INT 136b578a859Schristos ((value pc) (sra SI (sub SI value pc) 2)) 137*f7172901Schristos ((value pc) (add SI pc (sub (xor (sll (and value #x3ffffff) 2) 138*f7172901Schristos #x8000000) 139*f7172901Schristos #x8000000))) 140b578a859Schristos) 141b578a859Schristos 142b578a859Schristos 143b578a859Schristos; Operands. 144b578a859Schristos 145b578a859Schristos(dnop r0 "register 0" () h-gr f-r0) 146b578a859Schristos(dnop r1 "register 1" () h-gr f-r1) 147b578a859Schristos(dnop r2 "register 2" () h-gr f-r2) 148b578a859Schristos(dnop shift "shift amout" () h-uint f-shift) 149b578a859Schristos(dnop imm "signed immediate" () h-sint f-imm) 150b578a859Schristos(dnop uimm "unsigned immediate" () h-uint f-uimm) 151b578a859Schristos(dnop branch "branch offset" () h-iaddr f-branch) 152b578a859Schristos(dnop call "call offset" () h-iaddr f-call) 153b578a859Schristos(dnop csr "csr" () h-csr f-csr) 154b578a859Schristos(dnop user "user" () h-uint f-user) 155b578a859Schristos(dnop exception "exception" () h-uint f-exception) 156b578a859Schristos 157b578a859Schristos(define-operand 158b578a859Schristos (name hi16) 159b578a859Schristos (comment "high 16-bit immediate") 160b578a859Schristos (attrs) 161b578a859Schristos (type h-uint) 162b578a859Schristos (index f-uimm) 163b578a859Schristos (handlers (parse "hi16")) 164b578a859Schristos) 165b578a859Schristos 166b578a859Schristos(define-operand 167b578a859Schristos (name lo16) 168b578a859Schristos (comment "low 16-bit immediate") 169b578a859Schristos (attrs) 170b578a859Schristos (type h-uint) 171b578a859Schristos (index f-uimm) 172b578a859Schristos (handlers (parse "lo16")) 173b578a859Schristos) 174b578a859Schristos 175b578a859Schristos(define-operand 176b578a859Schristos (name gp16) 177b578a859Schristos (comment "gp relative 16-bit immediate") 178b578a859Schristos (attrs) 179b578a859Schristos (type h-sint) 180b578a859Schristos (index f-imm) 181b578a859Schristos (handlers (parse "gp16")) 182b578a859Schristos) 183b578a859Schristos 184b578a859Schristos(define-operand 185b578a859Schristos (name got16) 186b578a859Schristos (comment "got 16-bit immediate") 187b578a859Schristos (attrs) 188b578a859Schristos (type h-sint) 189b578a859Schristos (index f-imm) 190b578a859Schristos (handlers (parse "got16")) 191b578a859Schristos) 192b578a859Schristos 193b578a859Schristos(define-operand 194b578a859Schristos (name gotoffhi16) 195b578a859Schristos (comment "got offset high 16-bit immediate") 196b578a859Schristos (attrs) 197b578a859Schristos (type h-sint) 198b578a859Schristos (index f-imm) 199b578a859Schristos (handlers (parse "gotoff_hi16")) 200b578a859Schristos) 201b578a859Schristos 202b578a859Schristos(define-operand 203b578a859Schristos (name gotofflo16) 204b578a859Schristos (comment "got offset low 16-bit immediate") 205b578a859Schristos (attrs) 206b578a859Schristos (type h-sint) 207b578a859Schristos (index f-imm) 208b578a859Schristos (handlers (parse "gotoff_lo16")) 209b578a859Schristos) 210b578a859Schristos 211b578a859Schristos 212b578a859Schristos; Enumerations. 213b578a859Schristos 214b578a859Schristos(define-normal-insn-enum 215b578a859Schristos opcodes "opcodes" () OP_ f-opcode 216b578a859Schristos (("ADD" 45) 217b578a859Schristos ("ADDI" 13) 218b578a859Schristos ("AND" 40) 219b578a859Schristos ("ANDI" 8) 220b578a859Schristos ("ANDHI" 24) 221b578a859Schristos ("B" 48) 222b578a859Schristos ("BI" 56) 223b578a859Schristos ("BE" 17) 224b578a859Schristos ("BG" 18) 225b578a859Schristos ("BGE" 19) 226b578a859Schristos ("BGEU" 20) 227b578a859Schristos ("BGU" 21) 228b578a859Schristos ("BNE" 23) 229b578a859Schristos ("CALL" 54) 230b578a859Schristos ("CALLI" 62) 231b578a859Schristos ("CMPE" 57) 232b578a859Schristos ("CMPEI" 25) 233b578a859Schristos ("CMPG" 58) 234b578a859Schristos ("CMPGI" 26) 235b578a859Schristos ("CMPGE" 59) 236b578a859Schristos ("CMPGEI" 27) 237b578a859Schristos ("CMPGEU" 60) 238b578a859Schristos ("CMPGEUI" 28) 239b578a859Schristos ("CMPGU" 61) 240b578a859Schristos ("CMPGUI" 29) 241b578a859Schristos ("CMPNE" 63) 242b578a859Schristos ("CMPNEI" 31) 243b578a859Schristos ("DIVU" 35) 244b578a859Schristos ("LB" 4) 245b578a859Schristos ("LBU" 16) 246b578a859Schristos ("LH" 7) 247b578a859Schristos ("LHU" 11) 248b578a859Schristos ("LW" 10) 249b578a859Schristos ("MODU" 49) 250b578a859Schristos ("MUL" 34) 251b578a859Schristos ("MULI" 2) 252b578a859Schristos ("NOR" 33) 253b578a859Schristos ("NORI" 1) 254b578a859Schristos ("OR" 46) 255b578a859Schristos ("ORI" 14) 256b578a859Schristos ("ORHI" 30) 257b578a859Schristos ("RAISE" 43) 258b578a859Schristos ("RCSR" 36) 259b578a859Schristos ("SB" 12) 260b578a859Schristos ("SEXTB" 44) 261b578a859Schristos ("SEXTH" 55) 262b578a859Schristos ("SH" 3) 263b578a859Schristos ("SL" 47) 264b578a859Schristos ("SLI" 15) 265b578a859Schristos ("SR" 37) 266b578a859Schristos ("SRI" 5) 267b578a859Schristos ("SRU" 32) 268b578a859Schristos ("SRUI" 0) 269b578a859Schristos ("SUB" 50) 270b578a859Schristos ("SW" 22) 271b578a859Schristos ("USER" 51) 272b578a859Schristos ("WCSR" 52) 273b578a859Schristos ("XNOR" 41) 274b578a859Schristos ("XNORI" 9) 275b578a859Schristos ("XOR" 38) 276b578a859Schristos ("XORI" 6) 277b578a859Schristos ) 278b578a859Schristos) 279b578a859Schristos 280b578a859Schristos 281b578a859Schristos; Instructions. Note: Reg-reg must come before reg-imm. 282b578a859Schristos 283b578a859Schristos(dni add "add" () 284b578a859Schristos "add $r2,$r0,$r1" 285b578a859Schristos (+ OP_ADD r0 r1 r2 (f-resv0 0)) 286b578a859Schristos (set r2 (add r0 r1)) 287b578a859Schristos () 288b578a859Schristos) 289b578a859Schristos 290b578a859Schristos(dni addi "add immediate" () 291b578a859Schristos "addi $r1,$r0,$imm" 292b578a859Schristos (+ OP_ADDI r0 r1 imm) 293b578a859Schristos (set r1 (add r0 (ext SI (trunc HI imm)))) 294b578a859Schristos () 295b578a859Schristos) 296b578a859Schristos 297b578a859Schristos(dni and "and" () 298b578a859Schristos "and $r2,$r0,$r1" 299b578a859Schristos (+ OP_AND r0 r1 r2 (f-resv0 0)) 300b578a859Schristos (set r2 (and r0 r1)) 301b578a859Schristos () 302b578a859Schristos) 303b578a859Schristos 304b578a859Schristos(dni andi "and immediate" () 305b578a859Schristos "andi $r1,$r0,$uimm" 306b578a859Schristos (+ OP_ANDI r0 r1 uimm) 307b578a859Schristos (set r1 (and r0 (zext SI uimm))) 308b578a859Schristos () 309b578a859Schristos) 310b578a859Schristos 311b578a859Schristos(dni andhii "and high immediate" () 312b578a859Schristos "andhi $r1,$r0,$hi16" 313b578a859Schristos (+ OP_ANDHI r0 r1 hi16) 314b578a859Schristos (set r1 (and r0 (sll SI hi16 16))) 315b578a859Schristos () 316b578a859Schristos) 317b578a859Schristos 318b578a859Schristos(dni b "branch" () 319b578a859Schristos "b $r0" 320b578a859Schristos (+ OP_B r0 (f-r1 0) (f-r2 0) (f-resv0 0)) 321b578a859Schristos (set pc (c-call USI "@cpu@_b_insn" r0 f-r0)) 322b578a859Schristos () 323b578a859Schristos) 324b578a859Schristos 325b578a859Schristos(dni bi "branch immediate" () 326b578a859Schristos "bi $call" 327b578a859Schristos (+ OP_BI call) 328b578a859Schristos (set pc (ext SI call)) 329b578a859Schristos () 330b578a859Schristos) 331b578a859Schristos 332b578a859Schristos(dni be "branch equal" () 333b578a859Schristos "be $r0,$r1,$branch" 334b578a859Schristos (+ OP_BE r0 r1 branch) 335b578a859Schristos (if (eq r0 r1) 336b578a859Schristos (set pc branch) 337b578a859Schristos ) 338b578a859Schristos () 339b578a859Schristos) 340b578a859Schristos 341b578a859Schristos(dni bg "branch greater" () 342b578a859Schristos "bg $r0,$r1,$branch" 343b578a859Schristos (+ OP_BG r0 r1 branch) 344b578a859Schristos (if (gt r0 r1) 345b578a859Schristos (set pc branch) 346b578a859Schristos ) 347b578a859Schristos () 348b578a859Schristos) 349b578a859Schristos 350b578a859Schristos(dni bge "branch greater or equal" () 351b578a859Schristos "bge $r0,$r1,$branch" 352b578a859Schristos (+ OP_BGE r0 r1 branch) 353b578a859Schristos (if (ge r0 r1) 354b578a859Schristos (set pc branch) 355b578a859Schristos ) 356b578a859Schristos () 357b578a859Schristos) 358b578a859Schristos 359b578a859Schristos(dni bgeu "branch greater or equal unsigned" () 360b578a859Schristos "bgeu $r0,$r1,$branch" 361b578a859Schristos (+ OP_BGEU r0 r1 branch) 362b578a859Schristos (if (geu r0 r1) 363b578a859Schristos (set pc branch) 364b578a859Schristos ) 365b578a859Schristos () 366b578a859Schristos) 367b578a859Schristos 368b578a859Schristos(dni bgu "branch greater unsigned" () 369b578a859Schristos "bgu $r0,$r1,$branch" 370b578a859Schristos (+ OP_BGU r0 r1 branch) 371b578a859Schristos (if (gtu r0 r1) 372b578a859Schristos (set pc branch) 373b578a859Schristos ) 374b578a859Schristos () 375b578a859Schristos) 376b578a859Schristos 377b578a859Schristos(dni bne "branch not equal" () 378b578a859Schristos "bne $r0,$r1,$branch" 379b578a859Schristos (+ OP_BNE r0 r1 branch) 380b578a859Schristos (if (ne r0 r1) 381b578a859Schristos (set pc branch) 382b578a859Schristos ) 383b578a859Schristos () 384b578a859Schristos) 385b578a859Schristos 386b578a859Schristos(dni call "call" () 387b578a859Schristos "call $r0" 388b578a859Schristos (+ OP_CALL r0 (f-r1 0) (f-r2 0) (f-resv0 0)) 389b578a859Schristos (sequence () 390b578a859Schristos (set (reg h-gr 29) (add pc 4)) 391b578a859Schristos (set pc r0) 392b578a859Schristos ) 393b578a859Schristos () 394b578a859Schristos) 395b578a859Schristos 396b578a859Schristos(dni calli "call immediate" () 397b578a859Schristos "calli $call" 398b578a859Schristos (+ OP_CALLI call) 399b578a859Schristos (sequence () 400b578a859Schristos (set (reg h-gr 29) (add pc 4)) 401b578a859Schristos (set pc (ext SI call)) 402b578a859Schristos ) 403b578a859Schristos () 404b578a859Schristos) 405b578a859Schristos 406b578a859Schristos(dni cmpe "compare equal" () 407b578a859Schristos "cmpe $r2,$r0,$r1" 408b578a859Schristos (+ OP_CMPE r0 r1 r2 (f-resv0 0)) 409b578a859Schristos (set r2 (eq SI r0 r1)) 410b578a859Schristos () 411b578a859Schristos) 412b578a859Schristos 413b578a859Schristos(dni cmpei "compare equal immediate" () 414b578a859Schristos "cmpei $r1,$r0,$imm" 415b578a859Schristos (+ OP_CMPEI r0 r1 imm) 416b578a859Schristos (set r1 (eq SI r0 (ext SI (trunc HI imm)))) 417b578a859Schristos () 418b578a859Schristos) 419b578a859Schristos 420b578a859Schristos(dni cmpg "compare greater than" () 421b578a859Schristos "cmpg $r2,$r0,$r1" 422b578a859Schristos (+ OP_CMPG r0 r1 r2 (f-resv0 0)) 423b578a859Schristos (set r2 (gt SI r0 r1)) 424b578a859Schristos () 425b578a859Schristos) 426b578a859Schristos 427b578a859Schristos(dni cmpgi "compare greater than immediate" () 428b578a859Schristos "cmpgi $r1,$r0,$imm" 429b578a859Schristos (+ OP_CMPGI r0 r1 imm) 430b578a859Schristos (set r1 (gt SI r0 (ext SI (trunc HI imm)))) 431b578a859Schristos () 432b578a859Schristos) 433b578a859Schristos 434b578a859Schristos(dni cmpge "compare greater or equal" () 435b578a859Schristos "cmpge $r2,$r0,$r1" 436b578a859Schristos (+ OP_CMPGE r0 r1 r2 (f-resv0 0)) 437b578a859Schristos (set r2 (ge SI r0 r1)) 438b578a859Schristos () 439b578a859Schristos) 440b578a859Schristos 441b578a859Schristos(dni cmpgei "compare greater or equal immediate" () 442b578a859Schristos "cmpgei $r1,$r0,$imm" 443b578a859Schristos (+ OP_CMPGEI r0 r1 imm) 444b578a859Schristos (set r1 (ge SI r0 (ext SI (trunc HI imm)))) 445b578a859Schristos () 446b578a859Schristos) 447b578a859Schristos 448b578a859Schristos(dni cmpgeu "compare greater or equal unsigned" () 449b578a859Schristos "cmpgeu $r2,$r0,$r1" 450b578a859Schristos (+ OP_CMPGEU r0 r1 r2 (f-resv0 0)) 451b578a859Schristos (set r2 (geu SI r0 r1)) 452b578a859Schristos () 453b578a859Schristos) 454b578a859Schristos 455b578a859Schristos(dni cmpgeui "compare greater or equal unsigned immediate" () 456b578a859Schristos "cmpgeui $r1,$r0,$uimm" 457b578a859Schristos (+ OP_CMPGEUI r0 r1 uimm) 458b578a859Schristos (set r1 (geu SI r0 (zext SI uimm))) 459b578a859Schristos () 460b578a859Schristos) 461b578a859Schristos 462b578a859Schristos(dni cmpgu "compare greater than unsigned" () 463b578a859Schristos "cmpgu $r2,$r0,$r1" 464b578a859Schristos (+ OP_CMPGU r0 r1 r2 (f-resv0 0)) 465b578a859Schristos (set r2 (gtu SI r0 r1)) 466b578a859Schristos () 467b578a859Schristos) 468b578a859Schristos 469b578a859Schristos(dni cmpgui "compare greater than unsigned immediate" () 470b578a859Schristos "cmpgui $r1,$r0,$uimm" 471b578a859Schristos (+ OP_CMPGUI r0 r1 uimm) 472b578a859Schristos (set r1 (gtu SI r0 (zext SI uimm))) 473b578a859Schristos () 474b578a859Schristos) 475b578a859Schristos 476b578a859Schristos(dni cmpne "compare not equal" () 477b578a859Schristos "cmpne $r2,$r0,$r1" 478b578a859Schristos (+ OP_CMPNE r0 r1 r2 (f-resv0 0)) 479b578a859Schristos (set r2 (ne SI r0 r1)) 480b578a859Schristos () 481b578a859Schristos) 482b578a859Schristos 483b578a859Schristos(dni cmpnei "compare not equal immediate" () 484b578a859Schristos "cmpnei $r1,$r0,$imm" 485b578a859Schristos (+ OP_CMPNEI r0 r1 imm) 486b578a859Schristos (set r1 (ne SI r0 (ext SI (trunc HI imm)))) 487b578a859Schristos () 488b578a859Schristos) 489b578a859Schristos 490b578a859Schristos(dni divu "unsigned divide" () 491b578a859Schristos "divu $r2,$r0,$r1" 492b578a859Schristos (+ OP_DIVU r0 r1 r2 (f-resv0 0)) 493b578a859Schristos (set pc (c-call USI "@cpu@_divu_insn" pc f-r0 f-r1 f-r2)) 494b578a859Schristos () 495b578a859Schristos) 496b578a859Schristos 497b578a859Schristos(dni lb "load byte" () 498b578a859Schristos "lb $r1,($r0+$imm)" 499b578a859Schristos (+ OP_LB r0 r1 imm) 500b578a859Schristos (set r1 (ext SI (mem QI (add r0 (ext SI (trunc HI imm)))))) 501b578a859Schristos () 502b578a859Schristos) 503b578a859Schristos 504b578a859Schristos(dni lbu "load byte unsigned" () 505b578a859Schristos "lbu $r1,($r0+$imm)" 506b578a859Schristos (+ OP_LBU r0 r1 imm) 507b578a859Schristos (set r1 (zext SI (mem QI (add r0 (ext SI (trunc HI imm)))))) 508b578a859Schristos () 509b578a859Schristos) 510b578a859Schristos 511b578a859Schristos(dni lh "load halfword" () 512b578a859Schristos "lh $r1,($r0+$imm)" 513b578a859Schristos (+ OP_LH r0 r1 imm) 514b578a859Schristos (set r1 (ext SI (mem HI (add r0 (ext SI (trunc HI imm)))))) 515b578a859Schristos () 516b578a859Schristos) 517b578a859Schristos 518b578a859Schristos(dni lhu "load halfword unsigned" () 519b578a859Schristos "lhu $r1,($r0+$imm)" 520b578a859Schristos (+ OP_LHU r0 r1 imm) 521b578a859Schristos (set r1 (zext SI (mem HI (add r0 (ext SI (trunc HI imm)))))) 522b578a859Schristos () 523b578a859Schristos) 524b578a859Schristos 525b578a859Schristos(dni lw "load word" () 526b578a859Schristos "lw $r1,($r0+$imm)" 527b578a859Schristos (+ OP_LW r0 r1 imm) 528b578a859Schristos (set r1 (mem SI (add r0 (ext SI (trunc HI imm))))) 529b578a859Schristos () 530b578a859Schristos) 531b578a859Schristos 532b578a859Schristos(dni modu "unsigned modulus" () 533b578a859Schristos "modu $r2,$r0,$r1" 534b578a859Schristos (+ OP_MODU r0 r1 r2 (f-resv0 0)) 535b578a859Schristos (set pc (c-call USI "@cpu@_modu_insn" pc f-r0 f-r1 f-r2)) 536b578a859Schristos () 537b578a859Schristos) 538b578a859Schristos 539b578a859Schristos(dni mul "mulitply" () 540b578a859Schristos "mul $r2,$r0,$r1" 541b578a859Schristos (+ OP_MUL r0 r1 r2 (f-resv0 0)) 542b578a859Schristos (set r2 (mul r0 r1)) 543b578a859Schristos () 544b578a859Schristos) 545b578a859Schristos 546b578a859Schristos(dni muli "multiply immediate" () 547b578a859Schristos "muli $r1,$r0,$imm" 548b578a859Schristos (+ OP_MULI r0 r1 imm) 549b578a859Schristos (set r1 (mul r0 (ext SI (trunc HI imm)))) 550b578a859Schristos () 551b578a859Schristos) 552b578a859Schristos 553b578a859Schristos(dni nor "nor" () 554b578a859Schristos "nor $r2,$r0,$r1" 555b578a859Schristos (+ OP_NOR r0 r1 r2 (f-resv0 0)) 556b578a859Schristos (set r2 (inv (or r0 r1))) 557b578a859Schristos () 558b578a859Schristos) 559b578a859Schristos 560b578a859Schristos(dni nori "nor immediate" () 561b578a859Schristos "nori $r1,$r0,$uimm" 562b578a859Schristos (+ OP_NORI r0 r1 uimm) 563b578a859Schristos (set r1 (inv (or r0 (zext SI uimm)))) 564b578a859Schristos () 565b578a859Schristos) 566b578a859Schristos 567b578a859Schristos(dni or "or" () 568b578a859Schristos "or $r2,$r0,$r1" 569b578a859Schristos (+ OP_OR r0 r1 r2 (f-resv0 0)) 570b578a859Schristos (set r2 (or r0 r1)) 571b578a859Schristos () 572b578a859Schristos) 573b578a859Schristos 574b578a859Schristos(dni ori "or immediate" () 575b578a859Schristos "ori $r1,$r0,$lo16" 576b578a859Schristos (+ OP_ORI r0 r1 lo16) 577b578a859Schristos (set r1 (or r0 (zext SI lo16))) 578b578a859Schristos () 579b578a859Schristos) 580b578a859Schristos 581b578a859Schristos(dni orhii "or high immediate" () 582b578a859Schristos "orhi $r1,$r0,$hi16" 583b578a859Schristos (+ OP_ORHI r0 r1 hi16) 584b578a859Schristos (set r1 (or r0 (sll SI hi16 16))) 585b578a859Schristos () 586b578a859Schristos) 587b578a859Schristos 588b578a859Schristos(dni rcsr "read control or status register" () 589b578a859Schristos "rcsr $r2,$csr" 590b578a859Schristos (+ OP_RCSR csr (f-r1 0) r2 (f-resv0 0)) 591b578a859Schristos (set r2 csr) 592b578a859Schristos () 593b578a859Schristos) 594b578a859Schristos 595b578a859Schristos(dni sb "store byte" () 596b578a859Schristos "sb ($r0+$imm),$r1" 597b578a859Schristos (+ OP_SB r0 r1 imm) 598b578a859Schristos (set (mem QI (add r0 (ext SI (trunc HI imm)))) r1) 599b578a859Schristos () 600b578a859Schristos) 601b578a859Schristos 602b578a859Schristos(dni sextb "sign extend byte" () 603b578a859Schristos "sextb $r2,$r0" 604b578a859Schristos (+ OP_SEXTB r0 (f-r1 0) r2 (f-resv0 0)) 605b578a859Schristos (set r2 (ext SI (trunc QI r0))) 606b578a859Schristos () 607b578a859Schristos) 608b578a859Schristos 609b578a859Schristos(dni sexth "sign extend half-word" () 610b578a859Schristos "sexth $r2,$r0" 611b578a859Schristos (+ OP_SEXTH r0 (f-r1 0) r2 (f-resv0 0)) 612b578a859Schristos (set r2 (ext SI (trunc HI r0))) 613b578a859Schristos () 614b578a859Schristos) 615b578a859Schristos 616b578a859Schristos(dni sh "store halfword" () 617b578a859Schristos "sh ($r0+$imm),$r1" 618b578a859Schristos (+ OP_SH r0 r1 imm) 619b578a859Schristos (set (mem HI (add r0 (ext SI (trunc HI imm)))) r1) 620b578a859Schristos () 621b578a859Schristos) 622b578a859Schristos 623b578a859Schristos(dni sl "shift left" () 624b578a859Schristos "sl $r2,$r0,$r1" 625b578a859Schristos (+ OP_SL r0 r1 r2 (f-resv0 0)) 626b578a859Schristos (set r2 (sll SI r0 r1)) 627b578a859Schristos () 628b578a859Schristos) 629b578a859Schristos 630b578a859Schristos(dni sli "shift left immediate" () 631b578a859Schristos "sli $r1,$r0,$imm" 632b578a859Schristos (+ OP_SLI r0 r1 imm) 633b578a859Schristos (set r1 (sll SI r0 imm)) 634b578a859Schristos () 635b578a859Schristos) 636b578a859Schristos 637b578a859Schristos(dni sr "shift right" () 638b578a859Schristos "sr $r2,$r0,$r1" 639b578a859Schristos (+ OP_SR r0 r1 r2 (f-resv0 0)) 640b578a859Schristos (set r2 (sra SI r0 r1)) 641b578a859Schristos () 642b578a859Schristos) 643b578a859Schristos 644b578a859Schristos(dni sri "shift right immediate" () 645b578a859Schristos "sri $r1,$r0,$imm" 646b578a859Schristos (+ OP_SRI r0 r1 imm) 647b578a859Schristos (set r1 (sra SI r0 imm)) 648b578a859Schristos () 649b578a859Schristos) 650b578a859Schristos 651b578a859Schristos(dni sru "shift right unsigned" () 652b578a859Schristos "sru $r2,$r0,$r1" 653b578a859Schristos (+ OP_SRU r0 r1 r2 (f-resv0 0)) 654b578a859Schristos (set r2 (srl SI r0 r1)) 655b578a859Schristos () 656b578a859Schristos) 657b578a859Schristos 658b578a859Schristos(dni srui "shift right unsigned immediate" () 659b578a859Schristos "srui $r1,$r0,$imm" 660b578a859Schristos (+ OP_SRUI r0 r1 imm) 661b578a859Schristos (set r1 (srl SI r0 imm)) 662b578a859Schristos () 663b578a859Schristos) 664b578a859Schristos 665b578a859Schristos(dni sub "subtract" () 666b578a859Schristos "sub $r2,$r0,$r1" 667b578a859Schristos (+ OP_SUB r0 r1 r2 (f-resv0 0)) 668b578a859Schristos (set r2 (sub r0 r1)) 669b578a859Schristos () 670b578a859Schristos) 671b578a859Schristos 672b578a859Schristos(dni sw "store word" () 673b578a859Schristos "sw ($r0+$imm),$r1" 674b578a859Schristos (+ OP_SW r0 r1 imm) 675b578a859Schristos (set (mem SI (add r0 (ext SI (trunc HI imm)))) r1) 676b578a859Schristos () 677b578a859Schristos) 678b578a859Schristos 679b578a859Schristos(dni user "user defined instruction" () 680b578a859Schristos "user $r2,$r0,$r1,$user" 681b578a859Schristos (+ OP_USER r0 r1 r2 user) 682b578a859Schristos (set r2 (c-call SI "@cpu@_user_insn" r0 r1 user)) 683b578a859Schristos () 684b578a859Schristos) 685b578a859Schristos 686b578a859Schristos(dni wcsr "write control or status register" () 687b578a859Schristos "wcsr $csr,$r1" 688b578a859Schristos (+ OP_WCSR csr r1 (f-r2 0) (f-resv0 0)) 689b578a859Schristos (c-call VOID "@cpu@_wcsr_insn" f-csr r1) 690b578a859Schristos () 691b578a859Schristos) 692b578a859Schristos 693b578a859Schristos(dni xor "xor" () 694b578a859Schristos "xor $r2,$r0,$r1" 695b578a859Schristos (+ OP_XOR r0 r1 r2 (f-resv0 0)) 696b578a859Schristos (set r2 (xor r0 r1)) 697b578a859Schristos () 698b578a859Schristos) 699b578a859Schristos 700b578a859Schristos(dni xori "xor immediate" () 701b578a859Schristos "xori $r1,$r0,$uimm" 702b578a859Schristos (+ OP_XORI r0 r1 uimm) 703b578a859Schristos (set r1 (xor r0 (zext SI uimm))) 704b578a859Schristos () 705b578a859Schristos) 706b578a859Schristos 707b578a859Schristos(dni xnor "xnor" () 708b578a859Schristos "xnor $r2,$r0,$r1" 709b578a859Schristos (+ OP_XNOR r0 r1 r2 (f-resv0 0)) 710b578a859Schristos (set r2 (inv (xor r0 r1))) 711b578a859Schristos () 712b578a859Schristos) 713b578a859Schristos 714b578a859Schristos(dni xnori "xnor immediate" () 715b578a859Schristos "xnori $r1,$r0,$uimm" 716b578a859Schristos (+ OP_XNORI r0 r1 uimm) 717b578a859Schristos (set r1 (inv (xor r0 (zext SI uimm)))) 718b578a859Schristos () 719b578a859Schristos) 720b578a859Schristos 721b578a859Schristos; Pseudo instructions 722b578a859Schristos 723b578a859Schristos(dni break "breakpoint" () 724b578a859Schristos "break" 725b578a859Schristos (+ OP_RAISE (f-exception 2)) 726b578a859Schristos (set pc (c-call USI "@cpu@_break_insn" pc)) 727b578a859Schristos () 728b578a859Schristos) 729b578a859Schristos 730b578a859Schristos(dni scall "system call" () 731b578a859Schristos "scall" 732b578a859Schristos (+ OP_RAISE (f-exception 7)) 733b578a859Schristos (set pc (c-call USI "@cpu@_scall_insn" pc)) 734b578a859Schristos () 735b578a859Schristos) 736b578a859Schristos 737b578a859Schristos(dni bret "return from breakpoint" (ALIAS) 738b578a859Schristos "bret" 739b578a859Schristos (+ OP_B (f-r0 31) (f-r1 0) (f-r2 0) (f-resv0 0)) 740b578a859Schristos (set pc (c-call USI "@cpu@_bret_insn" r0)) 741b578a859Schristos () 742b578a859Schristos) 743b578a859Schristos 744b578a859Schristos(dni eret "return from exception" (ALIAS) 745b578a859Schristos "eret" 746b578a859Schristos (+ OP_B (f-r0 30) (f-r1 0) (f-r2 0) (f-resv0 0)) 747b578a859Schristos (set pc (c-call USI "@cpu@_eret_insn" r0)) 748b578a859Schristos () 749b578a859Schristos) 750b578a859Schristos 751b578a859Schristos(dni ret "return" (ALIAS) 752b578a859Schristos "ret" 753b578a859Schristos (+ OP_B (f-r0 29) (f-r1 0) (f-r2 0) (f-resv0 0)) 754b578a859Schristos (set pc r0) 755b578a859Schristos () 756b578a859Schristos) 757b578a859Schristos 758b578a859Schristos(dni mv "move" (ALIAS) 759b578a859Schristos "mv $r2,$r0" 760b578a859Schristos (+ OP_OR r0 (f-r1 0) r2 (f-resv0 0)) 761b578a859Schristos (set r2 r0) 762b578a859Schristos () 763b578a859Schristos) 764b578a859Schristos 765b578a859Schristos(dni mvi "move immediate" (ALIAS) 766b578a859Schristos "mvi $r1,$imm" 767b578a859Schristos (+ OP_ADDI (f-r0 0) r1 imm) 768b578a859Schristos (set r1 (add r0 (ext SI (trunc HI imm)))) 769b578a859Schristos () 770b578a859Schristos) 771b578a859Schristos 772b578a859Schristos(dni mvui "move unsigned immediate" (ALIAS) 773b578a859Schristos "mvu $r1,$lo16" 774b578a859Schristos (+ OP_ORI (f-r0 0) r1 lo16) 775b578a859Schristos (set r1 (zext SI lo16)) 776b578a859Schristos () 777b578a859Schristos) 778b578a859Schristos 779b578a859Schristos(dni mvhi "move high immediate" (ALIAS) 780b578a859Schristos "mvhi $r1,$hi16" 781b578a859Schristos (+ OP_ORHI (f-r0 0) r1 hi16) 782b578a859Schristos (set r1 (or r0 (sll SI hi16 16))) 783b578a859Schristos () 784b578a859Schristos) 785b578a859Schristos 786b578a859Schristos(dni mva "move address" (ALIAS) 787b578a859Schristos "mva $r1,$gp16" 788b578a859Schristos (+ OP_ADDI (f-r0 26) r1 gp16) 789b578a859Schristos (set r1 (add r0 (ext SI (trunc HI gp16)))) 790b578a859Schristos () 791b578a859Schristos) 792b578a859Schristos 793b578a859Schristos(dni not "not" (ALIAS) 794b578a859Schristos "not $r2,$r0" 795b578a859Schristos (+ OP_XNOR r0 (f-r1 0) r2 (f-resv0 0)) 796b578a859Schristos (set r2 (inv r0)) 797b578a859Schristos () 798b578a859Schristos) 799b578a859Schristos 800b578a859Schristos(dni nop "nop" (ALIAS) 801b578a859Schristos "nop" 802b578a859Schristos (+ OP_ADDI (f-r0 0) (f-r1 0) (f-imm 0)) 803b578a859Schristos (set r0 r0) 804b578a859Schristos () 805b578a859Schristos) 806b578a859Schristos 807b578a859Schristos(dni lbgprel "load byte gp relative" (ALIAS) 808b578a859Schristos "lb $r1,$gp16" 809b578a859Schristos (+ OP_LB (f-r0 26) r1 gp16) 810b578a859Schristos (set r1 (ext SI (mem QI (add r0 (ext SI (trunc HI gp16)))))) 811b578a859Schristos () 812b578a859Schristos) 813b578a859Schristos 814b578a859Schristos(dni lbugprel "load byte unsigned gp relative" (ALIAS) 815b578a859Schristos "lbu $r1,$gp16" 816b578a859Schristos (+ OP_LBU (f-r0 26) r1 gp16) 817b578a859Schristos (set r1 (zext SI (mem QI (add r0 (ext SI (trunc HI gp16)))))) 818b578a859Schristos () 819b578a859Schristos) 820b578a859Schristos 821b578a859Schristos(dni lhgprel "load halfword gp relative" (ALIAS) 822b578a859Schristos "lh $r1,$gp16" 823b578a859Schristos (+ OP_LH (f-r0 26) r1 gp16) 824b578a859Schristos (set r1 (ext SI (mem HI (add r0 (ext SI (trunc HI gp16)))))) 825b578a859Schristos () 826b578a859Schristos) 827b578a859Schristos 828b578a859Schristos(dni lhugprel "load halfword unsigned gp relative" (ALIAS) 829b578a859Schristos "lhu $r1,$gp16" 830b578a859Schristos (+ OP_LHU (f-r0 26) r1 gp16) 831b578a859Schristos (set r1 (zext SI (mem HI (add r0 (ext SI (trunc HI gp16)))))) 832b578a859Schristos () 833b578a859Schristos) 834b578a859Schristos 835b578a859Schristos(dni lwgprel "load word gp relative" (ALIAS) 836b578a859Schristos "lw $r1,$gp16" 837b578a859Schristos (+ OP_LW (f-r0 26) r1 gp16) 838b578a859Schristos (set r1 (mem SI (add r0 (ext SI (trunc HI gp16))))) 839b578a859Schristos () 840b578a859Schristos) 841b578a859Schristos 842b578a859Schristos(dni sbgprel "store byte gp relative" (ALIAS) 843b578a859Schristos "sb $gp16,$r1" 844b578a859Schristos (+ OP_SB (f-r0 26) r1 gp16) 845b578a859Schristos (set (mem QI (add r0 (ext SI (trunc HI gp16)))) r1) 846b578a859Schristos () 847b578a859Schristos) 848b578a859Schristos 849b578a859Schristos(dni shgprel "store halfword gp relative" (ALIAS) 850b578a859Schristos "sh $gp16,$r1" 851b578a859Schristos (+ OP_SH (f-r0 26) r1 gp16) 852b578a859Schristos (set (mem HI (add r0 (ext SI (trunc HI gp16)))) r1) 853b578a859Schristos () 854b578a859Schristos) 855b578a859Schristos 856b578a859Schristos(dni swgprel "store word gp relative" (ALIAS) 857b578a859Schristos "sw $gp16,$r1" 858b578a859Schristos (+ OP_SW (f-r0 26) r1 gp16) 859b578a859Schristos (set (mem SI (add r0 (ext SI (trunc HI gp16)))) r1) 860b578a859Schristos () 861b578a859Schristos) 862b578a859Schristos 863b578a859Schristos(dni lwgotrel "load word got relative" (ALIAS) 864b578a859Schristos "lw $r1,(gp+$got16)" 865b578a859Schristos (+ OP_LW (f-r0 26) r1 got16) 866b578a859Schristos (set r1 (mem SI (add r0 (ext SI (trunc HI got16))))) 867b578a859Schristos () 868b578a859Schristos) 869b578a859Schristos 870b578a859Schristos(dni orhigotoffi "or high got offset immediate" (ALIAS) 871b578a859Schristos "orhi $r1,$r0,$gotoffhi16" 872b578a859Schristos (+ OP_ORHI r0 r1 gotoffhi16) 873b578a859Schristos (set r1 (or r0 (sll SI gotoffhi16 16))) 874b578a859Schristos () 875b578a859Schristos) 876b578a859Schristos 877b578a859Schristos(dni addgotoff "add got offset" (ALIAS) 878b578a859Schristos "addi $r1,$r0,$gotofflo16" 879b578a859Schristos (+ OP_ADDI r0 r1 gotofflo16) 880b578a859Schristos (set r1 (add r0 (ext SI (trunc HI gotofflo16)))) 881b578a859Schristos () 882b578a859Schristos) 883b578a859Schristos 884b578a859Schristos(dni swgotoff "store word got offset" (ALIAS) 885b578a859Schristos "sw ($r0+$gotofflo16),$r1" 886b578a859Schristos (+ OP_SW r0 r1 gotofflo16) 887b578a859Schristos (set (mem SI (add r0 (ext SI (trunc HI gotofflo16)))) r1) 888b578a859Schristos () 889b578a859Schristos) 890b578a859Schristos 891b578a859Schristos(dni lwgotoff "load word got offset" (ALIAS) 892b578a859Schristos "lw $r1,($r0+$gotofflo16)" 893b578a859Schristos (+ OP_LW r0 r1 gotofflo16) 894b578a859Schristos (set r1 (mem SI (add r0 (ext SI (trunc HI gotofflo16))))) 895b578a859Schristos () 896b578a859Schristos) 897b578a859Schristos 898b578a859Schristos(dni shgotoff "store half word got offset" (ALIAS) 899b578a859Schristos "sh ($r0+$gotofflo16),$r1" 900b578a859Schristos (+ OP_SH r0 r1 gotofflo16) 901b578a859Schristos (set (mem HI (add r0 (ext SI (trunc HI gotofflo16)))) r1) 902b578a859Schristos () 903b578a859Schristos) 904b578a859Schristos 905b578a859Schristos(dni lhgotoff "load half word got offset" (ALIAS) 906b578a859Schristos "lh $r1,($r0+$gotofflo16)" 907b578a859Schristos (+ OP_LH r0 r1 gotofflo16) 908b578a859Schristos (set r1 (ext SI (mem HI (add r0 (ext SI (trunc HI gotofflo16)))))) 909b578a859Schristos () 910b578a859Schristos) 911b578a859Schristos 912b578a859Schristos(dni lhugotoff "load half word got offset unsigned" (ALIAS) 913b578a859Schristos "lhu $r1,($r0+$gotofflo16)" 914b578a859Schristos (+ OP_LHU r0 r1 gotofflo16) 915b578a859Schristos (set r1 (zext SI (mem HI (add r0 (ext SI (trunc HI gotofflo16)))))) 916b578a859Schristos () 917b578a859Schristos) 918b578a859Schristos 919b578a859Schristos(dni sbgotoff "store byte got offset" (ALIAS) 920b578a859Schristos "sb ($r0+$gotofflo16),$r1" 921b578a859Schristos (+ OP_SB r0 r1 gotofflo16) 922b578a859Schristos (set (mem QI (add r0 (ext SI (trunc HI gotofflo16)))) r1) 923b578a859Schristos () 924b578a859Schristos) 925b578a859Schristos 926b578a859Schristos(dni lbgotoff "load byte got offset" (ALIAS) 927b578a859Schristos "lb $r1,($r0+$gotofflo16)" 928b578a859Schristos (+ OP_LB r0 r1 gotofflo16) 929b578a859Schristos (set r1 (ext SI (mem QI (add r0 (ext SI (trunc HI gotofflo16)))))) 930b578a859Schristos () 931b578a859Schristos) 932b578a859Schristos 933b578a859Schristos(dni lbugotoff "load byte got offset unsigned" (ALIAS) 934b578a859Schristos "lbu $r1,($r0+$gotofflo16)" 935b578a859Schristos (+ OP_LBU r0 r1 gotofflo16) 936b578a859Schristos (set r1 (zext SI (mem QI (add r0 (ext SI (trunc HI gotofflo16)))))) 937b578a859Schristos () 938b578a859Schristos) 939