| OLD | NEW |
| 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// | 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "IceDefs.h" | 22 #include "IceDefs.h" |
| 23 #include "IceELFObjectWriter.h" | 23 #include "IceELFObjectWriter.h" |
| 24 #include "IceGlobalInits.h" | 24 #include "IceGlobalInits.h" |
| 25 #include "IceInstVarIter.h" | 25 #include "IceInstVarIter.h" |
| 26 #include "IceLiveness.h" | 26 #include "IceLiveness.h" |
| 27 #include "IceOperand.h" | 27 #include "IceOperand.h" |
| 28 #include "IcePhiLoweringImpl.h" | 28 #include "IcePhiLoweringImpl.h" |
| 29 #include "IceUtils.h" | 29 #include "IceUtils.h" |
| 30 #include "llvm/Support/MathExtras.h" | 30 #include "llvm/Support/MathExtras.h" |
| 31 | 31 |
| 32 #include <cmath> // signbit() | |
| 33 #include <stack> | 32 #include <stack> |
| 34 | 33 |
| 35 namespace Ice { | 34 namespace Ice { |
| 36 namespace X86Internal { | 35 namespace X86Internal { |
| 37 | 36 |
| 38 /// A helper class to ease the settings of RandomizationPoolingPause to disable | 37 /// A helper class to ease the settings of RandomizationPoolingPause to disable |
| 39 /// constant blinding or pooling for some translation phases. | 38 /// constant blinding or pooling for some translation phases. |
| 40 class BoolFlagSaver { | 39 class BoolFlagSaver { |
| 41 BoolFlagSaver() = delete; | 40 BoolFlagSaver() = delete; |
| 42 BoolFlagSaver(const BoolFlagSaver &) = delete; | 41 BoolFlagSaver(const BoolFlagSaver &) = delete; |
| (...skipping 5456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5499 Type Ty = Src->getType(); | 5498 Type Ty = Src->getType(); |
| 5500 Variable *Reg = makeReg(Ty, RegNum); | 5499 Variable *Reg = makeReg(Ty, RegNum); |
| 5501 if (isVectorType(Ty)) { | 5500 if (isVectorType(Ty)) { |
| 5502 _movp(Reg, Src); | 5501 _movp(Reg, Src); |
| 5503 } else { | 5502 } else { |
| 5504 _mov(Reg, Src); | 5503 _mov(Reg, Src); |
| 5505 } | 5504 } |
| 5506 return Reg; | 5505 return Reg; |
| 5507 } | 5506 } |
| 5508 | 5507 |
| 5509 namespace { | |
| 5510 | |
| 5511 template <typename T> bool isPositiveZero(T Val) { | |
| 5512 static_assert(std::is_floating_point<T>::value, | |
| 5513 "Input type must be floating point"); | |
| 5514 return Val == 0 && !std::signbit(Val); | |
| 5515 } | |
| 5516 | |
| 5517 } // end of anonymous namespace | |
| 5518 | |
| 5519 template <class Machine> | 5508 template <class Machine> |
| 5520 Operand *TargetX86Base<Machine>::legalize(Operand *From, LegalMask Allowed, | 5509 Operand *TargetX86Base<Machine>::legalize(Operand *From, LegalMask Allowed, |
| 5521 int32_t RegNum) { | 5510 int32_t RegNum) { |
| 5522 Type Ty = From->getType(); | 5511 Type Ty = From->getType(); |
| 5523 // Assert that a physical register is allowed. To date, all calls to | 5512 // Assert that a physical register is allowed. To date, all calls to |
| 5524 // legalize() allow a physical register. If a physical register needs to be | 5513 // legalize() allow a physical register. If a physical register needs to be |
| 5525 // explicitly disallowed, then new code will need to be written to force a | 5514 // explicitly disallowed, then new code will need to be written to force a |
| 5526 // spill. | 5515 // spill. |
| 5527 assert(Allowed & Legal_Reg); | 5516 assert(Allowed & Legal_Reg); |
| 5528 // If we're asking for a specific physical register, make sure we're not | 5517 // If we're asking for a specific physical register, make sure we're not |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5602 Operand *NewConst = randomizeOrPoolImmediate(C, RegNum); | 5591 Operand *NewConst = randomizeOrPoolImmediate(C, RegNum); |
| 5603 if (NewConst != Const) { | 5592 if (NewConst != Const) { |
| 5604 return NewConst; | 5593 return NewConst; |
| 5605 } | 5594 } |
| 5606 } | 5595 } |
| 5607 | 5596 |
| 5608 // Convert a scalar floating point constant into an explicit memory | 5597 // Convert a scalar floating point constant into an explicit memory |
| 5609 // operand. | 5598 // operand. |
| 5610 if (isScalarFloatingType(Ty)) { | 5599 if (isScalarFloatingType(Ty)) { |
| 5611 if (auto *ConstFloat = llvm::dyn_cast<ConstantFloat>(Const)) { | 5600 if (auto *ConstFloat = llvm::dyn_cast<ConstantFloat>(Const)) { |
| 5612 if (isPositiveZero(ConstFloat->getValue())) | 5601 if (Utils::isPositiveZero(ConstFloat->getValue())) |
| 5613 return makeZeroedRegister(Ty, RegNum); | 5602 return makeZeroedRegister(Ty, RegNum); |
| 5614 } else if (auto *ConstDouble = llvm::dyn_cast<ConstantDouble>(Const)) { | 5603 } else if (auto *ConstDouble = llvm::dyn_cast<ConstantDouble>(Const)) { |
| 5615 if (isPositiveZero(ConstDouble->getValue())) | 5604 if (Utils::isPositiveZero(ConstDouble->getValue())) |
| 5616 return makeZeroedRegister(Ty, RegNum); | 5605 return makeZeroedRegister(Ty, RegNum); |
| 5617 } | 5606 } |
| 5618 Variable *Base = nullptr; | 5607 Variable *Base = nullptr; |
| 5619 std::string Buffer; | 5608 std::string Buffer; |
| 5620 llvm::raw_string_ostream StrBuf(Buffer); | 5609 llvm::raw_string_ostream StrBuf(Buffer); |
| 5621 llvm::cast<Constant>(From)->emitPoolLabel(StrBuf, Ctx); | 5610 llvm::cast<Constant>(From)->emitPoolLabel(StrBuf, Ctx); |
| 5622 llvm::cast<Constant>(From)->setShouldBePooled(true); | 5611 llvm::cast<Constant>(From)->setShouldBePooled(true); |
| 5623 Constant *Offset = Ctx->getConstantSym(0, StrBuf.str(), true); | 5612 Constant *Offset = Ctx->getConstantSym(0, StrBuf.str(), true); |
| 5624 From = Traits::X86OperandMem::create(Func, Ty, Base, Offset); | 5613 From = Traits::X86OperandMem::create(Func, Ty, Base, Offset); |
| 5625 } | 5614 } |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6030 } | 6019 } |
| 6031 // the offset is not eligible for blinding or pooling, return the original | 6020 // the offset is not eligible for blinding or pooling, return the original |
| 6032 // mem operand | 6021 // mem operand |
| 6033 return MemOperand; | 6022 return MemOperand; |
| 6034 } | 6023 } |
| 6035 | 6024 |
| 6036 } // end of namespace X86Internal | 6025 } // end of namespace X86Internal |
| 6037 } // end of namespace Ice | 6026 } // end of namespace Ice |
| 6038 | 6027 |
| 6039 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H | 6028 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H |
| OLD | NEW |