2 /*---------------------------------------------------------------*/
3 /*--- begin host_mips_defs.h ---*/
4 /*---------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2010-2017 RT-RK
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of the
15 License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, see <http://www.gnu.org/licenses/>.
25 The GNU General Public License is contained in the file COPYING.
28 #ifndef __VEX_HOST_MIPS_DEFS_H
29 #define __VEX_HOST_MIPS_DEFS_H
31 #include "libvex_basictypes.h"
32 #include "libvex.h" /* VexArch */
33 #include "host_generic_regs.h" /* HReg */
36 /* --------- Registers. --------- */
38 #define ST_IN static inline
40 #define GPR(_mode64, _enc, _ix64, _ix32) \
41 mkHReg(False, (_mode64) ? HRcInt64 : HRcInt32, \
42 (_enc), (_mode64) ? (_ix64) : (_ix32))
44 #define FR(_mode64, _enc, _ix64, _ix32) \
45 mkHReg(False, (_mode64) ? HRcFlt64 : HRcFlt32, \
46 (_enc), (_mode64) ? (_ix64) : (_ix32))
48 #define DR(_mode64, _enc, _ix64, _ix32) \
49 mkHReg(False, HRcFlt64, \
50 (_enc), (_mode64) ? (_ix64) : (_ix32))
52 #define VEC(_mode64, _enc, _ix64, _ix32) \
53 mkHReg(False, HRcVec128, \
54 (_enc), (_mode64) ? (_ix64) : (_ix32))
56 ST_IN HReg
hregMIPS_GPR16 ( Bool mode64
) { return GPR(mode64
, 16, 0, 0); }
57 ST_IN HReg
hregMIPS_GPR17 ( Bool mode64
) { return GPR(mode64
, 17, 1, 1); }
58 ST_IN HReg
hregMIPS_GPR18 ( Bool mode64
) { return GPR(mode64
, 18, 2, 2); }
59 ST_IN HReg
hregMIPS_GPR19 ( Bool mode64
) { return GPR(mode64
, 19, 3, 3); }
60 ST_IN HReg
hregMIPS_GPR20 ( Bool mode64
) { return GPR(mode64
, 20, 4, 4); }
61 ST_IN HReg
hregMIPS_GPR21 ( Bool mode64
) { return GPR(mode64
, 21, 5, 5); }
62 ST_IN HReg
hregMIPS_GPR22 ( Bool mode64
) { return GPR(mode64
, 22, 6, 6); }
64 ST_IN HReg
hregMIPS_GPR12 ( Bool mode64
) { return GPR(mode64
, 12, 7, 7); }
65 ST_IN HReg
hregMIPS_GPR13 ( Bool mode64
) { return GPR(mode64
, 13, 8, 8); }
66 ST_IN HReg
hregMIPS_GPR14 ( Bool mode64
) { return GPR(mode64
, 14, 9, 9); }
67 ST_IN HReg
hregMIPS_GPR15 ( Bool mode64
) { return GPR(mode64
, 15, 10, 10); }
68 ST_IN HReg
hregMIPS_GPR24 ( Bool mode64
) { return GPR(mode64
, 24, 11, 11); }
70 ST_IN HReg
hregMIPS_F16 ( Bool mode64
) { return FR (mode64
, 16, 12, 12); }
71 ST_IN HReg
hregMIPS_F18 ( Bool mode64
) { return FR (mode64
, 18, 13, 13); }
72 ST_IN HReg
hregMIPS_F20 ( Bool mode64
) { return FR (mode64
, 20, 14, 14); }
73 ST_IN HReg
hregMIPS_F22 ( Bool mode64
) { return FR (mode64
, 22, 15, 15); }
74 ST_IN HReg
hregMIPS_F24 ( Bool mode64
) { return FR (mode64
, 24, 16, 16); }
75 ST_IN HReg
hregMIPS_F26 ( Bool mode64
) { return FR (mode64
, 26, 17, 17); }
76 ST_IN HReg
hregMIPS_F28 ( Bool mode64
) { return FR (mode64
, 28, 18, 18); }
77 ST_IN HReg
hregMIPS_F30 ( Bool mode64
) { return FR (mode64
, 30, 19, 19); }
79 ST_IN HReg
hregMIPS_W16 ( Bool mode64
) { return VEC(mode64
, 1, 20, 20); }
80 ST_IN HReg
hregMIPS_W17 ( Bool mode64
) { return VEC(mode64
, 3, 21, 21); }
81 ST_IN HReg
hregMIPS_W18 ( Bool mode64
) { return VEC(mode64
, 5, 22, 22); }
82 ST_IN HReg
hregMIPS_W19 ( Bool mode64
) { return VEC(mode64
, 7, 23, 23); }
83 ST_IN HReg
hregMIPS_W20 ( Bool mode64
) { return VEC(mode64
, 9, 24, 24); }
84 ST_IN HReg
hregMIPS_W21 ( Bool mode64
) { return VEC(mode64
, 11, 25, 25); }
85 ST_IN HReg
hregMIPS_W22 ( Bool mode64
) { return VEC(mode64
, 13, 26, 26); }
86 ST_IN HReg
hregMIPS_W23 ( Bool mode64
) { return VEC(mode64
, 15, 27, 27); }
87 ST_IN HReg
hregMIPS_W24 ( Bool mode64
) { return VEC(mode64
, 17, 28, 28); }
88 ST_IN HReg
hregMIPS_W25 ( Bool mode64
) { return VEC(mode64
, 19, 29, 29); }
89 ST_IN HReg
hregMIPS_W26 ( Bool mode64
) { return VEC(mode64
, 21, 30, 30); }
90 ST_IN HReg
hregMIPS_W27 ( Bool mode64
) { return VEC(mode64
, 23, 31, 31); }
91 ST_IN HReg
hregMIPS_W28 ( Bool mode64
) { return VEC(mode64
, 25, 32, 32); }
92 ST_IN HReg
hregMIPS_W29 ( Bool mode64
) { return VEC(mode64
, 27, 33, 33); }
93 ST_IN HReg
hregMIPS_W30 ( Bool mode64
) { return VEC(mode64
, 29, 34, 34); }
94 ST_IN HReg
hregMIPS_W31 ( Bool mode64
) { return VEC(mode64
, 31, 35, 35); }
96 // DRs are only allocatable in 32-bit mode, so the 64-bit index numbering
97 // doesn't advance here.
98 ST_IN HReg
hregMIPS_D0 ( Bool mode64
) { vassert(!mode64
);
99 return DR (mode64
, 0, 0, 36); }
100 ST_IN HReg
hregMIPS_D1 ( Bool mode64
) { vassert(!mode64
);
101 return DR (mode64
, 2, 0, 37); }
102 ST_IN HReg
hregMIPS_D2 ( Bool mode64
) { vassert(!mode64
);
103 return DR (mode64
, 4, 0, 38); }
104 ST_IN HReg
hregMIPS_D3 ( Bool mode64
) { vassert(!mode64
);
105 return DR (mode64
, 6, 0, 39); }
106 ST_IN HReg
hregMIPS_D4 ( Bool mode64
) { vassert(!mode64
);
107 return DR (mode64
, 8, 0, 40); }
108 ST_IN HReg
hregMIPS_D5 ( Bool mode64
) { vassert(!mode64
);
109 return DR (mode64
, 10, 0, 41); }
110 ST_IN HReg
hregMIPS_D6 ( Bool mode64
) { vassert(!mode64
);
111 return DR (mode64
, 12, 0, 42); }
112 ST_IN HReg
hregMIPS_D7 ( Bool mode64
) { vassert(!mode64
);
113 return DR (mode64
, 14, 0, 43); }
115 ST_IN HReg
hregMIPS_HI ( Bool mode64
) { return FR (mode64
, 33, 36, 44); }
116 ST_IN HReg
hregMIPS_LO ( Bool mode64
) { return FR (mode64
, 34, 37, 45); }
118 ST_IN HReg
hregMIPS_GPR0 ( Bool mode64
) { return GPR(mode64
, 0, 38, 46); }
119 ST_IN HReg
hregMIPS_GPR1 ( Bool mode64
) { return GPR(mode64
, 1, 39, 47); }
120 ST_IN HReg
hregMIPS_GPR2 ( Bool mode64
) { return GPR(mode64
, 2, 40, 48); }
121 ST_IN HReg
hregMIPS_GPR3 ( Bool mode64
) { return GPR(mode64
, 3, 41, 49); }
122 ST_IN HReg
hregMIPS_GPR4 ( Bool mode64
) { return GPR(mode64
, 4, 42, 50); }
123 ST_IN HReg
hregMIPS_GPR5 ( Bool mode64
) { return GPR(mode64
, 5, 43, 51); }
124 ST_IN HReg
hregMIPS_GPR6 ( Bool mode64
) { return GPR(mode64
, 6, 44, 52); }
125 ST_IN HReg
hregMIPS_GPR7 ( Bool mode64
) { return GPR(mode64
, 7, 45, 53); }
126 ST_IN HReg
hregMIPS_GPR8 ( Bool mode64
) { return GPR(mode64
, 8, 46, 54); }
127 ST_IN HReg
hregMIPS_GPR9 ( Bool mode64
) { return GPR(mode64
, 9, 47, 55); }
128 ST_IN HReg
hregMIPS_GPR10 ( Bool mode64
) { return GPR(mode64
, 10, 48, 56); }
129 ST_IN HReg
hregMIPS_GPR11 ( Bool mode64
) { return GPR(mode64
, 11, 49, 57); }
130 ST_IN HReg
hregMIPS_GPR23 ( Bool mode64
) { return GPR(mode64
, 23, 50, 58); }
131 ST_IN HReg
hregMIPS_GPR25 ( Bool mode64
) { return GPR(mode64
, 25, 51, 59); }
132 ST_IN HReg
hregMIPS_GPR29 ( Bool mode64
) { return GPR(mode64
, 29, 52, 60); }
133 ST_IN HReg
hregMIPS_GPR31 ( Bool mode64
) { return GPR(mode64
, 31, 53, 61); }
141 #define GuestStatePointer(_mode64) hregMIPS_GPR23(_mode64)
142 #define StackFramePointer(_mode64) hregMIPS_GPR30(_mode64)
143 #define StackPointer(_mode64) hregMIPS_GPR29(_mode64)
144 #define Zero(_mode64) hregMIPS_GPR0(_mode64)
146 /* guest_COND offset */
147 #define COND_OFFSET(_mode64) ((_mode64) ? 588 : 448)
149 /* guest_MSACSR offset */
150 #define MSACSR_OFFSET(_mode64) ((_mode64) ? 1144 : 1016)
152 /* Num registers used for function calls */
153 #if defined(VGP_mips32_linux)
155 # define MIPS_N_REGPARMS 4
157 /* a0, a1, a2, a3, a4, a5, a6, a7 */
158 # define MIPS_N_REGPARMS 8
161 extern UInt
ppHRegMIPS ( HReg
, Bool
);
163 #define OPC_MSA 0x78000000
165 /* --------- Condition codes, Intel encoding. --------- */
167 MIPScc_EQ
= 0, /* equal */
168 MIPScc_NE
= 1, /* not equal */
170 MIPScc_HS
= 2, /* >=u (higher or same) */
171 MIPScc_LO
= 3, /* <u (lower) */
173 MIPScc_MI
= 4, /* minus (negative) */
174 MIPScc_PL
= 5, /* plus (zero or +ve) */
176 MIPScc_VS
= 6, /* overflow */
177 MIPScc_VC
= 7, /* no overflow */
179 MIPScc_HI
= 8, /* >u (higher) */
180 MIPScc_LS
= 9, /* <=u (lower or same) */
182 MIPScc_GE
= 10, /* >=s (signed greater or equal) */
183 MIPScc_LT
= 11, /* <s (signed less than) */
185 MIPScc_GT
= 12, /* >s (signed greater) */
186 MIPScc_LE
= 13, /* <=s (signed less or equal) */
188 MIPScc_AL
= 14, /* always (unconditional) */
189 MIPScc_NV
= 15 /* never (unconditional): */
192 extern const HChar
*showMIPSCondCode(MIPSCondCode
);
194 /* --------- Memory address expressions (amodes). --------- */
196 Mam_IR
, /* Immediate (signed 16-bit) + Reg */
197 Mam_RR
/* Reg1 + Reg2 */
214 extern MIPSAMode
*MIPSAMode_IR(Int
, HReg
);
215 extern MIPSAMode
*MIPSAMode_RR(HReg
, HReg
);
217 extern MIPSAMode
*dopyMIPSAMode(MIPSAMode
*);
218 extern MIPSAMode
*nextMIPSAModeFloat(MIPSAMode
*);
219 extern MIPSAMode
*nextMIPSAModeInt(MIPSAMode
*);
221 extern void ppMIPSAMode(MIPSAMode
*, Bool
);
223 /* --------- Operand, which can be a reg or a u16/s16. --------- */
224 /* ("RH" == "Register or Halfword immediate") */
243 extern void ppMIPSRH(MIPSRH
*, Bool
);
245 extern MIPSRH
*MIPSRH_Imm(Bool
, UShort
);
246 extern MIPSRH
*MIPSRH_Reg(HReg
);
248 /* --------- Instructions. --------- */
250 /*Tags for operations*/
261 extern const HChar
*showMIPSUnaryOp(MIPSUnaryOp
);
269 Malu_AND
, Malu_OR
, Malu_NOR
, Malu_XOR
,
270 Malu_DADD
, Malu_DSUB
,
274 extern const HChar
*showMIPSAluOp(MIPSAluOp
,
275 Bool
/* is the 2nd operand an immediate? */ );
280 Mshft_SLL
, Mshft_SRL
,
284 extern const HChar
*showMIPSShftOp(MIPSShftOp
,
285 Bool
/* is the 2nd operand an immediate? */ ,
286 Bool
/* is this a 32bit or 64bit op? */ );
294 extern const HChar
*showMIPSMaccOp(MIPSMaccOp
, Bool
);
302 extern const HChar
*showMsaMI10op(MSAMI10Op
);
315 extern const HChar
*showMsaElmOp(MSAELMOp
);
324 extern const HChar
*showMsa2ROp(MSA2ROp
);
327 MSA_FTRUNC_S
= 0x191,
328 MSA_FTRUNC_U
= 0x192,
340 extern const HChar
*showMsa2RFOp(MSA2RFOp
);
351 MSA_SUBS_U
= 0x800011,
356 MSA_PCKEV
= 0x1000014,
357 MSA_MAX_U
= 0x180000E,
360 MSA_PCKOD
= 0x1800014,
361 MSA_MIN_S
= 0x200000E,
362 MSA_ILVL
= 0x2000014,
363 MSA_MIN_U
= 0x280000E,
364 MSA_ILVR
= 0x2800014,
365 MSA_AVER_S
= 0x3000010,
366 MSA_ILVEV
= 0x3000014,
367 MSA_AVER_U
= 0x3800010,
368 MSA_ILVOD
= 0x3800014,
369 MSA_MULV
= 0x0000012,
370 MSA_SPLAT
= 0x0800014,
371 MSA_DIVS
= 0x2000012,
372 MSA_DIVU
= 0x2800012,
373 MSA_VSHF
= 0x0000015,
376 extern const HChar
*showMsa3ROp(MSA3ROp
);
379 MSA_FADD
= 0x000001B,
380 MSA_FCUN
= 0x040001A,
381 MSA_FSUB
= 0x040001B,
382 MSA_FCEQ
= 0x080001A,
383 MSA_FMUL
= 0x080001B,
384 MSA_FDIV
= 0x0C0001B,
385 MSA_FMADD
= 0x100001B,
386 MSA_FCLT
= 0x100001A,
387 MSA_FMSUB
= 0x140001B,
388 MSA_FEXP2
= 0x1C0001B,
389 MSA_FMIN
= 0x300001B,
390 MSA_FMIN_A
= 0x340001B,
391 MSA_FMAX
= 0x380001B,
392 MSA_MUL_Q
= 0x100001C,
393 MSA_FCLE
= 0x180001A,
395 MSA_FEXDO
= 0x200001B,
396 MSA_MULR_Q
= 0x300001C,
399 extern const HChar
*showMsa3RFOp(MSA3RFOp
);
408 extern const HChar
*showMsaVecOp(MSAVECOp
);
414 MSA_SRLI
= 0x1000009,
415 MSA_SRARI
= 0x100000A
418 extern const HChar
*showMsaBitOp(MSABITOp
);
427 extern HChar
showMsaDF(MSADF df
);
441 extern HChar
showMsaDFF(MSADFFlx df
, int op
);
444 /* ----- Instruction tags ----- */
446 Min_LI
, /* load word (32/64-bit) immediate (fake insn) */
447 Min_Alu
, /* word add/sub/and/or/xor/nor/others? */
448 Min_Shft
, /* word sll/srl/sra */
449 Min_Unary
, /* clo, clz, nop, neg */
450 Min_Ext
, /* ext / dext, dextm, dextu */
453 Min_Cmp
, /* word compare (fake insn) */
455 Min_Mul
, /* non-widening, 32-bit, signed multiply */
456 Min_Mult
, /* widening multiply */
461 Min_Call
, /* call to address in register */
463 /* The following 5 insns are mandated by translation chaining */
464 Min_XDirect
, /* direct transfer to GA */
465 Min_XIndir
, /* indirect transfer to GA */
466 Min_XAssisted
, /* assisted transfer to GA */
467 Min_EvCheck
, /* Event check */
468 Min_ProfInc
, /* 64-bit profile counter increment */
470 Min_RdWrLR
, /* Read/Write Link Register */
471 Min_Mthi
, /* Move to HI from GP register */
472 Min_Mtlo
, /* Move to LO from GP register */
473 Min_Mfhi
, /* Move from HI to GP register */
474 Min_Mflo
, /* Move from LO to GP register */
475 Min_Macc
, /* Multiply and accumulate */
477 Min_Load
, /* zero-extending load a 8|16|32 bit value from mem */
478 Min_Store
, /* store a 8|16|32 bit value to mem */
479 Min_Cas
, /* compare and swap */
480 Min_LoadL
, /* mips Load Linked Word - LL */
481 Min_StoreC
, /* mips Store Conditional Word - SC */
483 Min_FpUnary
, /* FP unary op */
484 Min_FpBinary
, /* FP binary op */
485 Min_FpTernary
, /* FP ternary op */
486 Min_FpConvert
, /* FP conversion op */
487 Min_FpMulAcc
, /* FP multipy-accumulate style op */
488 Min_FpLdSt
, /* FP load/store */
489 Min_FpSTFIW
, /* stfiwx */
490 Min_FpRSP
, /* FP round IEEE754 double to IEEE754 single */
491 Min_FpCftI
, /* fcfid/fctid/fctiw */
492 Min_FpCMov
, /* FP floating point conditional move */
493 Min_MtFCSR
, /* set FCSR register */
494 Min_MfFCSR
, /* get FCSR register */
495 Min_FpCompare
, /* FP compare, generating value into int reg */
496 Min_FpMinMax
, /* FP r6 min and max*/
498 Min_FpGpMove
, /* Move from/to fpr to/from gpr */
499 Min_MoveCond
, /* Move Conditional */
516 Mfp_MADDD
, Mfp_MSUBD
,
517 Mfp_MADDS
, Mfp_MSUBS
,
520 Mfp_ADDD
, Mfp_SUBD
, Mfp_MULD
, Mfp_DIVD
,
521 Mfp_ADDS
, Mfp_SUBS
, Mfp_MULS
, Mfp_DIVS
,
524 Mfp_SQRTS
, Mfp_SQRTD
,
525 Mfp_ABSS
, Mfp_ABSD
, Mfp_NEGS
, Mfp_NEGD
, Mfp_MOVS
, Mfp_MOVD
,
528 Mfp_CVTSD
, Mfp_CVTSW
, Mfp_CVTWD
,
529 Mfp_CVTWS
, Mfp_CVTDL
, Mfp_CVTSL
, Mfp_CVTLS
, Mfp_CVTLD
, Mfp_TRULS
, Mfp_TRULD
,
530 Mfp_TRUWS
, Mfp_TRUWD
, Mfp_FLOORWS
, Mfp_FLOORWD
, Mfp_ROUNDWS
, Mfp_ROUNDWD
,
531 Mfp_CVTDW
, Mfp_CEILWS
, Mfp_CEILWD
, Mfp_CEILLS
, Mfp_CEILLD
, Mfp_CVTDS
,
532 Mfp_ROUNDLD
, Mfp_FLOORLD
, Mfp_RINTS
, Mfp_RINTD
,
535 Mfp_CMP_UN
, Mfp_CMP_EQ
, Mfp_CMP_LT
, Mfp_CMP_NGT
,
537 Mfp_CMP_UN_S
, Mfp_CMP_EQ_S
, Mfp_CMP_LT_S
, Mfp_CMP_NGT_S
,
540 Mfp_MAXS
, Mfp_MAXD
, Mfp_MINS
, Mfp_MIND
544 extern const HChar
*showMIPSFpOp(MIPSFpOp
);
551 extern const HChar
*showRotxOp(MIPSRotxOp
);
553 /* Move from/to fpr to/from gpr */
555 MFpGpMove_mfc1
, /* Move Word From Floating Point - MIPS32 */
556 MFpGpMove_dmfc1
, /* Doubleword Move from Floating Point - MIPS64 */
557 MFpGpMove_mtc1
, /* Move Word to Floating Point - MIPS32 */
558 MFpGpMove_dmtc1
/* Doubleword Move to Floating Point - MIPS64 */
561 extern const HChar
*showMIPSFpGpMoveOp ( MIPSFpGpMoveOp
);
563 /* Move Conditional */
565 MFpMoveCond_movns
, /* FP Move Conditional on Not Zero - MIPS32 */
567 MMoveCond_movn
, /* Move Conditional on Not Zero */
568 MSeleqz
, /* r6 instructions */
574 extern const HChar
*showMIPSMoveCondOp ( MIPSMoveCondOp
);
576 /*--------- Structure for instructions ----------*/
577 /* Destinations are on the LEFT (first operand) */
582 /* Get a 32/64-bit literal into a register.
583 May turn into a number of real insns. */
588 /* Integer add/sub/and/or/xor. Limitations:
589 - For add, the immediate, if it exists, is a signed 16.
590 - For sub, the immediate, if it exists, is a signed 16
591 which may not be -32768, since no such instruction
592 exists, and so we have to emit addi with +32768, but
593 that is not possible.
594 - For and/or/xor, the immediate, if it exists,
603 /* Integer shl/shr/sar.
604 Limitations: the immediate, if it exists,
605 is a signed 5-bit value between 1 and 31 inclusive.
609 Bool sz32
; /* mode64 has both 32 and 64bit shft */
635 /* Word compare. Fake instruction, used for basic block ending */
646 Bool widening
; /* True => widening, False => non-widening */
647 Bool syned
; /* signed/unsigned - meaningless if widenind = False */
654 Bool syned
; /* signed/unsigned */
659 Bool syned
; /* signed/unsigned - meaningless if widenind = False */
667 Bool syned
; /* signed/unsigned - meaningless if widenind = False */
673 Bool syned
; /* signed/unsigned - meaningless if widenind = False */
680 /* Pseudo-insn. Call target (an absolute address), on given
681 condition (which could be Mcc_ALWAYS). argiregs indicates
682 which of $4 .. $7 (mips32) or $4 .. $11 (mips64)
683 carries argument values for this call,
684 using a bit mask (1<<N is set if $N holds an arg, for N in
685 $4 .. $7 or $4 .. $11 inclusive).
686 If cond is != Mcc_ALWAYS, src is checked.
687 Otherwise, unconditional call */
693 RetLoc rloc
; /* where the return value will be */
695 /* Update the guest EIP value, then exit requesting to chain
696 to it. May be conditional. Urr, use of Addr32 implicitly
697 assumes that wordsize(guest) == wordsize(host). */
699 Addr64 dstGA
; /* next guest address */
700 MIPSAMode
* amPC
; /* amode in guest state for PC */
701 MIPSCondCode cond
; /* can be MIPScc_AL */
702 Bool toFastEP
; /* chain to the slow or fast point? */
704 /* Boring transfer to a guest address not known at JIT time.
705 Not chainable. May be conditional. */
709 MIPSCondCode cond
; /* can be MIPScc_AL */
711 /* Assisted transfer to a guest address, most general case.
712 Not chainable. May be conditional. */
716 MIPSCondCode cond
; /* can be MIPScc_AL */
719 /* Zero extending loads. Dst size is host word size */
721 UChar sz
; /* 1|2|4|8 */
729 /* 64/32/16/8 bit stores */
731 UChar sz
; /* 1|2|4|8 */
752 /* Move from HI/LO register to GP register. */
757 /* Move to HI/LO register from GP register. */
762 /* Read/Write Link Register */
768 /* MIPS Multiply and accumulate instructions. */
777 /* MIPS Floating point */
805 UChar sz
; /* only 4 (IEEE single) or 8 (IEEE double) */
828 /* Move from GP register to FCSR register. */
832 /* Move from FCSR register to GP register. */
837 MIPSAMode
* amCounter
;
838 MIPSAMode
* amFailAddr
;
841 /* No fields. The address of the counter to inc is
842 installed later, post-translation, by patching it in,
843 as it is not known at translation time. */
846 /* Move from/to fpr to/from gpr */
914 extern MIPSInstr
*MIPSInstr_LI(HReg
, ULong
);
915 extern MIPSInstr
*MIPSInstr_Alu(MIPSAluOp
, HReg
, HReg
, MIPSRH
*);
916 extern MIPSInstr
*MIPSInstr_Shft(MIPSShftOp
, Bool sz32
, HReg
, HReg
, MIPSRH
*);
917 extern MIPSInstr
*MIPSInstr_Unary(MIPSUnaryOp op
, HReg dst
, HReg src
);
918 extern MIPSInstr
*MIPSInstr_Ext(HReg
, HReg
, UInt
, UInt
);
919 extern MIPSInstr
*MIPSInstr_Cmp(Bool
, Bool
, HReg
, HReg
, HReg
, MIPSCondCode
);
920 extern MIPSInstr
*MIPSInstr_Mul(HReg
, HReg
, HReg
);
921 extern MIPSInstr
*MIPSInstr_Mult(Bool
, HReg
, HReg
);
922 extern MIPSInstr
*MIPSInstr_Mulr6(Bool syned
, Bool sz32
, Bool low
,
924 extern MIPSInstr
*MIPSInstr_Div(Bool syned
, Bool sz32
, HReg
, HReg
);
925 extern MIPSInstr
*MIPSInstr_Divr6(Bool syned
, Bool sz32
, Bool mod
,
927 extern MIPSInstr
*MIPSInstr_Madd(Bool
, HReg
, HReg
);
928 extern MIPSInstr
*MIPSInstr_Msub(Bool
, HReg
, HReg
);
930 extern MIPSInstr
*MIPSInstr_Load(UChar sz
, HReg dst
, MIPSAMode
* src
,
932 extern MIPSInstr
*MIPSInstr_Store(UChar sz
, MIPSAMode
* dst
, HReg src
,
935 extern MIPSInstr
*MIPSInstr_LoadL(UChar sz
, HReg dst
, MIPSAMode
* src
,
937 extern MIPSInstr
*MIPSInstr_StoreC(UChar sz
, MIPSAMode
* dst
, HReg src
,
939 extern MIPSInstr
*MIPSInstr_Cas(UChar sz
, HReg old
, HReg addr
,
940 HReg expd
, HReg data
, Bool mode64
);
942 extern MIPSInstr
*MIPSInstr_Call ( MIPSCondCode
, Addr64
, UInt
, HReg
, RetLoc
);
943 extern MIPSInstr
*MIPSInstr_CallAlways ( MIPSCondCode
, Addr64
, UInt
, RetLoc
);
945 extern MIPSInstr
*MIPSInstr_XDirect ( Addr64 dstGA
, MIPSAMode
* amPC
,
946 MIPSCondCode cond
, Bool toFastEP
);
947 extern MIPSInstr
*MIPSInstr_XIndir(HReg dstGA
, MIPSAMode
* amPC
,
949 extern MIPSInstr
*MIPSInstr_XAssisted(HReg dstGA
, MIPSAMode
* amPC
,
950 MIPSCondCode cond
, IRJumpKind jk
);
952 extern MIPSInstr
*MIPSInstr_FpUnary(MIPSFpOp op
, HReg dst
, HReg src
);
953 extern MIPSInstr
*MIPSInstr_FpBinary(MIPSFpOp op
, HReg dst
, HReg srcL
,
955 extern MIPSInstr
*MIPSInstr_FpTernary ( MIPSFpOp op
, HReg dst
, HReg src1
,
956 HReg src2
, HReg src3
);
957 extern MIPSInstr
*MIPSInstr_FpConvert(MIPSFpOp op
, HReg dst
, HReg src
);
958 extern MIPSInstr
*MIPSInstr_FpCompare(MIPSFpOp op
, HReg dst
, HReg srcL
,
960 extern MIPSInstr
*MIPSInstr_FpMinMax(MIPSFpOp op
, HReg dst
, HReg srcL
,
962 extern MIPSInstr
*MIPSInstr_FpMulAcc(MIPSFpOp op
, HReg dst
, HReg srcML
,
963 HReg srcMR
, HReg srcAcc
);
964 extern MIPSInstr
*MIPSInstr_FpLdSt(Bool isLoad
, UChar sz
, HReg
, MIPSAMode
*);
965 extern MIPSInstr
*MIPSInstr_FpSTFIW(HReg addr
, HReg data
);
966 extern MIPSInstr
*MIPSInstr_FpRSP(HReg dst
, HReg src
);
967 extern MIPSInstr
*MIPSInstr_FpCftI(Bool fromI
, Bool int32
, HReg dst
, HReg src
);
968 extern MIPSInstr
*MIPSInstr_FpCMov(MIPSCondCode
, HReg dst
, HReg src
);
969 extern MIPSInstr
*MIPSInstr_MtFCSR(HReg src
);
970 extern MIPSInstr
*MIPSInstr_MfFCSR(HReg dst
);
971 extern MIPSInstr
*MIPSInstr_FpCmp(HReg dst
, HReg srcL
, HReg srcR
);
973 extern MIPSInstr
*MIPSInstr_Mfhi(HReg dst
);
974 extern MIPSInstr
*MIPSInstr_Mflo(HReg dst
);
975 extern MIPSInstr
*MIPSInstr_Mthi(HReg src
);
976 extern MIPSInstr
*MIPSInstr_Mtlo(HReg src
);
978 extern MIPSInstr
*MIPSInstr_RdWrLR(Bool wrLR
, HReg gpr
);
980 extern MIPSInstr
*MIPSInstr_MoveCond ( MIPSMoveCondOp op
, HReg dst
,
981 HReg src
, HReg cond
);
983 extern MIPSInstr
*MIPSInstr_FpGpMove ( MIPSFpGpMoveOp op
, HReg dst
, HReg src
);
985 extern MIPSInstr
*MIPSInstr_EvCheck(MIPSAMode
* amCounter
,
986 MIPSAMode
* amFailAddr
);
987 extern MIPSInstr
*MIPSInstr_ProfInc( void );
989 extern MIPSInstr
* MIPSInstr_MsaMi10(MSAMI10Op op
, UInt s10
, HReg rs
, HReg wd
, MSADF df
);
990 extern MIPSInstr
* MIPSInstr_MsaElm(MSAELMOp op
, HReg ws
, HReg wd
, UInt dfn
);
991 extern MIPSInstr
* MIPSInstr_Msa3R(MSA3ROp op
, MSADF df
, HReg wd
, HReg ws
, HReg wt
);
992 extern MIPSInstr
* MIPSInstr_Msa2R(MSA2ROp op
, MSADF df
, HReg ws
, HReg wd
);
993 extern MIPSInstr
* MIPSInstr_MsaVec(MSAVECOp op
, HReg wt
, HReg ws
, HReg wd
);
994 extern MIPSInstr
* MIPSInstr_MsaBit(MSABITOp op
, MSADF df
, UChar ms
, HReg ws
, HReg wd
);
995 extern MIPSInstr
* MIPSInstr_Msa3RF(MSA3RFOp op
, MSADFFlx df
, HReg wd
, HReg ws
, HReg wt
);
996 extern MIPSInstr
* MIPSInstr_Msa2RF(MSA2RFOp op
, MSADFFlx df
, HReg wd
, HReg ws
);
998 extern MIPSInstr
* MIPSInstr_Bitswap(MIPSRotxOp
, HReg
, HReg
, HReg
, HReg
, HReg
);
1000 extern void ppMIPSInstr(const MIPSInstr
*, Bool mode64
);
1002 /* Some functions that insulate the register allocator from details
1003 of the underlying instruction set. */
1004 extern void getRegUsage_MIPSInstr (HRegUsage
*, const MIPSInstr
*, Bool
);
1005 extern void mapRegs_MIPSInstr (HRegRemap
*, MIPSInstr
*, Bool mode64
);
1006 extern Int
emit_MIPSInstr (/*MB_MOD*/Bool
* is_profInc
,
1007 UChar
* buf
, Int nbuf
, const MIPSInstr
* i
,
1009 VexEndness endness_host
,
1010 const void* disp_cp_chain_me_to_slowEP
,
1011 const void* disp_cp_chain_me_to_fastEP
,
1012 const void* disp_cp_xindir
,
1013 const void* disp_cp_xassisted
);
1015 extern void genSpill_MIPS ( /*OUT*/ HInstr
** i1
, /*OUT*/ HInstr
** i2
,
1016 HReg rreg
, Int offset
, Bool
);
1017 extern void genReload_MIPS( /*OUT*/ HInstr
** i1
, /*OUT*/ HInstr
** i2
,
1018 HReg rreg
, Int offset
, Bool
);
1019 extern MIPSInstr
* genMove_MIPS(HReg from
, HReg to
, Bool mode64
);
1021 extern const RRegUniverse
* getRRegUniverse_MIPS ( Bool mode64
);
1023 extern HInstrArray
*iselSB_MIPS ( const IRSB
*,
1027 Int offs_Host_EvC_Counter
,
1028 Int offs_Host_EvC_FailAddr
,
1029 Bool chainingAllowed
,
1033 /* How big is an event check? This is kind of a kludge because it
1034 depends on the offsets of host_EvC_FAILADDR and host_EvC_COUNTER,
1035 and so assumes that they are both <= 128, and so can use the short
1036 offset encoding. This is all checked with assertions, so in the
1037 worst case we will merely assert at startup. */
1038 extern Int
evCheckSzB_MIPS (void);
1040 /* Perform a chaining and unchaining of an XDirect jump. */
1041 extern VexInvalRange
chainXDirect_MIPS ( VexEndness endness_host
,
1042 void* place_to_chain
,
1043 const void* disp_cp_chain_me_EXPECTED
,
1044 const void* place_to_jump_to
,
1047 extern VexInvalRange
unchainXDirect_MIPS ( VexEndness endness_host
,
1048 void* place_to_unchain
,
1049 const void* place_to_jump_to_EXPECTED
,
1050 const void* disp_cp_chain_me
,
1053 /* Patch the counter location into an existing ProfInc point. */
1054 extern VexInvalRange
patchProfInc_MIPS ( VexEndness endness_host
,
1055 void* place_to_patch
,
1056 const ULong
* location_of_counter
,
1060 #endif /* ndef __VEX_HOST_MIPS_DEFS_H */
1062 /*---------------------------------------------------------------*/
1063 /*--- end host-mips_defs.h ---*/
1064 /*---------------------------------------------------------------*/