OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===// | 1 //===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- 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 // This file declares the TargetLoweringX8632 class, which | 10 // This file declares the TargetLoweringX8632 class, which |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "IceInstX8632.h" | 24 #include "IceInstX8632.h" |
25 #include "IceRegistersX8632.h" | 25 #include "IceRegistersX8632.h" |
26 #include "IceTargetLowering.h" | 26 #include "IceTargetLowering.h" |
27 | 27 |
28 namespace Ice { | 28 namespace Ice { |
29 | 29 |
30 class BoolFoldingEntry { | 30 class BoolFoldingEntry { |
31 BoolFoldingEntry(const BoolFoldingEntry &) = delete; | 31 BoolFoldingEntry(const BoolFoldingEntry &) = delete; |
32 | 32 |
33 public: | 33 public: |
34 BoolFoldingEntry() | 34 BoolFoldingEntry() = default; |
35 : Instr(nullptr), IsComplex(false), IsLiveOut(true), NumUses(0) {} | |
36 explicit BoolFoldingEntry(Inst *I); | 35 explicit BoolFoldingEntry(Inst *I); |
37 BoolFoldingEntry &operator=(const BoolFoldingEntry &) = default; | 36 BoolFoldingEntry &operator=(const BoolFoldingEntry &) = default; |
38 // Instr is the instruction producing the i1-type variable of interest. | 37 // Instr is the instruction producing the i1-type variable of interest. |
39 Inst *Instr; | 38 Inst *Instr = nullptr; |
40 // IsComplex is the cached result of BoolFolding::hasComplexLowering(Instr). | 39 // IsComplex is the cached result of BoolFolding::hasComplexLowering(Instr). |
41 bool IsComplex; | 40 bool IsComplex = false; |
42 // IsLiveOut is initialized conservatively to true, and is set to false when | 41 // IsLiveOut is initialized conservatively to true, and is set to false when |
43 // we encounter an instruction that ends Var's live range. We disable the | 42 // we encounter an instruction that ends Var's live range. We disable the |
44 // folding optimization when Var is live beyond this basic block. Note that | 43 // folding optimization when Var is live beyond this basic block. Note that |
45 // if liveness analysis is not performed (e.g. in Om1 mode), IsLiveOut will | 44 // if liveness analysis is not performed (e.g. in Om1 mode), IsLiveOut will |
46 // always be true and the folding optimization will never be performed. | 45 // always be true and the folding optimization will never be performed. |
47 bool IsLiveOut; | 46 bool IsLiveOut = true; |
48 // NumUses counts the number of times Var is used as a source operand in the | 47 // NumUses counts the number of times Var is used as a source operand in the |
49 // basic block. If IsComplex is true and there is more than one use of Var, | 48 // basic block. If IsComplex is true and there is more than one use of Var, |
50 // then the folding optimization is disabled for Var. | 49 // then the folding optimization is disabled for Var. |
51 uint32_t NumUses; | 50 uint32_t NumUses = 0; |
52 }; | 51 }; |
53 | 52 |
54 class BoolFolding { | 53 class BoolFolding { |
55 public: | 54 public: |
56 enum BoolFoldingProducerKind { | 55 enum BoolFoldingProducerKind { |
57 PK_None, | 56 PK_None, |
58 PK_Icmp32, | 57 PK_Icmp32, |
59 PK_Icmp64, | 58 PK_Icmp64, |
60 PK_Fcmp, | 59 PK_Fcmp, |
61 PK_Trunc | 60 PK_Trunc |
62 }; | 61 }; |
63 | 62 |
64 // Currently the actual enum values are not used (other than CK_None), but we | 63 // Currently the actual enum values are not used (other than CK_None), but we |
65 // go | 64 // go |
66 // ahead and produce them anyway for symmetry with the | 65 // ahead and produce them anyway for symmetry with the |
67 // BoolFoldingProducerKind. | 66 // BoolFoldingProducerKind. |
68 enum BoolFoldingConsumerKind { CK_None, CK_Br, CK_Select, CK_Sext, CK_Zext }; | 67 enum BoolFoldingConsumerKind { CK_None, CK_Br, CK_Select, CK_Sext, CK_Zext }; |
69 | 68 |
70 private: | 69 private: |
71 BoolFolding(const BoolFolding &) = delete; | 70 BoolFolding(const BoolFolding &) = delete; |
72 BoolFolding &operator=(const BoolFolding &) = delete; | 71 BoolFolding &operator=(const BoolFolding &) = delete; |
73 | 72 |
74 public: | 73 public: |
75 BoolFolding() {} | 74 BoolFolding() = default; |
76 static BoolFoldingProducerKind getProducerKind(const Inst *Instr); | 75 static BoolFoldingProducerKind getProducerKind(const Inst *Instr); |
77 static BoolFoldingConsumerKind getConsumerKind(const Inst *Instr); | 76 static BoolFoldingConsumerKind getConsumerKind(const Inst *Instr); |
78 static bool hasComplexLowering(const Inst *Instr); | 77 static bool hasComplexLowering(const Inst *Instr); |
79 void init(CfgNode *Node); | 78 void init(CfgNode *Node); |
80 const Inst *getProducerFor(const Operand *Opnd) const; | 79 const Inst *getProducerFor(const Operand *Opnd) const; |
81 void dump(const Cfg *Func) const; | 80 void dump(const Cfg *Func) const; |
82 | 81 |
83 private: | 82 private: |
84 // Returns true if Producers contains a valid entry for the given VarNum. | 83 // Returns true if Producers contains a valid entry for the given VarNum. |
85 bool containsValid(SizeT VarNum) const { | 84 bool containsValid(SizeT VarNum) const { |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 void _xor_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { | 578 void _xor_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { |
580 Context.insert(InstX8632XorRMW::create(Func, DestSrc0, Src1)); | 579 Context.insert(InstX8632XorRMW::create(Func, DestSrc0, Src1)); |
581 } | 580 } |
582 void _set_dest_nonkillable() { | 581 void _set_dest_nonkillable() { |
583 Context.getLastInserted()->setDestNonKillable(); | 582 Context.getLastInserted()->setDestNonKillable(); |
584 } | 583 } |
585 | 584 |
586 bool optimizeScalarMul(Variable *Dest, Operand *Src0, int32_t Src1); | 585 bool optimizeScalarMul(Variable *Dest, Operand *Src0, int32_t Src1); |
587 void findRMW(); | 586 void findRMW(); |
588 | 587 |
589 X86InstructionSet InstructionSet; | 588 X86InstructionSet InstructionSet = X86InstructionSet::Begin; |
590 bool IsEbpBasedFrame; | 589 bool IsEbpBasedFrame = false; |
591 bool NeedsStackAlignment; | 590 bool NeedsStackAlignment = false; |
592 size_t SpillAreaSizeBytes; | 591 size_t SpillAreaSizeBytes = 0; |
593 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; | 592 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; |
594 llvm::SmallBitVector ScratchRegs; | 593 llvm::SmallBitVector ScratchRegs; |
595 llvm::SmallBitVector RegsUsed; | 594 llvm::SmallBitVector RegsUsed; |
596 VarList PhysicalRegisters[IceType_NUM]; | 595 VarList PhysicalRegisters[IceType_NUM]; |
597 static IceString RegNames[]; | 596 static IceString RegNames[]; |
598 | 597 |
599 // Randomize a given immediate operand | 598 // Randomize a given immediate operand |
600 Operand *randomizeOrPoolImmediate(Constant *Immediate, | 599 Operand *randomizeOrPoolImmediate(Constant *Immediate, |
601 int32_t RegNum = Variable::NoRegister); | 600 int32_t RegNum = Variable::NoRegister); |
602 OperandX8632Mem * | 601 OperandX8632Mem * |
603 randomizeOrPoolImmediate(OperandX8632Mem *MemOperand, | 602 randomizeOrPoolImmediate(OperandX8632Mem *MemOperand, |
604 int32_t RegNum = Variable::NoRegister); | 603 int32_t RegNum = Variable::NoRegister); |
605 bool RandomizationPoolingPaused; | 604 bool RandomizationPoolingPaused = false; |
606 | 605 |
607 private: | 606 private: |
608 ~TargetX8632() override {} | 607 ~TargetX8632() override {} |
609 BoolFolding FoldingInfo; | 608 BoolFolding FoldingInfo; |
610 }; | 609 }; |
611 | 610 |
612 class TargetDataX8632 final : public TargetDataLowering { | 611 class TargetDataX8632 final : public TargetDataLowering { |
613 TargetDataX8632() = delete; | 612 TargetDataX8632() = delete; |
614 TargetDataX8632(const TargetDataX8632 &) = delete; | 613 TargetDataX8632(const TargetDataX8632 &) = delete; |
615 TargetDataX8632 &operator=(const TargetDataX8632 &) = delete; | 614 TargetDataX8632 &operator=(const TargetDataX8632 &) = delete; |
(...skipping 28 matching lines...) Expand all Loading... |
644 protected: | 643 protected: |
645 explicit TargetHeaderX8632(GlobalContext *Ctx); | 644 explicit TargetHeaderX8632(GlobalContext *Ctx); |
646 | 645 |
647 private: | 646 private: |
648 ~TargetHeaderX8632() = default; | 647 ~TargetHeaderX8632() = default; |
649 }; | 648 }; |
650 | 649 |
651 } // end of namespace Ice | 650 } // end of namespace Ice |
652 | 651 |
653 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H | 652 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H |
OLD | NEW |