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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, | 460 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, |
461 SizeT MaxSrcs); | 461 SizeT MaxSrcs); |
462 | 462 |
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. | |
471 /// | |
472 /// MakeInstruction is a function-like object with signature | |
473 /// (Variable *Dest, Variable *Src0, Variable *Src1) -> Instr *. | |
474 template<typename F> | |
475 void scalarizeInstruction(Variable *Dest, Operand *Src0, Operand *Src1, | |
476 F &&MakeInstruction) { | |
477 assert(isVectorType(Dest->getType())); | |
Jim Stichnoth
2016/02/10 19:08:11
I would "assert(isVectorType(DestTy));" and move i
Eric Holk
2016/02/10 21:07:20
Done.
| |
478 const Type DestTy = Dest->getType(); | |
479 const Type DestElementTy = typeElementType(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 | |
487 Variable *T = Func->makeVariable(DestTy); | |
488 Context.insert<InstFakeDef>(T); | |
489 for (SizeT I = 0; I < NumElements; ++I) { | |
490 Constant *Index = Ctx->getConstantInt32(I); | |
491 | |
492 // Extract the next two inputs. | |
493 Variable *Op0 = Func->makeVariable(Src0ElementTy); | |
494 Context.insert<InstExtractElement>(Op0, Src0, Index); | |
495 Variable *Op1 = Func->makeVariable(Src1ElementTy); | |
496 Context.insert<InstExtractElement>(Op1, Src1, Index); | |
497 | |
498 // Perform the arithmetic as a scalar operation. | |
Jim Stichnoth
2016/02/10 19:08:12
You probably want change "arithmetic" to be more g
Eric Holk
2016/02/10 21:07:20
Done.
| |
499 Variable *Res = Func->makeVariable(DestElementTy); | |
500 auto Arith = MakeInstruction(Res, Op0, Op1); | |
501 // We might have created an operation that needed a helper call. | |
502 genTargetHelperCallFor(Arith); | |
503 | |
504 // Insert the result into position. | |
505 Variable *DestT = Func->makeVariable(DestTy); | |
506 Context.insert<InstInsertElement>(DestT, T, Res, Index); | |
507 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 assert(isVectorType(Dest->getType())); | |
516 const Type DestTy = Dest->getType(); | |
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 arithmetic 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 } | |
543 Context.insert<InstAssign>(Dest, T); | |
544 } | |
545 | |
546 | |
470 /// SandboxType enumerates all possible sandboxing strategies that | 547 /// SandboxType enumerates all possible sandboxing strategies that |
471 enum SandboxType { | 548 enum SandboxType { |
472 ST_None, | 549 ST_None, |
473 ST_NaCl, | 550 ST_NaCl, |
474 ST_Nonsfi, | 551 ST_Nonsfi, |
475 }; | 552 }; |
476 | 553 |
477 static SandboxType determineSandboxTypeFromFlags(const ClFlags &Flags); | 554 static SandboxType determineSandboxTypeFromFlags(const ClFlags &Flags); |
478 | 555 |
479 Cfg *Func; | 556 Cfg *Func; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 virtual void lower() {} | 648 virtual void lower() {} |
572 | 649 |
573 protected: | 650 protected: |
574 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 651 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
575 GlobalContext *Ctx; | 652 GlobalContext *Ctx; |
576 }; | 653 }; |
577 | 654 |
578 } // end of namespace Ice | 655 } // end of namespace Ice |
579 | 656 |
580 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 657 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
OLD | NEW |