1 // Copyright 2014 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "src/compiler/instruction-scheduler.h" 6 7 namespace v8 { 8 namespace internal { 9 namespace compiler { 10 SchedulerSupported()11bool InstructionScheduler::SchedulerSupported() { return true; } 12 13 GetTargetInstructionFlags(const Instruction * instr) const14int InstructionScheduler::GetTargetInstructionFlags( 15 const Instruction* instr) const { 16 switch (instr->arch_opcode()) { 17 case kArm64Add: 18 case kArm64Add32: 19 case kArm64And: 20 case kArm64And32: 21 case kArm64Bic: 22 case kArm64Bic32: 23 case kArm64Clz: 24 case kArm64Clz32: 25 case kArm64Cmp: 26 case kArm64Cmp32: 27 case kArm64Cmn: 28 case kArm64Cmn32: 29 case kArm64Tst: 30 case kArm64Tst32: 31 case kArm64Or: 32 case kArm64Or32: 33 case kArm64Orn: 34 case kArm64Orn32: 35 case kArm64Eor: 36 case kArm64Eor32: 37 case kArm64Eon: 38 case kArm64Eon32: 39 case kArm64Sub: 40 case kArm64Sub32: 41 case kArm64Mul: 42 case kArm64Mul32: 43 case kArm64Smull: 44 case kArm64Umull: 45 case kArm64Madd: 46 case kArm64Madd32: 47 case kArm64Msub: 48 case kArm64Msub32: 49 case kArm64Mneg: 50 case kArm64Mneg32: 51 case kArm64Idiv: 52 case kArm64Idiv32: 53 case kArm64Udiv: 54 case kArm64Udiv32: 55 case kArm64Imod: 56 case kArm64Imod32: 57 case kArm64Umod: 58 case kArm64Umod32: 59 case kArm64Not: 60 case kArm64Not32: 61 case kArm64Lsl: 62 case kArm64Lsl32: 63 case kArm64Lsr: 64 case kArm64Lsr32: 65 case kArm64Asr: 66 case kArm64Asr32: 67 case kArm64Ror: 68 case kArm64Ror32: 69 case kArm64Mov32: 70 case kArm64Sxtb32: 71 case kArm64Sxth32: 72 case kArm64Sxtw: 73 case kArm64Sbfx32: 74 case kArm64Ubfx: 75 case kArm64Ubfx32: 76 case kArm64Ubfiz32: 77 case kArm64Bfi: 78 case kArm64Rbit: 79 case kArm64Rbit32: 80 case kArm64Float32Cmp: 81 case kArm64Float32Add: 82 case kArm64Float32Sub: 83 case kArm64Float32Mul: 84 case kArm64Float32Div: 85 case kArm64Float32Max: 86 case kArm64Float32Min: 87 case kArm64Float32Abs: 88 case kArm64Float32Neg: 89 case kArm64Float32Sqrt: 90 case kArm64Float32RoundDown: 91 case kArm64Float64Cmp: 92 case kArm64Float64Add: 93 case kArm64Float64Sub: 94 case kArm64Float64Mul: 95 case kArm64Float64Div: 96 case kArm64Float64Mod: 97 case kArm64Float64Max: 98 case kArm64Float64Min: 99 case kArm64Float64Abs: 100 case kArm64Float64Neg: 101 case kArm64Float64Sqrt: 102 case kArm64Float64RoundDown: 103 case kArm64Float64RoundTiesAway: 104 case kArm64Float64RoundTruncate: 105 case kArm64Float64RoundTiesEven: 106 case kArm64Float64RoundUp: 107 case kArm64Float32RoundTiesEven: 108 case kArm64Float32RoundTruncate: 109 case kArm64Float32RoundUp: 110 case kArm64Float32ToFloat64: 111 case kArm64Float64ToFloat32: 112 case kArm64Float32ToInt32: 113 case kArm64Float64ToInt32: 114 case kArm64Float32ToUint32: 115 case kArm64Float64ToUint32: 116 case kArm64Float32ToInt64: 117 case kArm64Float64ToInt64: 118 case kArm64Float32ToUint64: 119 case kArm64Float64ToUint64: 120 case kArm64Int32ToFloat32: 121 case kArm64Int32ToFloat64: 122 case kArm64Int64ToFloat32: 123 case kArm64Int64ToFloat64: 124 case kArm64Uint32ToFloat32: 125 case kArm64Uint32ToFloat64: 126 case kArm64Uint64ToFloat32: 127 case kArm64Uint64ToFloat64: 128 case kArm64Float64ExtractLowWord32: 129 case kArm64Float64ExtractHighWord32: 130 case kArm64Float64InsertLowWord32: 131 case kArm64Float64InsertHighWord32: 132 case kArm64Float64MoveU64: 133 case kArm64U64MoveFloat64: 134 case kArm64Float64SilenceNaN: 135 return kNoOpcodeFlags; 136 137 case kArm64TestAndBranch32: 138 case kArm64TestAndBranch: 139 case kArm64CompareAndBranch32: 140 case kArm64CompareAndBranch: 141 return kIsBlockTerminator; 142 143 case kArm64LdrS: 144 case kArm64LdrD: 145 case kArm64Ldrb: 146 case kArm64Ldrsb: 147 case kArm64Ldrh: 148 case kArm64Ldrsh: 149 case kArm64LdrW: 150 case kArm64Ldr: 151 return kIsLoadOperation; 152 153 case kArm64ClaimCSP: 154 case kArm64ClaimJSSP: 155 case kArm64PokeCSP: 156 case kArm64PokeJSSP: 157 case kArm64PokePair: 158 case kArm64StrS: 159 case kArm64StrD: 160 case kArm64Strb: 161 case kArm64Strh: 162 case kArm64StrW: 163 case kArm64Str: 164 return kHasSideEffect; 165 166 #define CASE(Name) case k##Name: 167 COMMON_ARCH_OPCODE_LIST(CASE) 168 #undef CASE 169 // Already covered in architecture independent code. 170 UNREACHABLE(); 171 } 172 173 UNREACHABLE(); 174 return kNoOpcodeFlags; 175 } 176 177 GetInstructionLatency(const Instruction * instr)178int InstructionScheduler::GetInstructionLatency(const Instruction* instr) { 179 // Basic latency modeling for arm64 instructions. They have been determined 180 // in an empirical way. 181 switch (instr->arch_opcode()) { 182 case kArm64Add: 183 case kArm64Add32: 184 case kArm64And: 185 case kArm64And32: 186 case kArm64Bic: 187 case kArm64Bic32: 188 case kArm64Cmn: 189 case kArm64Cmn32: 190 case kArm64Cmp: 191 case kArm64Cmp32: 192 case kArm64Eon: 193 case kArm64Eon32: 194 case kArm64Eor: 195 case kArm64Eor32: 196 case kArm64Not: 197 case kArm64Not32: 198 case kArm64Or: 199 case kArm64Or32: 200 case kArm64Orn: 201 case kArm64Orn32: 202 case kArm64Sub: 203 case kArm64Sub32: 204 case kArm64Tst: 205 case kArm64Tst32: 206 if (instr->addressing_mode() != kMode_None) { 207 return 3; 208 } else { 209 return 1; 210 } 211 212 case kArm64Clz: 213 case kArm64Clz32: 214 case kArm64Sbfx32: 215 case kArm64Sxtb32: 216 case kArm64Sxth32: 217 case kArm64Sxtw: 218 case kArm64Ubfiz32: 219 case kArm64Ubfx: 220 case kArm64Ubfx32: 221 return 1; 222 223 case kArm64Lsl: 224 case kArm64Lsl32: 225 case kArm64Lsr: 226 case kArm64Lsr32: 227 case kArm64Asr: 228 case kArm64Asr32: 229 case kArm64Ror: 230 case kArm64Ror32: 231 return 1; 232 233 case kArm64Ldr: 234 case kArm64LdrD: 235 case kArm64LdrS: 236 case kArm64LdrW: 237 case kArm64Ldrb: 238 case kArm64Ldrh: 239 case kArm64Ldrsb: 240 case kArm64Ldrsh: 241 return 11; 242 243 case kCheckedLoadInt8: 244 case kCheckedLoadUint8: 245 case kCheckedLoadInt16: 246 case kCheckedLoadUint16: 247 case kCheckedLoadWord32: 248 case kCheckedLoadWord64: 249 case kCheckedLoadFloat32: 250 case kCheckedLoadFloat64: 251 return 5; 252 253 case kArm64Str: 254 case kArm64StrD: 255 case kArm64StrS: 256 case kArm64StrW: 257 case kArm64Strb: 258 case kArm64Strh: 259 return 1; 260 261 case kCheckedStoreWord8: 262 case kCheckedStoreWord16: 263 case kCheckedStoreWord32: 264 case kCheckedStoreWord64: 265 case kCheckedStoreFloat32: 266 case kCheckedStoreFloat64: 267 return 1; 268 269 case kArm64Madd32: 270 case kArm64Mneg32: 271 case kArm64Msub32: 272 case kArm64Mul32: 273 return 3; 274 275 case kArm64Madd: 276 case kArm64Mneg: 277 case kArm64Msub: 278 case kArm64Mul: 279 return 5; 280 281 case kArm64Idiv32: 282 case kArm64Udiv32: 283 return 12; 284 285 case kArm64Idiv: 286 case kArm64Udiv: 287 return 20; 288 289 case kArm64Float32Add: 290 case kArm64Float32Sub: 291 case kArm64Float64Add: 292 case kArm64Float64Sub: 293 return 5; 294 295 case kArm64Float32Abs: 296 case kArm64Float32Cmp: 297 case kArm64Float32Neg: 298 case kArm64Float64Abs: 299 case kArm64Float64Cmp: 300 case kArm64Float64Neg: 301 return 3; 302 303 case kArm64Float32Div: 304 case kArm64Float32Sqrt: 305 return 12; 306 307 case kArm64Float64Div: 308 case kArm64Float64Sqrt: 309 return 19; 310 311 case kArm64Float32RoundDown: 312 case kArm64Float32RoundTiesEven: 313 case kArm64Float32RoundTruncate: 314 case kArm64Float32RoundUp: 315 case kArm64Float64RoundDown: 316 case kArm64Float64RoundTiesAway: 317 case kArm64Float64RoundTiesEven: 318 case kArm64Float64RoundTruncate: 319 case kArm64Float64RoundUp: 320 return 5; 321 322 case kArm64Float32ToFloat64: 323 case kArm64Float64ToFloat32: 324 case kArm64Float64ToInt32: 325 case kArm64Float64ToUint32: 326 case kArm64Float32ToInt64: 327 case kArm64Float64ToInt64: 328 case kArm64Float32ToUint64: 329 case kArm64Float64ToUint64: 330 case kArm64Int32ToFloat64: 331 case kArm64Int64ToFloat32: 332 case kArm64Int64ToFloat64: 333 case kArm64Uint32ToFloat64: 334 case kArm64Uint64ToFloat32: 335 case kArm64Uint64ToFloat64: 336 return 5; 337 338 default: 339 return 2; 340 } 341 } 342 343 } // namespace compiler 344 } // namespace internal 345 } // namespace v8 346