2 /*---------------------------------------------------------------*/
3 /*--- begin host_ppc_defs.h ---*/
4 /*---------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2004-2017 OpenWorks LLP
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 The GNU General Public License is contained in the file COPYING.
30 Neither the names of the U.S. Department of Energy nor the
31 University of California nor the names of its contributors may be
32 used to endorse or promote products derived from this software
33 without prior written permission.
36 #ifndef __VEX_HOST_PPC_DEFS_H
37 #define __VEX_HOST_PPC_DEFS_H
39 #include "libvex_basictypes.h"
40 #include "libvex.h" // VexArch
41 #include "host_generic_regs.h" // HReg
44 /* --------- Registers. --------- */
46 #define ST_IN static inline
48 #define GPR(_mode64, _enc, _ix64, _ix32) \
49 mkHReg(False, (_mode64) ? HRcInt64 : HRcInt32, \
50 (_enc), (_mode64) ? (_ix64) : (_ix32))
52 #define FPR(_mode64, _enc, _ix64, _ix32) \
53 mkHReg(False, HRcFlt64, \
54 (_enc), (_mode64) ? (_ix64) : (_ix32))
56 #define VR(_mode64, _enc, _ix64, _ix32) \
57 mkHReg(False, HRcVec128, \
58 (_enc), (_mode64) ? (_ix64) : (_ix32))
60 ST_IN HReg
hregPPC_GPR14 ( Bool mode64
) { return GPR(mode64
, 14, 0, 0); }
61 ST_IN HReg
hregPPC_GPR15 ( Bool mode64
) { return GPR(mode64
, 15, 1, 1); }
62 ST_IN HReg
hregPPC_GPR16 ( Bool mode64
) { return GPR(mode64
, 16, 2, 2); }
63 ST_IN HReg
hregPPC_GPR17 ( Bool mode64
) { return GPR(mode64
, 17, 3, 3); }
64 ST_IN HReg
hregPPC_GPR18 ( Bool mode64
) { return GPR(mode64
, 18, 4, 4); }
65 ST_IN HReg
hregPPC_GPR19 ( Bool mode64
) { return GPR(mode64
, 19, 5, 5); }
66 ST_IN HReg
hregPPC_GPR20 ( Bool mode64
) { return GPR(mode64
, 20, 6, 6); }
67 ST_IN HReg
hregPPC_GPR21 ( Bool mode64
) { return GPR(mode64
, 21, 7, 7); }
68 ST_IN HReg
hregPPC_GPR22 ( Bool mode64
) { return GPR(mode64
, 22, 8, 8); }
69 ST_IN HReg
hregPPC_GPR23 ( Bool mode64
) { return GPR(mode64
, 23, 9, 9); }
70 ST_IN HReg
hregPPC_GPR24 ( Bool mode64
) { return GPR(mode64
, 24, 10, 10); }
71 ST_IN HReg
hregPPC_GPR25 ( Bool mode64
) { return GPR(mode64
, 25, 11, 11); }
72 ST_IN HReg
hregPPC_GPR26 ( Bool mode64
) { return GPR(mode64
, 26, 12, 12); }
73 ST_IN HReg
hregPPC_GPR27 ( Bool mode64
) { return GPR(mode64
, 27, 13, 13); }
74 ST_IN HReg
hregPPC_GPR28 ( Bool mode64
) { return GPR(mode64
, 28, 14, 14); }
76 ST_IN HReg
hregPPC_GPR3 ( Bool mode64
) { return GPR(mode64
, 3, 15, 15); }
77 ST_IN HReg
hregPPC_GPR4 ( Bool mode64
) { return GPR(mode64
, 4, 16, 16); }
78 ST_IN HReg
hregPPC_GPR5 ( Bool mode64
) { return GPR(mode64
, 5, 17, 17); }
79 ST_IN HReg
hregPPC_GPR6 ( Bool mode64
) { return GPR(mode64
, 6, 18, 18); }
80 ST_IN HReg
hregPPC_GPR7 ( Bool mode64
) { return GPR(mode64
, 7, 19, 19); }
81 ST_IN HReg
hregPPC_GPR8 ( Bool mode64
) { return GPR(mode64
, 8, 20, 20); }
82 ST_IN HReg
hregPPC_GPR9 ( Bool mode64
) { return GPR(mode64
, 9, 21, 21); }
83 ST_IN HReg
hregPPC_GPR10 ( Bool mode64
) { return GPR(mode64
, 10, 22, 22); }
85 // r11 and r12 are only allocatable in 32-bit mode. Hence the 64-bit
86 // index numbering doesn't advance for these two.
87 ST_IN HReg
hregPPC_GPR11 ( Bool mode64
) { return GPR(mode64
, 11, 22, 23); }
88 ST_IN HReg
hregPPC_GPR12 ( Bool mode64
) { return GPR(mode64
, 12, 22, 24); }
90 ST_IN HReg
hregPPC_FPR14 ( Bool mode64
) { return FPR(mode64
, 14, 23, 25); }
91 ST_IN HReg
hregPPC_FPR15 ( Bool mode64
) { return FPR(mode64
, 15, 24, 26); }
92 ST_IN HReg
hregPPC_FPR16 ( Bool mode64
) { return FPR(mode64
, 16, 25, 27); }
93 ST_IN HReg
hregPPC_FPR17 ( Bool mode64
) { return FPR(mode64
, 17, 26, 28); }
94 ST_IN HReg
hregPPC_FPR18 ( Bool mode64
) { return FPR(mode64
, 18, 27, 29); }
95 ST_IN HReg
hregPPC_FPR19 ( Bool mode64
) { return FPR(mode64
, 19, 28, 30); }
96 ST_IN HReg
hregPPC_FPR20 ( Bool mode64
) { return FPR(mode64
, 20, 29, 31); }
97 ST_IN HReg
hregPPC_FPR21 ( Bool mode64
) { return FPR(mode64
, 21, 30, 32); }
99 ST_IN HReg
hregPPC_VR20 ( Bool mode64
) { return VR (mode64
, 20, 31, 33); }
100 ST_IN HReg
hregPPC_VR21 ( Bool mode64
) { return VR (mode64
, 21, 32, 34); }
101 ST_IN HReg
hregPPC_VR22 ( Bool mode64
) { return VR (mode64
, 22, 33, 35); }
102 ST_IN HReg
hregPPC_VR23 ( Bool mode64
) { return VR (mode64
, 23, 34, 36); }
103 ST_IN HReg
hregPPC_VR24 ( Bool mode64
) { return VR (mode64
, 24, 35, 37); }
104 ST_IN HReg
hregPPC_VR25 ( Bool mode64
) { return VR (mode64
, 25, 36, 38); }
105 ST_IN HReg
hregPPC_VR26 ( Bool mode64
) { return VR (mode64
, 26, 37, 39); }
106 ST_IN HReg
hregPPC_VR27 ( Bool mode64
) { return VR (mode64
, 27, 38, 40); }
108 ST_IN HReg
hregPPC_GPR1 ( Bool mode64
) { return GPR(mode64
, 1, 39, 41); }
109 ST_IN HReg
hregPPC_GPR29 ( Bool mode64
) { return GPR(mode64
, 29, 40, 42); }
110 ST_IN HReg
hregPPC_GPR30 ( Bool mode64
) { return GPR(mode64
, 30, 41, 43); }
111 ST_IN HReg
hregPPC_GPR31 ( Bool mode64
) { return GPR(mode64
, 31, 42, 44); }
112 ST_IN HReg
hregPPC_VR29 ( Bool mode64
) { return VR (mode64
, 29, 43, 45); }
119 #define StackFramePtr(_mode64) hregPPC_GPR1(_mode64)
120 #define GuestStatePtr(_mode64) hregPPC_GPR31(_mode64)
122 /* Num registers used for function calls */
123 #define PPC_N_REGPARMS 8
125 extern UInt
ppHRegPPC ( HReg
);
128 /* --------- Condition codes --------- */
130 /* This gives names from bitfields in CR; hence it names BI numbers */
131 /* Using IBM/hardware indexing convention */
134 // CR7, which we use for integer compares
135 Pcf_7LT
= 28, /* neg | lt */
136 Pcf_7GT
= 29, /* pos | gt */
137 Pcf_7EQ
= 30, /* zero | equal */
138 Pcf_7SO
= 31, /* summary overflow */
139 Pcf_NONE
= 32 /* no condition; used with Pct_ALWAYS */
144 enum { /* Maps bc bitfield BO */
145 Pct_FALSE
= 0x4, /* associated PPCCondFlag must not be Pcf_NONE */
146 Pct_TRUE
= 0xC, /* associated PPCCondFlag must not be Pcf_NONE */
147 Pct_ALWAYS
= 0x14 /* associated PPCCondFlag must be Pcf_NONE */
158 extern const HChar
* showPPCCondCode ( PPCCondCode
);
161 extern PPCCondCode
mk_PPCCondCode ( PPCCondTest
, PPCCondFlag
);
163 /* false->true, true->false */
164 extern PPCCondTest
invertCondTest ( PPCCondTest
);
169 /* --------- Memory address expressions (amodes). --------- */
173 Pam_IR
=1, /* Immediate (signed 16-bit) + Reg */
174 Pam_RR
=2 /* Reg1 + Reg2 */
194 extern PPCAMode
* PPCAMode_IR ( Int
, HReg
);
195 extern PPCAMode
* PPCAMode_RR ( HReg
, HReg
);
197 extern PPCAMode
* dopyPPCAMode ( PPCAMode
* );
199 extern void ppPPCAMode ( PPCAMode
* );
202 /* --------- Operand, which can be a reg or a u16/s16. --------- */
203 /* ("RH" == "Register or Halfword immediate") */
227 extern PPCRH
* PPCRH_Imm ( Bool
, UShort
);
228 extern PPCRH
* PPCRH_Reg ( HReg
);
230 extern void ppPPCRH ( PPCRH
* );
233 /* --------- Operand, which can be a reg or a u32/64. --------- */
253 extern PPCRI
* PPCRI_Imm ( ULong
);
254 extern PPCRI
* PPCRI_Reg( HReg
);
256 extern void ppPPCRI ( PPCRI
* );
259 /* --------- Operand, which can be a vector reg or a s6. --------- */
260 /* ("VI" == "Vector Register or Immediate") */
279 extern PPCVI5s
* PPCVI5s_Imm ( Char
);
280 extern PPCVI5s
* PPCVI5s_Reg ( HReg
);
282 extern void ppPPCVI5s ( PPCVI5s
* );
285 /* --------- Instructions. --------- */
295 Pun_POP32
, // popcntw
300 extern const HChar
* showPPCUnaryOp ( PPCUnaryOp
);
308 Palu_AND
, Palu_OR
, Palu_XOR
,
313 const HChar
* showPPCAluOp ( PPCAluOp
,
314 Bool
/* is the 2nd operand an immediate? */);
321 Pshft_SHL
, Pshft_SHR
, Pshft_SAR
,
326 const HChar
* showPPCShftOp ( PPCShftOp
,
327 Bool
/* is the 2nd operand an immediate? */,
328 Bool
/* is this a 32bit or 64bit op? */ );
337 Pfp_MADDD
, Pfp_MSUBD
,
338 Pfp_MADDS
, Pfp_MSUBS
,
339 Pfp_FPADDQ
, Pfp_FPADDQRNDODD
,
340 Pfp_FPSUBQ
, Pfp_FPSUBQRNDODD
,
341 Pfp_FPMULQ
, Pfp_FPMULQRNDODD
,
342 Pfp_FPDIVQ
, Pfp_FPDIVQRNDODD
,
343 Pfp_FPMULADDQ
, Pfp_FPMULADDQRNDODD
,
344 Pfp_FPMULSUBQ
, Pfp_FPMULSUBQRNDODD
,
345 Pfp_FPNEGMULADDQ
, Pfp_FPNEGMULADDQRNDODD
,
346 Pfp_FPNEGMULSUBQ
, Pfp_FPNEGMULSUBQRNDODD
,
347 Pfp_FPSQRTQ
, Pfp_FPSQRTQRNDODD
,
348 Pfp_FPQTOD
, Pfp_FPQTODRNDODD
,
349 Pfp_FPQTOW
, Pfp_FPQTOWRNDODD
,
357 Pfp_DFPADD
, Pfp_DFPADDQ
,
358 Pfp_DFPSUB
, Pfp_DFPSUBQ
,
359 Pfp_DFPMUL
, Pfp_DFPMULQ
,
360 Pfp_DFPDIV
, Pfp_DFPDIVQ
,
361 Pfp_DQUAQ
, Pfp_DRRNDQ
,
364 Pfp_ADDD
, Pfp_SUBD
, Pfp_MULD
, Pfp_DIVD
,
365 Pfp_ADDS
, Pfp_SUBS
, Pfp_MULS
, Pfp_DIVS
,
366 Pfp_DRSP
, Pfp_DRDPQ
, Pfp_DCTFIX
, Pfp_DCTFIXQ
, Pfp_DCFFIX
,
367 Pfp_DQUA
, Pfp_RRDTR
, Pfp_DIEX
, Pfp_DIEXQ
, Pfp_DRINTN
,
370 Pfp_SQRT
, Pfp_ABS
, Pfp_NEG
, Pfp_MOV
, Pfp_RES
, Pfp_RSQRTE
,
371 Pfp_FRIN
, Pfp_FRIM
, Pfp_FRIP
, Pfp_FRIZ
,
372 Pfp_DSCLI
, Pfp_DSCRI
, Pfp_DSCLIQ
, Pfp_DSCRIQ
, Pfp_DCTDP
,
373 Pfp_DCTQPQ
, Pfp_DCFFIXQ
, Pfp_DXEX
, Pfp_DXEXQ
,
378 extern const HChar
* showPPCFpOp ( PPCFpOp
);
388 Pav_NOT
, /* Bitwise */
389 Pav_UNPCKH8S
, Pav_UNPCKH16S
, /* Unpack */
390 Pav_UNPCKL8S
, Pav_UNPCKL16S
,
391 Pav_UNPCKHPIX
, Pav_UNPCKLPIX
,
394 Pav_AND
, Pav_OR
, Pav_XOR
, /* Bitwise */
395 Pav_ADDU
, Pav_QADDU
, Pav_QADDS
,
396 Pav_SUBU
, Pav_QSUBU
, Pav_QSUBS
,
398 Pav_OMULU
, Pav_OMULS
, Pav_EMULU
, Pav_EMULS
,
403 /* Compare (always affects CR field 6) */
404 Pav_CMPEQU
, Pav_CMPGTU
, Pav_CMPGTS
,
407 Pav_SHL
, Pav_SHR
, Pav_SAR
, Pav_ROTL
,
410 Pav_PACKUU
, Pav_QPACKUU
, Pav_QPACKSU
, Pav_QPACKSS
,
414 Pav_MRGHI
, Pav_MRGLO
,
417 Pav_CATODD
, Pav_CATEVEN
,
419 /* Polynomial Multipy-Add */
423 Pav_CIPHERV128
, Pav_CIPHERLV128
, Pav_NCIPHERV128
, Pav_NCIPHERLV128
,
427 Pav_SHA256
, Pav_SHA512
,
430 Pav_BCDAdd
, Pav_BCDSub
,
432 /* Conversion signed 128-bit value to signed BCD 128-bit */
435 /* Conversion signed BCD 128-bit to signed 128-bit value */
439 Pav_ZEROCNTBYTE
, Pav_ZEROCNTWORD
, Pav_ZEROCNTHALF
, Pav_ZEROCNTDBL
,
441 /* trailing zero count */
442 Pav_TRAILINGZEROCNTBYTE
, Pav_TRAILINGZEROCNTWORD
,
443 Pav_TRAILINGZEROCNTHALF
, Pav_TRAILINGZEROCNTDBL
,
445 /* Vector bit matrix transpose by byte */
448 /* Vector Half-precision format to single precision conversion */
451 /* Vector Single precision format to Half-precision conversion */
454 /* Vector Half-precision format to Double precision conversion */
457 /* Vector Double precision format to Half-precision conversion */
460 /* 128 bit mult by 10 */
463 /* 128 bit mult by 10, carry out */
464 Pav_MulI128by10Carry
,
466 /* 128 bit mult by 10 plus carry in */
469 /* 128 bit mult by 10 plus carry in, carry out */
470 Pav_MulI128by10ECarry
,
475 /* Round F128 to F128 */
480 extern const HChar
* showPPCAvOp ( PPCAvOp
);
488 /* Floating point binary */
489 Pavfp_ADDF
, Pavfp_SUBF
, Pavfp_MULF
,
490 Pavfp_MAXF
, Pavfp_MINF
,
491 Pavfp_CMPEQF
, Pavfp_CMPGTF
, Pavfp_CMPGEF
,
493 /* Floating point unary */
494 Pavfp_RCPF
, Pavfp_RSQRTF
,
495 Pavfp_CVTU2F
, Pavfp_CVTS2F
, Pavfp_QCVTF2U
, Pavfp_QCVTF2S
,
496 Pavfp_ROUNDM
, Pavfp_ROUNDP
, Pavfp_ROUNDN
, Pavfp_ROUNDZ
,
500 extern const HChar
* showPPCAvFpOp ( PPCAvFpOp
);
506 Pin_LI
, /* load word (32/64-bit) immediate (fake insn) */
507 Pin_Alu
, /* word add/sub/and/or/xor */
508 Pin_Shft
, /* word shl/shr/sar */
509 Pin_AddSubC
, /* add/sub with read/write carry */
510 Pin_Cmp
, /* word compare */
511 Pin_Unary
, /* not, neg, clz */
512 Pin_MulL
, /* widening multiply */
514 Pin_Call
, /* call to address in register */
515 Pin_XDirect
, /* direct transfer to GA */
516 Pin_XIndir
, /* indirect transfer to GA */
517 Pin_XAssisted
, /* assisted transfer to GA */
518 Pin_CMov
, /* conditional move */
519 Pin_Load
, /* zero-extending load a 8|16|32|64 bit value from mem */
520 Pin_LoadL
, /* load-linked (lwarx/ldarx) 32|64 bit value from mem */
521 Pin_Store
, /* store a 8|16|32|64 bit value to mem */
522 Pin_StoreC
, /* store-conditional (stwcx./stdcx.) 32|64 bit val */
523 Pin_Set
, /* convert condition code to value 0 or 1 */
524 Pin_MfCR
, /* move from condition register to GPR */
525 Pin_MFence
, /* mem fence */
527 Pin_FpUnary
, /* FP unary op */
528 Pin_FpBinary
, /* FP binary op */
529 Pin_Fp128Unary
, /* FP unary op for 128-bit floating point */
530 Pin_Fp128Binary
, /* FP binary op for 128-bit floating point */
531 Pin_Fp128Trinary
, /* FP trinary op for 128-bit floating point */
532 Pin_FpMulAcc
, /* FP multipy-accumulate style op */
533 Pin_FpLdSt
, /* FP load/store */
534 Pin_FpSTFIW
, /* stfiwx */
535 Pin_FpRSP
, /* FP round IEEE754 double to IEEE754 single */
536 Pin_FpCftI
, /* fcfid[u,s,us]/fctid[u]/fctiw[u] */
537 Pin_FpCMov
, /* FP floating point conditional move */
538 Pin_FpLdFPSCR
, /* mtfsf */
539 Pin_FpCmp
, /* FP compare, generating value into int reg */
541 Pin_RdWrLR
, /* Read/Write Link Register */
543 Pin_AvLdSt
, /* AV load/store (kludging for AMode_IR) */
544 Pin_AvUnary
, /* AV unary general reg=>reg */
546 Pin_AvBinary
, /* AV binary general reg,reg=>reg */
547 Pin_AvBinaryInt
,/* AV binary reg,int=>reg */
548 Pin_AvBin8x16
, /* AV binary, 8x4 */
549 Pin_AvBin16x8
, /* AV binary, 16x4 */
550 Pin_AvBin32x4
, /* AV binary, 32x4 */
551 Pin_AvBin64x2
, /* AV binary, 64x2 */
553 Pin_AvBin32Fx4
, /* AV FP binary, 32Fx4 */
554 Pin_AvUn32Fx4
, /* AV FP unary, 32Fx4 */
556 Pin_AvPerm
, /* AV permute (shuffle) */
557 Pin_AvSel
, /* AV select */
558 Pin_AvSh
, /* AV shift left or right */
559 Pin_AvShlDbl
, /* AV shift-left double by imm */
560 Pin_AvSplat
, /* One elem repeated throughout dst */
561 Pin_AvLdVSCR
, /* mtvscr */
562 Pin_AvCMov
, /* AV conditional move */
563 Pin_AvCipherV128Unary
, /* AV Vector unary Cipher */
564 Pin_AvCipherV128Binary
, /* AV Vector binary Cipher */
565 Pin_AvHashV128Binary
, /* AV Vector binary Hash */
566 Pin_AvBCDV128Binary
, /* BCD Arithmetic */
567 Pin_Dfp64Unary
, /* DFP64 unary op */
568 Pin_Dfp128Unary
, /* DFP128 unary op */
569 Pin_DfpShift
, /* Decimal floating point shift by immediate value */
570 Pin_Dfp64Binary
, /* DFP64 binary op */
571 Pin_Dfp128Binary
, /* DFP128 binary op */
572 Pin_DfpShift128
, /* 128-bit Decimal floating point shift by
574 Pin_DfpD128toD64
, /* DFP 128 to DFP 64 op */
575 Pin_DfpI64StoD128
, /* DFP signed integer to DFP 128 */
576 Pin_DfpRound
, /* D64 round to D64 */
577 Pin_DfpRound128
, /* D128 round to D128 */
578 Pin_ExtractExpD128
, /* DFP, extract 64 bit exponent */
579 Pin_InsertExpD128
, /* DFP, insert 64 bit exponent and 128 bit binary
580 * significand into a DFP 128-bit value*/
581 Pin_Dfp64Cmp
, /* DFP 64-bit compare, generating value into
583 Pin_Dfp128Cmp
, /* DFP 128-bit compare, generating value into
585 Pin_DfpQuantize
, /* D64 quantize using register value, significance
587 Pin_DfpQuantize128
, /* D128 quantize using register value, significance
589 Pin_EvCheck
, /* Event check */
590 Pin_ProfInc
/* 64-bit profile counter increment */
594 /* Destinations are on the LEFT (first operand) */
600 /* Get a 32/64-bit literal into a register.
601 May turn into a number of real insns. */
606 /* Integer add/sub/and/or/xor. Limitations:
607 - For add, the immediate, if it exists, is a signed 16.
608 - For sub, the immediate, if it exists, is a signed 16
609 which may not be -32768, since no such instruction
610 exists, and so we have to emit addi with +32768, but
611 that is not possible.
612 - For and/or/xor, the immediate, if it exists,
621 /* Integer shl/shr/sar.
622 Limitations: the immediate, if it exists,
623 is a signed 5-bit value between 1 and 31 inclusive.
627 Bool sz32
; /* mode64 has both 32 and 64bit shft */
634 Bool isAdd
; /* else sub */
635 Bool setC
; /* else read carry */
640 /* If signed, the immediate, if it exists, is a signed 16,
641 else it is an unsigned 16. */
644 Bool sz32
; /* mode64 has both 32 and 64bit cmp */
649 /* Not, Neg, Clz32/64, Extsw */
656 Bool syned
; /* meaningless if hi32==False */
657 Bool hi
; /* False=>low, True=>high */
658 Bool sz32
; /* mode64 has both 32 & 64bit mull */
663 /* ppc32 div/divu instruction. */
667 Bool sz32
; /* mode64 has both 32 & 64bit div */
672 /* Pseudo-insn. Call target (an absolute address), on given
673 condition (which could be Pct_ALWAYS). argiregs indicates
674 which of r3 .. r10 carries argument values for this call,
675 using a bit mask (1<<N is set if rN holds an arg, for N in
676 3 .. 10 inclusive). */
681 RetLoc rloc
; /* where the return value will be */
683 /* Update the guest CIA value, then exit requesting to chain
684 to it. May be conditional. Use of Addr64 in order to cope
685 with 64-bit hosts. */
687 Addr64 dstGA
; /* next guest address */
688 PPCAMode
* amCIA
; /* amode in guest state for CIA */
689 PPCCondCode cond
; /* can be ALWAYS */
690 Bool toFastEP
; /* chain to the slow or fast point? */
692 /* Boring transfer to a guest address not known at JIT time.
693 Not chainable. May be conditional. */
697 PPCCondCode cond
; /* can be ALWAYS */
699 /* Assisted transfer to a guest address, most general case.
700 Not chainable. May be conditional. */
704 PPCCondCode cond
; /* can be ALWAYS */
707 /* Mov src to dst on the given condition, which may not
708 be the bogus Pct_ALWAYS. */
714 /* Zero extending loads. Dst size is host word size */
716 UChar sz
; /* 1|2|4|8 */
720 /* Load-and-reserve (lwarx, ldarx) */
726 /* 64/32/16/8 bit stores */
728 UChar sz
; /* 1|2|4|8 */
732 /* Store-conditional (stwcx., stdcx.) */
738 /* Convert a ppc condition code to value 0 or 1. */
743 /* Move the entire CR to a GPR */
747 /* Mem fence. In short, an insn which flushes all preceding
748 loads and stores as much as possible before continuing.
749 On PPC we emit a "sync". */
753 /* PPC Floating point */
791 UChar sz
; /* only 4 (IEEE single) or 8 (IEEE double) */
796 HReg addr
; /* int reg */
797 HReg data
; /* float reg */
799 /* Round 64-bit FP value to 32-bit FP value in an FP reg. */
804 /* fcfid[u,s,us]/fctid[u]/fctiw[u]. Only some combinations
805 of the various fields are allowed. This is asserted for
806 and documented in the code for the constructor,
807 PPCInstr_FpCftI, in host_ppc_defs.c. */
809 Bool fromI
; /* True== I->F, False== F->I */
810 Bool int32
; /* True== I is 32, False== I is 64 */
812 Bool flt64
; /* True== F is 64, False== F is 32 */
816 /* FP mov src to dst on the given condition. */
822 /* Load FP Status & Control Register */
827 /* Do a compare, generating result into an int register. */
835 /* Read/Write Link Register */
841 /* Simplistic AltiVec */
844 UChar sz
; /* 8|16|32|128 */
883 /* Can only be generated for CPUs capable of ISA 2.07 or above */
901 /* Perm,Sel,SlDbl,Splat are all weird AV permutations */
926 UChar sz
; /* 8,16,32 */
930 /* Mov src to dst on the given condition, which may not
931 be the bogus Xcc_ALWAYS. */
937 /* Load AltiVec Status & Control Register */
963 } AvCipherV128Binary
;
989 /* The dst is used to pass the left source operand in and return
1074 PPCAMode
* amCounter
;
1075 PPCAMode
* amFailAddr
;
1078 /* No fields. The address of the counter to inc is
1079 installed later, post-translation, by patching it in,
1080 as it is not known at translation time. */
1087 extern PPCInstr
* PPCInstr_LI ( HReg
, ULong
, Bool
);
1088 extern PPCInstr
* PPCInstr_Alu ( PPCAluOp
, HReg
, HReg
, PPCRH
* );
1089 extern PPCInstr
* PPCInstr_Shft ( PPCShftOp
, Bool sz32
, HReg
, HReg
, PPCRH
* );
1090 extern PPCInstr
* PPCInstr_AddSubC ( Bool
, Bool
, HReg
, HReg
, HReg
);
1091 extern PPCInstr
* PPCInstr_Cmp ( Bool
, Bool
, UInt
, HReg
, PPCRH
* );
1092 extern PPCInstr
* PPCInstr_Unary ( PPCUnaryOp op
, HReg dst
, HReg src
);
1093 extern PPCInstr
* PPCInstr_MulL ( Bool syned
, Bool hi32
, Bool sz32
, HReg
, HReg
, HReg
);
1094 extern PPCInstr
* PPCInstr_Div ( Bool extended
, Bool syned
, Bool sz32
, HReg dst
, HReg srcL
, HReg srcR
);
1095 extern PPCInstr
* PPCInstr_Call ( PPCCondCode
, Addr64
, UInt
, RetLoc
);
1096 extern PPCInstr
* PPCInstr_XDirect ( Addr64 dstGA
, PPCAMode
* amCIA
,
1097 PPCCondCode cond
, Bool toFastEP
);
1098 extern PPCInstr
* PPCInstr_XIndir ( HReg dstGA
, PPCAMode
* amCIA
,
1100 extern PPCInstr
* PPCInstr_XAssisted ( HReg dstGA
, PPCAMode
* amCIA
,
1101 PPCCondCode cond
, IRJumpKind jk
);
1102 extern PPCInstr
* PPCInstr_CMov ( PPCCondCode
, HReg dst
, PPCRI
* src
);
1103 extern PPCInstr
* PPCInstr_Load ( UChar sz
,
1104 HReg dst
, PPCAMode
* src
, Bool mode64
);
1105 extern PPCInstr
* PPCInstr_LoadL ( UChar sz
,
1106 HReg dst
, HReg src
, Bool mode64
);
1107 extern PPCInstr
* PPCInstr_Store ( UChar sz
, PPCAMode
* dst
,
1108 HReg src
, Bool mode64
);
1109 extern PPCInstr
* PPCInstr_StoreC ( UChar sz
, HReg dst
, HReg src
,
1111 extern PPCInstr
* PPCInstr_Set ( PPCCondCode cond
, HReg dst
);
1112 extern PPCInstr
* PPCInstr_MfCR ( HReg dst
);
1113 extern PPCInstr
* PPCInstr_MFence ( void );
1115 extern PPCInstr
* PPCInstr_Fp128Unary ( PPCFpOp op
, HReg dst
, HReg src
);
1116 extern PPCInstr
* PPCInstr_Fp128Binary ( PPCFpOp op
, HReg dst
, HReg srcL
, HReg srcR
);
1117 extern PPCInstr
* PPCInstr_Fp128Trinary ( PPCFpOp op
, HReg dst
, HReg srcL
,
1120 extern PPCInstr
* PPCInstr_FpUnary ( PPCFpOp op
, HReg dst
, HReg src
);
1121 extern PPCInstr
* PPCInstr_FpBinary ( PPCFpOp op
, HReg dst
, HReg srcL
, HReg srcR
);
1122 extern PPCInstr
* PPCInstr_FpMulAcc ( PPCFpOp op
, HReg dst
, HReg srcML
,
1123 HReg srcMR
, HReg srcAcc
);
1124 extern PPCInstr
* PPCInstr_FpLdSt ( Bool isLoad
, UChar sz
, HReg
, PPCAMode
* );
1125 extern PPCInstr
* PPCInstr_FpSTFIW ( HReg addr
, HReg data
);
1126 extern PPCInstr
* PPCInstr_FpRSP ( HReg dst
, HReg src
);
1127 extern PPCInstr
* PPCInstr_FpCftI ( Bool fromI
, Bool int32
, Bool syned
,
1128 Bool dst64
, HReg dst
, HReg src
);
1129 extern PPCInstr
* PPCInstr_FpCMov ( PPCCondCode
, HReg dst
, HReg src
);
1130 extern PPCInstr
* PPCInstr_FpLdFPSCR ( HReg src
, Bool dfp_rm
);
1131 extern PPCInstr
* PPCInstr_FpCmp ( HReg dst
, HReg srcL
, HReg srcR
);
1133 extern PPCInstr
* PPCInstr_RdWrLR ( Bool wrLR
, HReg gpr
);
1135 extern PPCInstr
* PPCInstr_AvLdSt ( Bool isLoad
, UChar sz
, HReg
, PPCAMode
* );
1136 extern PPCInstr
* PPCInstr_AvUnary ( PPCAvOp op
, HReg dst
, HReg src
);
1137 extern PPCInstr
* PPCInstr_AvBinary ( PPCAvOp op
, HReg dst
, HReg srcL
, HReg srcR
);
1138 extern PPCInstr
* PPCInstr_AvBinaryInt( PPCAvOp op
, HReg dst
, HReg src
, PPCRI
* val
);
1139 extern PPCInstr
* PPCInstr_AvBin8x16 ( PPCAvOp op
, HReg dst
, HReg srcL
, HReg srcR
);
1140 extern PPCInstr
* PPCInstr_AvBin16x8 ( PPCAvOp op
, HReg dst
, HReg srcL
, HReg srcR
);
1141 extern PPCInstr
* PPCInstr_AvBin32x4 ( PPCAvOp op
, HReg dst
, HReg srcL
, HReg srcR
);
1142 extern PPCInstr
* PPCInstr_AvBin64x2 ( PPCAvOp op
, HReg dst
, HReg srcL
, HReg srcR
);
1143 extern PPCInstr
* PPCInstr_AvBin32Fx4 ( PPCAvFpOp op
, HReg dst
, HReg srcL
, HReg srcR
);
1144 extern PPCInstr
* PPCInstr_AvUn32Fx4 ( PPCAvFpOp op
, HReg dst
, HReg src
);
1145 extern PPCInstr
* PPCInstr_AvPerm ( HReg dst
, HReg srcL
, HReg srcR
, HReg ctl
);
1146 extern PPCInstr
* PPCInstr_AvSel ( HReg ctl
, HReg dst
, HReg srcL
, HReg srcR
);
1147 extern PPCInstr
* PPCInstr_AvSh ( Bool shLeft
, HReg dst
, PPCAMode
* am_addr
);
1148 extern PPCInstr
* PPCInstr_AvShlDbl ( UChar shift
, HReg dst
, HReg srcL
, HReg srcR
);
1149 extern PPCInstr
* PPCInstr_AvSplat ( UChar sz
, HReg dst
, PPCVI5s
* src
);
1150 extern PPCInstr
* PPCInstr_AvCMov ( PPCCondCode
, HReg dst
, HReg src
);
1151 extern PPCInstr
* PPCInstr_AvLdVSCR ( HReg src
);
1152 extern PPCInstr
* PPCInstr_AvCipherV128Unary ( PPCAvOp op
, HReg dst
,
1154 extern PPCInstr
* PPCInstr_AvCipherV128Binary ( PPCAvOp op
, HReg dst
,
1155 HReg srcL
, HReg srcR
);
1156 extern PPCInstr
* PPCInstr_AvHashV128Binary ( PPCAvOp op
, HReg dst
,
1157 HReg src
, PPCRI
* s_field
);
1158 extern PPCInstr
* PPCInstr_AvBCDV128Binary ( PPCAvOp op
, HReg dst
,
1159 HReg src1
, HReg src2
);
1160 extern PPCInstr
* PPCInstr_Dfp64Unary ( PPCFpOp op
, HReg dst
, HReg src
);
1161 extern PPCInstr
* PPCInstr_Dfp64Binary ( PPCFpOp op
, HReg dst
, HReg srcL
,
1163 extern PPCInstr
* PPCInstr_DfpShift ( PPCFpOp op
, HReg dst
, HReg src
,
1165 extern PPCInstr
* PPCInstr_Dfp128Unary ( PPCFpOp op
, HReg dst_hi
, HReg dst_lo
,
1166 HReg srcR_hi
, HReg srcR_lo
);
1167 extern PPCInstr
* PPCInstr_Dfp128Binary ( PPCFpOp op
, HReg dst_hi
, HReg dst_lo
,
1168 HReg srcR_hi
, HReg srcR_lo
);
1169 extern PPCInstr
* PPCInstr_DfpShift128 ( PPCFpOp op
, HReg dst_hi
, HReg src_hi
,
1170 HReg dst_lo
, HReg src_lo
,
1172 extern PPCInstr
* PPCInstr_DfpD128toD64 ( PPCFpOp op
, HReg dst
,
1173 HReg dst_lo
, HReg src_lo
);
1174 extern PPCInstr
* PPCInstr_DfpI64StoD128 ( PPCFpOp op
, HReg dst_hi
,
1175 HReg dst_lo
, HReg src
);
1176 extern PPCInstr
* PPCInstr_DfpRound ( HReg dst
, HReg src
, PPCRI
* r_rmc
);
1177 extern PPCInstr
* PPCInstr_DfpRound128 ( HReg dst_hi
, HReg dst_lo
, HReg src_hi
,
1178 HReg src_lo
, PPCRI
* r_rmc
);
1179 extern PPCInstr
* PPCInstr_DfpQuantize ( PPCFpOp op
, HReg dst
, HReg srcL
,
1180 HReg srcR
, PPCRI
* rmc
);
1181 extern PPCInstr
* PPCInstr_DfpQuantize128 ( PPCFpOp op
, HReg dst_hi
,
1184 HReg src_lo
, PPCRI
* rmc
);
1185 extern PPCInstr
* PPCInstr_ExtractExpD128 ( PPCFpOp op
, HReg dst
,
1186 HReg src_hi
, HReg src_lo
);
1187 extern PPCInstr
* PPCInstr_InsertExpD128 ( PPCFpOp op
, HReg dst_hi
,
1188 HReg dst_lo
, HReg srcL
,
1189 HReg srcR_hi
, HReg srcR_lo
);
1190 extern PPCInstr
* PPCInstr_Dfp64Cmp ( HReg dst
, HReg srcL
, HReg srcR
);
1191 extern PPCInstr
* PPCInstr_Dfp128Cmp ( HReg dst
, HReg srcL_hi
, HReg srcL_lo
,
1192 HReg srcR_hi
, HReg srcR_lo
);
1193 extern PPCInstr
* PPCInstr_EvCheck ( PPCAMode
* amCounter
,
1194 PPCAMode
* amFailAddr
);
1195 extern PPCInstr
* PPCInstr_ProfInc ( void );
1197 extern void ppPPCInstr(const PPCInstr
*, Bool mode64
);
1200 /* Some functions that insulate the register allocator from details
1201 of the underlying instruction set. */
1202 extern void getRegUsage_PPCInstr ( HRegUsage
*, const PPCInstr
*, Bool mode64
);
1203 extern void mapRegs_PPCInstr ( HRegRemap
*, PPCInstr
* , Bool mode64
);
1204 extern Int
emit_PPCInstr ( /*MB_MOD*/Bool
* is_profInc
,
1205 UChar
* buf
, Int nbuf
, const PPCInstr
* i
,
1207 VexEndness endness_host
,
1208 const void* disp_cp_chain_me_to_slowEP
,
1209 const void* disp_cp_chain_me_to_fastEP
,
1210 const void* disp_cp_xindir
,
1211 const void* disp_cp_xassisted
);
1213 extern void genSpill_PPC ( /*OUT*/HInstr
** i1
, /*OUT*/HInstr
** i2
,
1214 HReg rreg
, Int offsetB
, Bool mode64
);
1215 extern void genReload_PPC ( /*OUT*/HInstr
** i1
, /*OUT*/HInstr
** i2
,
1216 HReg rreg
, Int offsetB
, Bool mode64
);
1217 extern PPCInstr
* genMove_PPC(HReg from
, HReg to
, Bool mode64
);
1219 extern const RRegUniverse
* getRRegUniverse_PPC ( Bool mode64
);
1221 extern HInstrArray
* iselSB_PPC ( const IRSB
*,
1225 Int offs_Host_EvC_Counter
,
1226 Int offs_Host_EvC_FailAddr
,
1227 Bool chainingAllowed
,
1231 /* How big is an event check? This is kind of a kludge because it
1232 depends on the offsets of host_EvC_FAILADDR and
1233 host_EvC_COUNTER. */
1234 extern Int
evCheckSzB_PPC (void);
1236 /* Perform a chaining and unchaining of an XDirect jump. */
1237 extern VexInvalRange
chainXDirect_PPC ( VexEndness endness_host
,
1238 void* place_to_chain
,
1239 const void* disp_cp_chain_me_EXPECTED
,
1240 const void* place_to_jump_to
,
1243 extern VexInvalRange
unchainXDirect_PPC ( VexEndness endness_host
,
1244 void* place_to_unchain
,
1245 const void* place_to_jump_to_EXPECTED
,
1246 const void* disp_cp_chain_me
,
1249 /* Patch the counter location into an existing ProfInc point. */
1250 extern VexInvalRange
patchProfInc_PPC ( VexEndness endness_host
,
1251 void* place_to_patch
,
1252 const ULong
* location_of_counter
,
1256 #endif /* ndef __VEX_HOST_PPC_DEFS_H */
1258 /*---------------------------------------------------------------*/
1259 /*--- end host_ppc_defs.h ---*/
1260 /*---------------------------------------------------------------*/