| OLD | NEW |
| 1 //===- subzero/src/IceTargetLoweringX86Base.h - x86 lowering ----*- C++ -*-===// | 1 //===- subzero/src/IceTargetLoweringX86Base.h - x86 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 /// \file | 10 /// \file |
| 11 /// This file declares the TargetLoweringX86 template class, which implements | 11 /// This file declares the TargetLoweringX86 template class, which implements |
| 12 /// the TargetLowering base interface for the x86 architecture. | 12 /// the TargetLowering base interface for the x86 architecture. |
| 13 /// | 13 /// |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #ifndef SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H | 16 #ifndef SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H |
| 17 #define SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H | 17 #define SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H |
| 18 | 18 |
| 19 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 20 #include "IceInst.h" | 20 #include "IceInst.h" |
| 21 #include "IceSwitchLowering.h" | 21 #include "IceSwitchLowering.h" |
| 22 #include "IceTargetLowering.h" | 22 #include "IceTargetLowering.h" |
| 23 #include "IceTargetLoweringX86RegClass.h" |
| 23 #include "IceUtils.h" | 24 #include "IceUtils.h" |
| 24 | 25 |
| 25 #include <array> | 26 #include <array> |
| 26 #include <type_traits> | 27 #include <type_traits> |
| 27 #include <utility> | 28 #include <utility> |
| 28 | 29 |
| 29 namespace Ice { | 30 namespace Ice { |
| 30 namespace X86Internal { | 31 namespace X86Internal { |
| 31 | 32 |
| 32 template <class MachineTraits> class BoolFolding; | 33 template <class MachineTraits> class BoolFolding; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 void doLoadOpt(); | 67 void doLoadOpt(); |
| 67 bool doBranchOpt(Inst *I, const CfgNode *NextNode) override; | 68 bool doBranchOpt(Inst *I, const CfgNode *NextNode) override; |
| 68 | 69 |
| 69 SizeT getNumRegisters() const override { | 70 SizeT getNumRegisters() const override { |
| 70 return Traits::RegisterSet::Reg_NUM; | 71 return Traits::RegisterSet::Reg_NUM; |
| 71 } | 72 } |
| 72 Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override; | 73 Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override; |
| 73 IceString getRegName(SizeT RegNum, Type Ty) const override; | 74 IceString getRegName(SizeT RegNum, Type Ty) const override; |
| 74 llvm::SmallBitVector getRegisterSet(RegSetMask Include, | 75 llvm::SmallBitVector getRegisterSet(RegSetMask Include, |
| 75 RegSetMask Exclude) const override; | 76 RegSetMask Exclude) const override; |
| 76 const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const override { | 77 const llvm::SmallBitVector & |
| 77 return TypeToRegisterSet[Ty]; | 78 getRegistersForVariable(const Variable *Var) const override { |
| 79 RegClass RC = Var->getRegClass(); |
| 80 assert(static_cast<RegClassX86>(RC) < RCX86_NUM); |
| 81 return TypeToRegisterSet[RC]; |
| 78 } | 82 } |
| 79 | 83 |
| 80 const llvm::SmallBitVector &getAliasesForRegister(SizeT Reg) const override { | 84 const llvm::SmallBitVector &getAliasesForRegister(SizeT Reg) const override { |
| 81 assert(Reg < Traits::RegisterSet::Reg_NUM); | 85 assert(Reg < Traits::RegisterSet::Reg_NUM); |
| 82 return RegisterAliases[Reg]; | 86 return RegisterAliases[Reg]; |
| 83 } | 87 } |
| 84 | 88 |
| 85 bool hasFramePointer() const override { return IsEbpBasedFrame; } | 89 bool hasFramePointer() const override { return IsEbpBasedFrame; } |
| 86 void setHasFramePointer() override { IsEbpBasedFrame = true; } | 90 void setHasFramePointer() override { IsEbpBasedFrame = true; } |
| 87 SizeT getStackReg() const override { return Traits::RegisterSet::Reg_esp; } | 91 SizeT getStackReg() const override { return Traits::RegisterSet::Reg_esp; } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 /// type is suitable for copying memory i.e. a load and store will be a single | 260 /// type is suitable for copying memory i.e. a load and store will be a single |
| 257 /// instruction (for example x86 will get f64 not i64). | 261 /// instruction (for example x86 will get f64 not i64). |
| 258 static Type largestTypeInSize(uint32_t Size, uint32_t MaxSize = NoSizeLimit); | 262 static Type largestTypeInSize(uint32_t Size, uint32_t MaxSize = NoSizeLimit); |
| 259 /// Returns the smallest type which is equal to or larger than Size bytes. If | 263 /// Returns the smallest type which is equal to or larger than Size bytes. If |
| 260 /// one doesn't exist then the largest type smaller than Size bytes is | 264 /// one doesn't exist then the largest type smaller than Size bytes is |
| 261 /// returned. The type is suitable for memory copies as described at | 265 /// returned. The type is suitable for memory copies as described at |
| 262 /// largestTypeInSize. | 266 /// largestTypeInSize. |
| 263 static Type firstTypeThatFitsSize(uint32_t Size, | 267 static Type firstTypeThatFitsSize(uint32_t Size, |
| 264 uint32_t MaxSize = NoSizeLimit); | 268 uint32_t MaxSize = NoSizeLimit); |
| 265 | 269 |
| 270 Variable *copyToReg8(Operand *Src, int32_t RegNum = Variable::NoRegister); |
| 266 Variable *copyToReg(Operand *Src, int32_t RegNum = Variable::NoRegister); | 271 Variable *copyToReg(Operand *Src, int32_t RegNum = Variable::NoRegister); |
| 267 | 272 |
| 268 /// \name Returns a vector in a register with the given constant entries. | 273 /// \name Returns a vector in a register with the given constant entries. |
| 269 /// @{ | 274 /// @{ |
| 270 Variable *makeVectorOfZeros(Type Ty, int32_t RegNum = Variable::NoRegister); | 275 Variable *makeVectorOfZeros(Type Ty, int32_t RegNum = Variable::NoRegister); |
| 271 Variable *makeVectorOfOnes(Type Ty, int32_t RegNum = Variable::NoRegister); | 276 Variable *makeVectorOfOnes(Type Ty, int32_t RegNum = Variable::NoRegister); |
| 272 Variable *makeVectorOfMinusOnes(Type Ty, | 277 Variable *makeVectorOfMinusOnes(Type Ty, |
| 273 int32_t RegNum = Variable::NoRegister); | 278 int32_t RegNum = Variable::NoRegister); |
| 274 Variable *makeVectorOfHighOrderBits(Type Ty, | 279 Variable *makeVectorOfHighOrderBits(Type Ty, |
| 275 int32_t RegNum = Variable::NoRegister); | 280 int32_t RegNum = Variable::NoRegister); |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 | 672 |
| 668 bool optimizeScalarMul(Variable *Dest, Operand *Src0, int32_t Src1); | 673 bool optimizeScalarMul(Variable *Dest, Operand *Src0, int32_t Src1); |
| 669 void findRMW(); | 674 void findRMW(); |
| 670 | 675 |
| 671 typename Traits::InstructionSet InstructionSet = | 676 typename Traits::InstructionSet InstructionSet = |
| 672 Traits::InstructionSet::Begin; | 677 Traits::InstructionSet::Begin; |
| 673 bool IsEbpBasedFrame = false; | 678 bool IsEbpBasedFrame = false; |
| 674 bool NeedsStackAlignment = false; | 679 bool NeedsStackAlignment = false; |
| 675 size_t SpillAreaSizeBytes = 0; | 680 size_t SpillAreaSizeBytes = 0; |
| 676 size_t FixedAllocaSizeBytes = 0; | 681 size_t FixedAllocaSizeBytes = 0; |
| 677 static std::array<llvm::SmallBitVector, IceType_NUM> TypeToRegisterSet; | 682 static std::array<llvm::SmallBitVector, RCX86_NUM> TypeToRegisterSet; |
| 678 static std::array<llvm::SmallBitVector, Traits::RegisterSet::Reg_NUM> | 683 static std::array<llvm::SmallBitVector, Traits::RegisterSet::Reg_NUM> |
| 679 RegisterAliases; | 684 RegisterAliases; |
| 680 static llvm::SmallBitVector ScratchRegs; | 685 static llvm::SmallBitVector ScratchRegs; |
| 681 llvm::SmallBitVector RegsUsed; | 686 llvm::SmallBitVector RegsUsed; |
| 682 std::array<VarList, IceType_NUM> PhysicalRegisters; | 687 std::array<VarList, IceType_NUM> PhysicalRegisters; |
| 683 | 688 |
| 684 /// Randomize a given immediate operand | 689 /// Randomize a given immediate operand |
| 685 Operand *randomizeOrPoolImmediate(Constant *Immediate, | 690 Operand *randomizeOrPoolImmediate(Constant *Immediate, |
| 686 int32_t RegNum = Variable::NoRegister); | 691 int32_t RegNum = Variable::NoRegister); |
| 687 typename Traits::X86OperandMem * | 692 typename Traits::X86OperandMem * |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 lowerIcmp64(const InstIcmp *Icmp, const InstBr *Br); | 745 lowerIcmp64(const InstIcmp *Icmp, const InstBr *Br); |
| 741 | 746 |
| 742 BoolFolding FoldingInfo; | 747 BoolFolding FoldingInfo; |
| 743 }; | 748 }; |
| 744 } // end of namespace X86Internal | 749 } // end of namespace X86Internal |
| 745 } // end of namespace Ice | 750 } // end of namespace Ice |
| 746 | 751 |
| 747 #include "IceTargetLoweringX86BaseImpl.h" | 752 #include "IceTargetLoweringX86BaseImpl.h" |
| 748 | 753 |
| 749 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H | 754 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H |
| OLD | NEW |