Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: src/mips64/constants-mips64.h

Issue 1356693002: MIPS64: Optimize simulator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix nit. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/mips64/constants-mips64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_MIPS_CONSTANTS_H_ 5 #ifndef V8_MIPS_CONSTANTS_H_
6 #define V8_MIPS_CONSTANTS_H_ 6 #define V8_MIPS_CONSTANTS_H_
7 7
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/base/macros.h" 9 #include "src/base/macros.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 881 }
882 882
883 // Instruction type. 883 // Instruction type.
884 enum Type { 884 enum Type {
885 kRegisterType, 885 kRegisterType,
886 kImmediateType, 886 kImmediateType,
887 kJumpType, 887 kJumpType,
888 kUnsupported = -1 888 kUnsupported = -1
889 }; 889 };
890 890
891 enum TypeChecks { NORMAL, EXTRA };
892
893
894 #define OpcodeToBitNumber(opcode) \
895 (1ULL << (static_cast<uint32_t>(opcode) >> kOpcodeShift))
896
897 static const uint64_t kOpcodeImmediateTypeMask =
898 OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) |
899 OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) |
900 OpcodeToBitNumber(BGTZ) | OpcodeToBitNumber(ADDI) |
901 OpcodeToBitNumber(DADDI) | OpcodeToBitNumber(ADDIU) |
902 OpcodeToBitNumber(DADDIU) | OpcodeToBitNumber(SLTI) |
903 OpcodeToBitNumber(SLTIU) | OpcodeToBitNumber(ANDI) |
904 OpcodeToBitNumber(ORI) | OpcodeToBitNumber(XORI) |
905 OpcodeToBitNumber(LUI) | OpcodeToBitNumber(BEQL) |
906 OpcodeToBitNumber(BNEL) | OpcodeToBitNumber(BLEZL) |
907 OpcodeToBitNumber(BGTZL) | OpcodeToBitNumber(POP66) |
908 OpcodeToBitNumber(POP76) | OpcodeToBitNumber(LB) | OpcodeToBitNumber(LH) |
909 OpcodeToBitNumber(LWL) | OpcodeToBitNumber(LW) | OpcodeToBitNumber(LWU) |
910 OpcodeToBitNumber(LD) | OpcodeToBitNumber(LBU) | OpcodeToBitNumber(LHU) |
911 OpcodeToBitNumber(LWR) | OpcodeToBitNumber(SB) | OpcodeToBitNumber(SH) |
912 OpcodeToBitNumber(SWL) | OpcodeToBitNumber(SW) | OpcodeToBitNumber(SD) |
913 OpcodeToBitNumber(SWR) | OpcodeToBitNumber(LWC1) |
914 OpcodeToBitNumber(LDC1) | OpcodeToBitNumber(SWC1) |
915 OpcodeToBitNumber(SDC1) | OpcodeToBitNumber(PCREL) |
916 OpcodeToBitNumber(BC) | OpcodeToBitNumber(BALC);
917
918 #define FunctionFieldToBitNumber(function) (1ULL << function)
919
920 static const uint64_t kFunctionFieldRegisterTypeMask =
921 FunctionFieldToBitNumber(JR) | FunctionFieldToBitNumber(JALR) |
922 FunctionFieldToBitNumber(BREAK) | FunctionFieldToBitNumber(SLL) |
923 FunctionFieldToBitNumber(DSLL) | FunctionFieldToBitNumber(DSLL32) |
924 FunctionFieldToBitNumber(SRL) | FunctionFieldToBitNumber(DSRL) |
925 FunctionFieldToBitNumber(DSRL32) | FunctionFieldToBitNumber(SRA) |
926 FunctionFieldToBitNumber(DSRA) | FunctionFieldToBitNumber(DSRA32) |
927 FunctionFieldToBitNumber(SLLV) | FunctionFieldToBitNumber(DSLLV) |
928 FunctionFieldToBitNumber(SRLV) | FunctionFieldToBitNumber(DSRLV) |
929 FunctionFieldToBitNumber(SRAV) | FunctionFieldToBitNumber(DSRAV) |
930 FunctionFieldToBitNumber(MFHI) | FunctionFieldToBitNumber(MFLO) |
931 FunctionFieldToBitNumber(MULT) | FunctionFieldToBitNumber(DMULT) |
932 FunctionFieldToBitNumber(MULTU) | FunctionFieldToBitNumber(DMULTU) |
933 FunctionFieldToBitNumber(DIV) | FunctionFieldToBitNumber(DDIV) |
934 FunctionFieldToBitNumber(DIVU) | FunctionFieldToBitNumber(DDIVU) |
935 FunctionFieldToBitNumber(ADD) | FunctionFieldToBitNumber(DADD) |
936 FunctionFieldToBitNumber(ADDU) | FunctionFieldToBitNumber(DADDU) |
937 FunctionFieldToBitNumber(SUB) | FunctionFieldToBitNumber(DSUB) |
938 FunctionFieldToBitNumber(SUBU) | FunctionFieldToBitNumber(DSUBU) |
939 FunctionFieldToBitNumber(AND) | FunctionFieldToBitNumber(OR) |
940 FunctionFieldToBitNumber(XOR) | FunctionFieldToBitNumber(NOR) |
941 FunctionFieldToBitNumber(SLT) | FunctionFieldToBitNumber(SLTU) |
942 FunctionFieldToBitNumber(TGE) | FunctionFieldToBitNumber(TGEU) |
943 FunctionFieldToBitNumber(TLT) | FunctionFieldToBitNumber(TLTU) |
944 FunctionFieldToBitNumber(TEQ) | FunctionFieldToBitNumber(TNE) |
945 FunctionFieldToBitNumber(MOVZ) | FunctionFieldToBitNumber(MOVN) |
946 FunctionFieldToBitNumber(MOVCI) | FunctionFieldToBitNumber(SELEQZ_S) |
947 FunctionFieldToBitNumber(SELNEZ_S);
948
949
891 // Get the encoding type of the instruction. 950 // Get the encoding type of the instruction.
892 Type InstructionType() const; 951 inline Type InstructionType(TypeChecks checks = NORMAL) const;
893 952
894 953
895 // Accessors for the different named fields used in the MIPS encoding. 954 // Accessors for the different named fields used in the MIPS encoding.
896 inline Opcode OpcodeValue() const { 955 inline Opcode OpcodeValue() const {
897 return static_cast<Opcode>( 956 return static_cast<Opcode>(
898 Bits(kOpcodeShift + kOpcodeBits - 1, kOpcodeShift)); 957 Bits(kOpcodeShift + kOpcodeBits - 1, kOpcodeShift));
899 } 958 }
900 959
901 inline int RsValue() const { 960 inline int RsValue() const {
902 DCHECK(InstructionType() == kRegisterType || 961 DCHECK(InstructionType() == kRegisterType ||
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 // C/C++ argument slots size. 1130 // C/C++ argument slots size.
1072 const int kCArgSlotCount = (kMipsAbi == kN64) ? 0 : 4; 1131 const int kCArgSlotCount = (kMipsAbi == kN64) ? 0 : 4;
1073 1132
1074 // TODO(plind): below should be based on kPointerSize 1133 // TODO(plind): below should be based on kPointerSize
1075 // TODO(plind): find all usages and remove the needless instructions for n64. 1134 // TODO(plind): find all usages and remove the needless instructions for n64.
1076 const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize * 2; 1135 const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize * 2;
1077 1136
1078 const int kInvalidStackOffset = -1; 1137 const int kInvalidStackOffset = -1;
1079 const int kBranchReturnOffset = 2 * Instruction::kInstrSize; 1138 const int kBranchReturnOffset = 2 * Instruction::kInstrSize;
1080 1139
1140
1141 Instruction::Type Instruction::InstructionType(TypeChecks checks) const {
1142 if (checks == EXTRA) {
1143 if (OpcodeToBitNumber(OpcodeFieldRaw()) & kOpcodeImmediateTypeMask) {
1144 return kImmediateType;
1145 }
1146 }
1147 switch (OpcodeFieldRaw()) {
1148 case SPECIAL:
1149 if (checks == EXTRA) {
1150 if (FunctionFieldToBitNumber(FunctionFieldRaw()) &
1151 kFunctionFieldRegisterTypeMask) {
1152 return kRegisterType;
1153 } else {
1154 return kUnsupported;
1155 }
1156 } else {
1157 return kRegisterType;
1158 }
1159 break;
1160 case SPECIAL2:
1161 switch (FunctionFieldRaw()) {
1162 case MUL:
1163 case CLZ:
1164 return kRegisterType;
1165 default:
1166 return kUnsupported;
1167 }
1168 break;
1169 case SPECIAL3:
1170 switch (FunctionFieldRaw()) {
1171 case INS:
1172 case EXT:
1173 case DEXT:
1174 return kRegisterType;
1175 case BSHFL: {
1176 int sa = SaFieldRaw() >> kSaShift;
1177 switch (sa) {
1178 case BITSWAP:
1179 return kRegisterType;
1180 case WSBH:
1181 case SEB:
1182 case SEH:
1183 return kUnsupported;
1184 }
1185 sa >>= kBp2Bits;
1186 switch (sa) {
1187 case ALIGN:
1188 return kRegisterType;
1189 default:
1190 return kUnsupported;
1191 }
1192 }
1193 case DBSHFL: {
1194 int sa = SaFieldRaw() >> kSaShift;
1195 switch (sa) {
1196 case DBITSWAP:
1197 return kRegisterType;
1198 case DSBH:
1199 case DSHD:
1200 return kUnsupported;
1201 }
1202 sa = SaFieldRaw() >> kSaShift;
1203 sa >>= kBp3Bits;
1204 switch (sa) {
1205 case DALIGN:
1206 return kRegisterType;
1207 default:
1208 return kUnsupported;
1209 }
1210 }
1211 default:
1212 return kUnsupported;
1213 }
1214 break;
1215 case COP1: // Coprocessor instructions.
1216 switch (RsFieldRawNoAssert()) {
1217 case BC1: // Branch on coprocessor condition.
1218 case BC1EQZ:
1219 case BC1NEZ:
1220 return kImmediateType;
1221 default:
1222 return kRegisterType;
1223 }
1224 break;
1225 case COP1X:
1226 return kRegisterType;
1227
1228 // 26 bits immediate type instructions. e.g.: j imm26.
1229 case J:
1230 case JAL:
1231 return kJumpType;
1232
1233 default:
1234 if (checks == NORMAL) {
1235 return kImmediateType;
1236 } else {
1237 return kUnsupported;
1238 }
1239 }
1240 return kUnsupported;
1241 }
1242
1243 #undef OpcodeToBitNumber
1244 #undef FunctionFieldToBitNumber
1081 } } // namespace v8::internal 1245 } } // namespace v8::internal
1082 1246
1083 #endif // #ifndef V8_MIPS_CONSTANTS_H_ 1247 #endif // #ifndef V8_MIPS_CONSTANTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/mips64/constants-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698