Changeset 66950 in vbox for trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c
- Timestamp:
- May 18, 2017 2:24:43 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c
r66937 r66950 101 101 BS3CG1OPLOC_END 102 102 } BS3CG1OPLOC; 103 AssertCompile(BS3CG1OPLOC_END <= 16); 103 104 104 105 … … 165 166 /** Operand size in bytes (0 if not applicable). */ 166 167 uint8_t cbOperand; 168 /** Current VEX.L value (UINT8_MAX if not applicable). */ 169 uint8_t uVexL; 167 170 /** Current target ring (0..3). */ 168 171 uint8_t uCpl; … … 208 211 /** BS3CG1OPLOC_XXX. */ 209 212 uint8_t enmLocation; 213 /** BS3CG1OPLOC_XXX for memory encodings (MODRM.rm field). */ 214 uint8_t enmLocationMem : 4; 215 /** BS3CG1OPLOC_XXX for register encodings (MODRM.rm field). */ 216 uint8_t enmLocationReg : 4; 210 217 /** The BS3CG1DST value for this field. 211 218 * Set to BS3CG1DST_INVALID if memory or immediate. */ 212 219 uint8_t idxField; 213 220 /** The base BS3CG1DST value for this field. 214 * Used only by some generalized encoders when dealing with 215 * registers. */ 221 * Used only by some generalized encoders when dealing with registers. */ 216 222 uint8_t idxFieldBase; 217 223 /** Depends on enmLocation. … … 1167 1173 1168 1174 /** 1169 * Checks if >= 16 byte SSE /AVXalignment are exempted for the exception type.1175 * Checks if >= 16 byte SSE alignment are exempted for the exception type. 1170 1176 * 1171 1177 * @returns true / false. … … 1176 1182 switch (enmXcptType) 1177 1183 { 1184 case BS3CG1XCPTTYPE_1: 1185 case BS3CG1XCPTTYPE_2: 1186 case BS3CG1XCPTTYPE_4: 1187 return false; 1188 case BS3CG1XCPTTYPE_3: 1178 1189 case BS3CG1XCPTTYPE_4UA: 1179 1190 case BS3CG1XCPTTYPE_5: 1180 1191 return true; 1192 default: 1193 return false; 1194 } 1195 } 1196 1197 1198 /** 1199 * Checks if >= 16 byte AVX alignment are exempted for the exception type. 1200 * 1201 * @returns true / false. 1202 * @param enmXcptType The type to check. 1203 */ 1204 static bool BS3_NEAR_CODE Bs3Cg1XcptTypeIsVexUnaligned(BS3CG1XCPTTYPE enmXcptType) 1205 { 1206 switch (enmXcptType) 1207 { 1208 case BS3CG1XCPTTYPE_1: 1209 return false; 1210 1211 case BS3CG1XCPTTYPE_2: 1212 case BS3CG1XCPTTYPE_3: 1213 case BS3CG1XCPTTYPE_4: 1214 case BS3CG1XCPTTYPE_4UA: 1215 case BS3CG1XCPTTYPE_5: 1216 case BS3CG1XCPTTYPE_6: 1217 case BS3CG1XCPTTYPE_11: 1218 case BS3CG1XCPTTYPE_12: 1219 return true; 1220 1181 1221 default: 1182 1222 return false; … … 1319 1359 1320 1360 1361 #if 0 /* unused */ 1321 1362 /** Also encodes idxField of the register operand using idxFieldBase. */ 1322 1363 static unsigned BS3_NEAR_CODE … … 1327 1368 return Bs3Cfg1EncodeMemMod0Disp(pThis, fAddrOverride, off, iReg & 7, cbOp, cbMissalign, enmLocation); 1328 1369 } 1329 1370 #endif 1330 1371 1331 1372 /** Also encodes idxField of the register operand using idxFieldBase. */ … … 2185 2226 pThis->abCurInstr[offDst] = 0xc5; /* vex2 */ 2186 2227 pThis->abCurInstr[offDst + 1] = b; 2228 pThis->uVexL = uVexL; 2187 2229 return offDst + 2; 2188 2230 } … … 2228 2270 pThis->abCurInstr[offDst + 1] = b1; 2229 2271 pThis->abCurInstr[offDst + 2] = b2; 2272 pThis->uVexL = uVexL; 2230 2273 return offDst + 3; 2231 2274 } … … 2286 2329 off = Bs3Cg1InsertOpcodes(pThis, off); 2287 2330 off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, 3 /*iReg*/, 16, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM); 2288 if (!Bs3Cg1XcptTypeIs Unaligned(pThis->enmXcptType))2331 if (!Bs3Cg1XcptTypeIsVexUnaligned(pThis->enmXcptType)) 2289 2332 pThis->bAlignmentXcpt = X86_XCPT_GP; 2290 2333 pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_XMM3; … … 2295 2338 off = Bs3Cg1InsertOpcodes(pThis, off); 2296 2339 off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, 3 /*iReg*/, 16, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM); 2297 if (!Bs3Cg1XcptTypeIs Unaligned(pThis->enmXcptType))2340 if (!Bs3Cg1XcptTypeIsVexUnaligned(pThis->enmXcptType)) 2298 2341 pThis->bAlignmentXcpt = X86_XCPT_GP; 2299 2342 pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_XMM3; … … 2371 2414 off = Bs3Cg1InsertOpcodes(pThis, off); 2372 2415 off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, 3 /*iReg*/, 32, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM); 2373 if (!Bs3Cg1XcptTypeIs Unaligned(pThis->enmXcptType))2416 if (!Bs3Cg1XcptTypeIsVexUnaligned(pThis->enmXcptType)) 2374 2417 pThis->bAlignmentXcpt = X86_XCPT_GP; 2375 2418 pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_YMM3; … … 2380 2423 off = Bs3Cg1InsertOpcodes(pThis, off); 2381 2424 off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, 3 /*iReg*/, 32, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM); 2382 if (!Bs3Cg1XcptTypeIs Unaligned(pThis->enmXcptType))2425 if (!Bs3Cg1XcptTypeIsVexUnaligned(pThis->enmXcptType)) 2383 2426 pThis->bAlignmentXcpt = X86_XCPT_GP; 2384 2427 pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_YMM3; … … 2967 3010 * Wip = VEX.W ignored. 2968 3011 */ 2969 static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_VEX_MODRM_WsomethingWO_Vsomething_Wip(PBS3CG1STATE pThis, unsigned iEncoding) 3012 static unsigned BS3_NEAR_CODE 3013 Bs3Cg1EncodeNext_VEX_MODRM_WsomethingWO_Vsomething_Wip_OR_ViceVersa(PBS3CG1STATE pThis, unsigned iEncoding) 2970 3014 { 2971 3015 unsigned off; … … 2977 3021 off = Bs3Cg1InsertOpcodes(pThis, off); 2978 3022 pThis->abCurInstr[off++] = X86_MODRM_MAKE(3, 1, 0); 3023 pThis->aOperands[pThis->iRmOp ].enmLocation = pThis->aOperands[pThis->iRegOp].enmLocationReg; 2979 3024 pThis->aOperands[pThis->iRmOp ].idxField = pThis->aOperands[pThis->iRmOp ].idxFieldBase + 0; 2980 3025 pThis->aOperands[pThis->iRegOp].idxField = pThis->aOperands[pThis->iRegOp].idxFieldBase + 1; … … 2996 3041 break; 2997 3042 case 3: 3043 pThis->aOperands[pThis->iRmOp].enmLocation = pThis->aOperands[pThis->iRmOp].enmLocationMem; 2998 3044 off = Bs3Cg1InsertVex2bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 0 /*L*/, 1 /*~R*/); 2999 3045 off = Bs3Cg1InsertOpcodes(pThis, off); 3000 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 2 /*iReg*/, 16, 0, BS3CG1OPLOC_MEM_WO);3046 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 2 /*iReg*/, 0); 3001 3047 break; 3002 3048 case 4: 3003 3049 off = Bs3Cg1InsertVex3bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 0 /*L*/, 1 /*~R*/, 1 /*~X*/, 1 /*~B*/, 0 /*W*/); 3004 3050 off = Bs3Cg1InsertOpcodes(pThis, off); 3005 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 3 /*iReg*/, 16, 0, BS3CG1OPLOC_MEM_WO);3051 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 3 /*iReg*/, 0); 3006 3052 break; 3007 3053 case 5: 3008 3054 off = Bs3Cg1InsertVex3bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 0 /*L*/, 1 /*~R*/, 1 /*~X*/, 1 /*~B*/, 1 /*W - ignored */); 3009 3055 off = Bs3Cg1InsertOpcodes(pThis, off); 3010 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 3 /*iReg*/, 16, 0, BS3CG1OPLOC_MEM_WO);3056 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 3 /*iReg*/, 0); 3011 3057 break; 3012 3058 case 6: 3013 3059 off = Bs3Cg1InsertVex2bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 0 /*L*/, 1 /*~R*/); 3014 3060 off = Bs3Cg1InsertOpcodes(pThis, off); 3015 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 3 /*iReg*/, 16, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM_WO);3016 if (!Bs3Cg1XcptTypeIs Unaligned(pThis->enmXcptType))3061 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 3 /*iReg*/, 1 /*cbMissalign*/); 3062 if (!Bs3Cg1XcptTypeIsVexUnaligned(pThis->enmXcptType)) 3017 3063 pThis->bAlignmentXcpt = X86_XCPT_GP; 3018 3064 break; … … 3020 3066 off = Bs3Cg1InsertVex3bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 0 /*L*/, 1 /*~R*/, 1 /*~X*/, 1 /*~B*/, 0 /*W*/); 3021 3067 off = Bs3Cg1InsertOpcodes(pThis, off); 3022 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 3 /*iReg*/, 16, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM_WO);3023 if (!Bs3Cg1XcptTypeIs Unaligned(pThis->enmXcptType))3068 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 3 /*iReg*/, 1 /*cbMissalign*/); 3069 if (!Bs3Cg1XcptTypeIsVexUnaligned(pThis->enmXcptType)) 3024 3070 pThis->bAlignmentXcpt = X86_XCPT_GP; 3025 3071 break; … … 3029 3075 off = Bs3Cg1InsertOpcodes(pThis, off); 3030 3076 pThis->abCurInstr[off++] = X86_MODRM_MAKE(3, 1, 0); 3077 pThis->aOperands[pThis->iRmOp ].enmLocation = pThis->aOperands[pThis->iRmOp].enmLocationReg; 3031 3078 pThis->aOperands[pThis->iRmOp ].idxField = pThis->aOperands[pThis->iRmOp ].idxFieldBase + 0; 3032 3079 pThis->aOperands[pThis->iRegOp].idxField = pThis->aOperands[pThis->iRegOp].idxFieldBase + 1; 3033 pThis->aOperands[pThis->iRmOp ].enmLocation = BS3CG1OPLOC_CTX_ZX_VLMAX;3034 3080 pThis->fInvalidEncoding = true; 3035 3081 break; … … 3052 3098 pThis->aOperands[pThis->iRmOp ].cbOp = 32; 3053 3099 pThis->aOperands[pThis->iRmOp ].idxFieldBase = BS3CG1DST_YMM0; 3054 pThis->aOperands[pThis->iRmOp ].enmLocation = BS3CG1OPLOC_CTX_ZX_VLMAX;3100 pThis->aOperands[pThis->iRmOp ].enmLocation = pThis->aOperands[pThis->iRmOp].enmLocationReg; 3055 3101 pThis->aOperands[pThis->iRegOp].cbOp = 32; 3056 3102 pThis->aOperands[pThis->iRegOp].idxFieldBase = BS3CG1DST_YMM0; … … 3079 3125 off = Bs3Cg1InsertVex2bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 1 /*L*/, 1 /*~R*/); 3080 3126 off = Bs3Cg1InsertOpcodes(pThis, off); 3081 off = Bs3Cfg1EncodeMemMod0DispWithRegField(pThis, false, off, 2 /*iReg*/, 32, 0, BS3CG1OPLOC_MEM_WO); 3127 pThis->aOperands[pThis->iRmOp ].enmLocation = pThis->aOperands[pThis->iRmOp].enmLocationMem; 3128 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 2 /*iReg*/, 0); 3082 3129 break; 3083 3130 case 24: 3084 3131 off = Bs3Cg1InsertVex3bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 1 /*L*/, 1 /*~R*/, 1 /*~X*/, 1 /*~B*/, 0 /*W*/); 3085 3132 off = Bs3Cg1InsertOpcodes(pThis, off); 3086 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 3 /*iReg*/, 32, 0, BS3CG1OPLOC_MEM_WO);3133 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 3 /*iReg*/, 0); 3087 3134 break; 3088 3135 case 25: 3089 3136 off = Bs3Cg1InsertVex3bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 1 /*L*/, 1 /*~R*/, 1 /*~X*/, 1 /*~B*/, 1 /*W - ignored */); 3090 3137 off = Bs3Cg1InsertOpcodes(pThis, off); 3091 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 3 /*iReg*/, 32, 0, BS3CG1OPLOC_MEM_WO);3138 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 3 /*iReg*/, 0); 3092 3139 break; 3093 3140 case 26: 3094 3141 off = Bs3Cg1InsertVex2bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 1 /*L*/, 1 /*~R*/); 3095 3142 off = Bs3Cg1InsertOpcodes(pThis, off); 3096 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 3 /*iReg*/, 32, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM_WO);3097 if (!Bs3Cg1XcptTypeIs Unaligned(pThis->enmXcptType))3143 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 3 /*iReg*/, 1 /*cbMissalign*/); 3144 if (!Bs3Cg1XcptTypeIsVexUnaligned(pThis->enmXcptType)) 3098 3145 pThis->bAlignmentXcpt = X86_XCPT_GP; 3099 3146 break; … … 3101 3148 off = Bs3Cg1InsertVex3bPrefix(pThis, 0 /*offDst*/, 0xf /*~V*/, 1 /*L*/, 1 /*~R*/, 1 /*~X*/, 1 /*~B*/, 0 /*W*/); 3102 3149 off = Bs3Cg1InsertOpcodes(pThis, off); 3103 off = Bs3Cfg1EncodeMemMod0DispWithRegField (pThis, false, off, 3 /*iReg*/, 32, 1 /*cbMissalign*/, BS3CG1OPLOC_MEM_WO);3104 if (!Bs3Cg1XcptTypeIs Unaligned(pThis->enmXcptType))3150 off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndDefaults(pThis, false, off, 3 /*iReg*/, 1 /*cbMissalign*/); 3151 if (!Bs3Cg1XcptTypeIsVexUnaligned(pThis->enmXcptType)) 3105 3152 pThis->bAlignmentXcpt = X86_XCPT_GP; 3106 3153 break; … … 3110 3157 off = Bs3Cg1InsertOpcodes(pThis, off); 3111 3158 pThis->abCurInstr[off++] = X86_MODRM_MAKE(3, 1, 0); 3159 pThis->aOperands[pThis->iRmOp ].enmLocation = pThis->aOperands[pThis->iRmOp].enmLocationReg; 3112 3160 pThis->aOperands[pThis->iRmOp ].idxField = pThis->aOperands[pThis->iRmOp ].idxFieldBase + 0; 3113 3161 pThis->aOperands[pThis->iRegOp].idxField = pThis->aOperands[pThis->iRegOp].idxFieldBase + 1; … … 3287 3335 { 3288 3336 pThis->bAlignmentXcpt = UINT8_MAX; 3337 pThis->uVexL = UINT8_MAX; 3289 3338 if (pThis->pfnEncoder) 3290 3339 return pThis->pfnEncoder(pThis, iEncoding); … … 3696 3745 break; 3697 3746 3747 case BS3CG1ENC_VEX_MODRM_Vx_WO_Wx: 3748 pThis->pfnEncoder = Bs3Cg1EncodeNext_VEX_MODRM_WsomethingWO_Vsomething_Wip_OR_ViceVersa; 3749 pThis->iRmOp = 1; 3750 pThis->iRegOp = 0; 3751 pThis->aOperands[0].cbOp = 16; 3752 pThis->aOperands[1].cbOp = 16; 3753 pThis->aOperands[0].enmLocation = BS3CG1OPLOC_CTX_ZX_VLMAX; 3754 pThis->aOperands[1].enmLocation = BS3CG1OPLOC_CTX; 3755 pThis->aOperands[1].enmLocationReg = BS3CG1OPLOC_CTX; 3756 pThis->aOperands[1].enmLocationMem = BS3CG1OPLOC_MEM; 3757 pThis->aOperands[0].idxFieldBase = BS3CG1DST_XMM0; 3758 pThis->aOperands[1].idxFieldBase = BS3CG1DST_XMM0; 3759 break; 3760 3698 3761 case BS3CG1ENC_VEX_MODRM_Md_WO_Vss: 3699 3762 pThis->pfnEncoder = Bs3Cg1EncodeNext_VEX_MODRM_VsomethingWO_Msomething_Wip_Lig_OR_ViceVersa; … … 3752 3815 case BS3CG1ENC_VEX_MODRM_Wps_WO_Vps: 3753 3816 case BS3CG1ENC_VEX_MODRM_Wpd_WO_Vpd: 3754 pThis->pfnEncoder = Bs3Cg1EncodeNext_VEX_MODRM_WsomethingWO_Vsomething_Wip ;3817 pThis->pfnEncoder = Bs3Cg1EncodeNext_VEX_MODRM_WsomethingWO_Vsomething_Wip_OR_ViceVersa; 3755 3818 pThis->iRmOp = 0; 3756 3819 pThis->iRegOp = 1; 3757 3820 pThis->aOperands[0].cbOp = 16; 3758 3821 pThis->aOperands[1].cbOp = 16; 3759 pThis->aOperands[0].enmLocation = BS3CG1OPLOC_CTX_ZX_VLMAX; 3760 pThis->aOperands[1].enmLocation = BS3CG1OPLOC_CTX; 3761 pThis->aOperands[0].idxFieldBase = BS3CG1DST_XMM0; 3762 pThis->aOperands[1].idxFieldBase = BS3CG1DST_XMM0; 3822 pThis->aOperands[0].enmLocation = BS3CG1OPLOC_CTX_ZX_VLMAX; 3823 pThis->aOperands[0].enmLocationReg = BS3CG1OPLOC_CTX_ZX_VLMAX; 3824 pThis->aOperands[0].enmLocationMem = BS3CG1OPLOC_MEM; 3825 pThis->aOperands[1].enmLocation = BS3CG1OPLOC_CTX; 3826 pThis->aOperands[0].idxFieldBase = BS3CG1DST_XMM0; 3827 pThis->aOperands[1].idxFieldBase = BS3CG1DST_XMM0; 3763 3828 break; 3764 3829 … … 4047 4112 CASE_PRED(BS3CG1PRED_SIZE_O32, pThis->cbOperand == 4); 4048 4113 CASE_PRED(BS3CG1PRED_SIZE_O64, pThis->cbOperand == 8); 4114 CASE_PRED(BS3CG1PRED_VEXL_0, pThis->uVexL == 0); 4115 CASE_PRED(BS3CG1PRED_VEXL_1, pThis->uVexL == 1); 4049 4116 CASE_PRED(BS3CG1PRED_RING_0, pThis->uCpl == 0); 4050 4117 CASE_PRED(BS3CG1PRED_RING_1, pThis->uCpl == 1); … … 5357 5424 } 5358 5425 } 5426 #if 1 5427 else ASMHalt(); 5428 #endif 5359 5429 } 5360 5430 else
Note:
See TracChangeset
for help on using the changeset viewer.