OLD | NEW |
---|---|
1 //===- subzero/src/IceInstX86BaseImpl.h - Generic X86 instructions -*- C++ -*=// | 1 //===- subzero/src/IceInstX86BaseImpl.h - Generic X86 instructions -*- C++ -*=// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1323 (void)Src0Var; | 1323 (void)Src0Var; |
1324 assert(Src0Var && | 1324 assert(Src0Var && |
1325 Src0Var->getRegNum() == | 1325 Src0Var->getRegNum() == |
1326 InstX86Base<Machine>::Traits::RegisterSet::Reg_eax); | 1326 InstX86Base<Machine>::Traits::RegisterSet::Reg_eax); |
1327 static const typename InstX86Base< | 1327 static const typename InstX86Base< |
1328 Machine>::Traits::Assembler::GPREmitterOneOp Emitter = { | 1328 Machine>::Traits::Assembler::GPREmitterOneOp Emitter = { |
1329 &InstX86Base<Machine>::Traits::Assembler::imul, | 1329 &InstX86Base<Machine>::Traits::Assembler::imul, |
1330 &InstX86Base<Machine>::Traits::Assembler::imul}; | 1330 &InstX86Base<Machine>::Traits::Assembler::imul}; |
1331 emitIASOpTyGPR<Machine>(Func, Ty, this->getSrc(1), Emitter); | 1331 emitIASOpTyGPR<Machine>(Func, Ty, this->getSrc(1), Emitter); |
1332 } else { | 1332 } else { |
1333 // We only use imul as a two-address instruction even though there is a 3 | 1333 // The two-address version is used when multiplying by a non-constant. |
Jim Stichnoth
2015/09/25 21:02:10
or for the 8-bit version (right?)
sehr
2015/09/25 23:04:40
Done.
| |
1334 // operand version when one of the operands is a constant. | |
1335 assert(Var == this->getSrc(0)); | 1334 assert(Var == this->getSrc(0)); |
1336 static const typename InstX86Base< | 1335 static const typename InstX86Base< |
1337 Machine>::Traits::Assembler::GPREmitterRegOp Emitter = { | 1336 Machine>::Traits::Assembler::GPREmitterRegOp Emitter = { |
1338 &InstX86Base<Machine>::Traits::Assembler::imul, | 1337 &InstX86Base<Machine>::Traits::Assembler::imul, |
1339 &InstX86Base<Machine>::Traits::Assembler::imul, | 1338 &InstX86Base<Machine>::Traits::Assembler::imul, |
1340 &InstX86Base<Machine>::Traits::Assembler::imul}; | 1339 &InstX86Base<Machine>::Traits::Assembler::imul}; |
1341 emitIASRegOpTyGPR<Machine>(Func, Ty, Var, Src, Emitter); | 1340 emitIASRegOpTyGPR<Machine>(Func, Ty, Var, Src, Emitter); |
1342 } | 1341 } |
1343 } | 1342 } |
1344 | 1343 |
1345 template <class Machine> | 1344 template <class Machine> |
1345 void InstX86ImulImm<Machine>::emit(const Cfg *Func) const { | |
1346 if (!BuildDefs::dump()) | |
1347 return; | |
1348 Ostream &Str = Func->getContext()->getStrEmit(); | |
1349 assert(this->getSrcSize() == 2); | |
1350 Variable *Dest = this->getDest(); | |
Jim Stichnoth
2015/09/25 21:02:10
Add an assert that the type is i16 or i32. (The e
sehr
2015/09/25 23:04:40
Done.
| |
1351 assert(llvm::isa<Constant>(this->getSrc(1))); | |
1352 Str << "\timul" << this->getWidthString(Dest->getType()) << "\t"; | |
1353 this->getSrc(1)->emit(Func); | |
1354 Str << ", "; | |
1355 this->getSrc(0)->emit(Func); | |
1356 Str << ", "; | |
1357 Dest->emit(Func); | |
1358 } | |
1359 | |
1360 template <class Machine> | |
1361 void InstX86ImulImm<Machine>::emitIAS(const Cfg *Func) const { | |
1362 assert(this->getSrcSize() == 2); | |
1363 const Variable *Dest = this->getDest(); | |
1364 Type Ty = Dest->getType(); | |
1365 assert(llvm::isa<Constant>(this->getSrc(1))); | |
1366 static const typename InstX86Base<Machine>::Traits::Assembler:: | |
1367 template ThreeOpImmEmitter< | |
1368 typename InstX86Base<Machine>::Traits::RegisterSet::GPRRegister, | |
1369 typename InstX86Base<Machine>::Traits::RegisterSet::GPRRegister> | |
1370 Emitter = {&InstX86Base<Machine>::Traits::Assembler::imul_imm, | |
1371 &InstX86Base<Machine>::Traits::Assembler::imul_imm}; | |
1372 emitIASThreeOpImmOps< | |
1373 Machine, typename InstX86Base<Machine>::Traits::RegisterSet::GPRRegister, | |
1374 typename InstX86Base<Machine>::Traits::RegisterSet::GPRRegister, | |
1375 InstX86Base<Machine>::Traits::RegisterSet::getEncodedGPR, | |
1376 InstX86Base<Machine>::Traits::RegisterSet::getEncodedGPR>( | |
1377 Func, Ty, Dest, this->getSrc(0), this->getSrc(1), Emitter); | |
1378 } | |
1379 | |
1380 template <class Machine> | |
1346 void InstX86Insertps<Machine>::emitIAS(const Cfg *Func) const { | 1381 void InstX86Insertps<Machine>::emitIAS(const Cfg *Func) const { |
1347 assert(this->getSrcSize() == 3); | 1382 assert(this->getSrcSize() == 3); |
1348 assert(static_cast<typename InstX86Base<Machine>::Traits::TargetLowering *>( | 1383 assert(static_cast<typename InstX86Base<Machine>::Traits::TargetLowering *>( |
1349 Func->getTarget()) | 1384 Func->getTarget()) |
1350 ->getInstructionSet() >= InstX86Base<Machine>::Traits::SSE4_1); | 1385 ->getInstructionSet() >= InstX86Base<Machine>::Traits::SSE4_1); |
1351 const Variable *Dest = this->getDest(); | 1386 const Variable *Dest = this->getDest(); |
1352 assert(Dest == this->getSrc(0)); | 1387 assert(Dest == this->getSrc(0)); |
1353 Type Ty = Dest->getType(); | 1388 Type Ty = Dest->getType(); |
1354 static const typename InstX86Base<Machine>::Traits::Assembler:: | 1389 static const typename InstX86Base<Machine>::Traits::Assembler:: |
1355 template ThreeOpImmEmitter< | 1390 template ThreeOpImmEmitter< |
(...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3273 return; | 3308 return; |
3274 Ostream &Str = Func->getContext()->getStrDump(); | 3309 Ostream &Str = Func->getContext()->getStrDump(); |
3275 Str << "IACA_END"; | 3310 Str << "IACA_END"; |
3276 } | 3311 } |
3277 | 3312 |
3278 } // end of namespace X86Internal | 3313 } // end of namespace X86Internal |
3279 | 3314 |
3280 } // end of namespace Ice | 3315 } // end of namespace Ice |
3281 | 3316 |
3282 #endif // SUBZERO_SRC_ICEINSTX86BASEIMPL_H | 3317 #endif // SUBZERO_SRC_ICEINSTX86BASEIMPL_H |
OLD | NEW |