OLD | NEW |
---|---|
1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- C++ -*-===// | 1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); } | 463 void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); } |
464 | 464 |
465 bool shouldOptimizeMemIntrins(); | 465 bool shouldOptimizeMemIntrins(); |
466 | 466 |
467 void scalarizeArithmetic(InstArithmetic::OpKind K, Variable *Dest, | 467 void scalarizeArithmetic(InstArithmetic::OpKind K, Variable *Dest, |
468 Operand *Src0, Operand *Src1); | 468 Operand *Src0, Operand *Src1); |
469 | 469 |
470 /// Generalizes scalarizeArithmetic to support other instruction types. | 470 /// Generalizes scalarizeArithmetic to support other instruction types. |
471 /// | 471 /// |
472 /// MakeInstruction is a function-like object with signature | 472 /// MakeInstruction is a function-like object with signature |
473 /// (Variable *Dest, Variable *Src0, Variable *Src1) -> Instr *. | 473 /// (Variable *Dest, Variable *Src0, Variable *Src1) -> Instr *. |
John
2016/02/11 15:02:41
out of date comment...
that's why I would encoura
| |
474 template <typename F> | 474 template <typename F, typename... Operands> |
475 void scalarizeInstruction(Variable *Dest, Operand *Src0, Operand *Src1, | 475 void scalarizeInstruction(Variable *Dest, F &&MakeInstruction, |
John
2016/02/11 15:02:41
MakeInstruction is a parameter, hence it is named
Eric Holk
2016/02/11 19:17:23
That sounds alright to me. I went ahead and made t
| |
476 F &&MakeInstruction) { | 476 Operands *... Srcs) { |
John
2016/02/11 15:02:41
I didn't see this before, but I am not a fan of th
| |
477 const Type DestTy = Dest->getType(); | 477 const Type DestTy = Dest->getType(); |
478 assert(isVectorType(DestTy)); | 478 assert(isVectorType(DestTy)); |
479 const Type DestElementTy = typeElementType(DestTy); | 479 const Type DestElementTy = typeElementType(DestTy); |
480 const SizeT NumElements = typeNumElements(DestTy); | 480 const SizeT NumElements = typeNumElements(DestTy); |
481 const Type Src0ElementTy = typeElementType(Src0->getType()); | |
482 const Type Src1ElementTy = typeElementType(Src1->getType()); | |
483 | |
484 assert(NumElements == typeNumElements(Src0->getType())); | |
485 assert(NumElements == typeNumElements(Src1->getType())); | |
486 | 481 |
487 Variable *T = Func->makeVariable(DestTy); | 482 Variable *T = Func->makeVariable(DestTy); |
488 Context.insert<InstFakeDef>(T); | 483 Context.insert<InstFakeDef>(T); |
484 | |
489 for (SizeT I = 0; I < NumElements; ++I) { | 485 for (SizeT I = 0; I < NumElements; ++I) { |
490 Constant *Index = Ctx->getConstantInt32(I); | 486 auto *Index = Ctx->getConstantInt32(I); |
491 | 487 |
492 // Extract the next two inputs. | 488 auto MakeExtract = [&](Operand *Src) { |
John
2016/02/11 15:02:41
please, no default capture -- capture what you nee
Jim Stichnoth
2016/02/11 15:26:07
Check whether the experts (hi John!) are OK with t
Eric Holk
2016/02/11 19:17:23
Done.
| |
493 Variable *Op0 = Func->makeVariable(Src0ElementTy); | 489 assert(typeNumElements(Src->getType()) == NumElements); |
494 Context.insert<InstExtractElement>(Op0, Src0, Index); | 490 |
495 Variable *Op1 = Func->makeVariable(Src1ElementTy); | 491 const auto ElementTy = typeElementType(Src->getType()); |
496 Context.insert<InstExtractElement>(Op1, Src1, Index); | 492 Variable *Op = Func->makeVariable(ElementTy); |
John
2016/02/11 15:02:41
auto here?
John
2016/02/11 15:02:41
why did you use makeVariable instead of makeReg?
Eric Holk
2016/02/11 19:17:23
makeReg is defined in TargetARM32, and this is in
Eric Holk
2016/02/11 19:17:23
Done.
| |
493 Context.insert<InstExtractElement>(Op, Src, Index); | |
494 return Op; | |
495 }; | |
497 | 496 |
498 // Perform the operation as a scalar operation. | 497 // Perform the operation as a scalar operation. |
499 Variable *Res = Func->makeVariable(DestElementTy); | 498 Variable *Res = Func->makeVariable(DestElementTy); |
500 auto Arith = MakeInstruction(Res, Op0, Op1); | 499 auto *Arith = MakeInstruction(Res, MakeExtract(Srcs)...); |
John
2016/02/11 15:02:41
I just noticed that MakeInstruction is misleading.
Eric Holk
2016/02/11 19:17:23
Done.
| |
501 // We might have created an operation that needed a helper call. | |
502 genTargetHelperCallFor(Arith); | 500 genTargetHelperCallFor(Arith); |
John
2016/02/11 15:02:41
Calling this method here is bad -- really bad.
Th
Eric Holk
2016/02/11 19:17:23
Scalarize is called by genTargetHelperCallsFor, so
| |
503 | 501 |
504 // Insert the result into position. | |
505 Variable *DestT = Func->makeVariable(DestTy); | 502 Variable *DestT = Func->makeVariable(DestTy); |
506 Context.insert<InstInsertElement>(DestT, T, Res, Index); | 503 Context.insert<InstInsertElement>(DestT, T, Res, Index); |
507 T = DestT; | 504 T = DestT; |
508 } | |
509 Context.insert<InstAssign>(Dest, T); | |
510 } | |
511 | |
512 template <typename F> | |
513 void scalarizeUnaryInstruction(Variable *Dest, Operand *Src0, | |
514 F &&MakeInstruction) { | |
515 const Type DestTy = Dest->getType(); | |
516 assert(isVectorType(DestTy)); | |
517 const Type DestElementTy = typeElementType(DestTy); | |
518 const SizeT NumElements = typeNumElements(DestTy); | |
519 const Type Src0ElementTy = typeElementType(Src0->getType()); | |
520 | |
521 assert(NumElements == typeNumElements(Src0->getType())); | |
522 | |
523 Variable *T = Func->makeVariable(DestTy); | |
524 Context.insert<InstFakeDef>(T); | |
525 for (SizeT I = 0; I < NumElements; ++I) { | |
526 Constant *Index = Ctx->getConstantInt32(I); | |
527 | |
528 // Extract the next two inputs. | |
529 Variable *Op0 = Func->makeVariable(Src0ElementTy); | |
530 Context.insert<InstExtractElement>(Op0, Src0, Index); | |
531 | |
532 // Perform the operation as a scalar operation. | |
533 Variable *Res = Func->makeVariable(DestElementTy); | |
534 auto Arith = MakeInstruction(Res, Op0); | |
535 // We might have created an operation that needed a helper call. | |
536 genTargetHelperCallFor(Arith); | |
537 | |
538 // Insert the result into position. | |
539 Variable *DestT = Func->makeVariable(DestTy); | |
540 Context.insert<InstInsertElement>(DestT, T, Res, Index); | |
541 T = DestT; | |
542 } | 505 } |
543 Context.insert<InstAssign>(Dest, T); | 506 Context.insert<InstAssign>(Dest, T); |
544 } | 507 } |
545 | 508 |
546 /// SandboxType enumerates all possible sandboxing strategies that | 509 /// SandboxType enumerates all possible sandboxing strategies that |
547 enum SandboxType { | 510 enum SandboxType { |
548 ST_None, | 511 ST_None, |
549 ST_NaCl, | 512 ST_NaCl, |
550 ST_Nonsfi, | 513 ST_Nonsfi, |
551 }; | 514 }; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 virtual void lower() {} | 610 virtual void lower() {} |
648 | 611 |
649 protected: | 612 protected: |
650 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 613 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
651 GlobalContext *Ctx; | 614 GlobalContext *Ctx; |
652 }; | 615 }; |
653 | 616 |
654 } // end of namespace Ice | 617 } // end of namespace Ice |
655 | 618 |
656 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 619 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
OLD | NEW |