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 5078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5089 return NewConst; | 5089 return NewConst; |
5090 } | 5090 } |
5091 } | 5091 } |
5092 | 5092 |
5093 // Convert a scalar floating point constant into an explicit memory | 5093 // Convert a scalar floating point constant into an explicit memory |
5094 // operand. | 5094 // operand. |
5095 if (isScalarFloatingType(Ty)) { | 5095 if (isScalarFloatingType(Ty)) { |
5096 Variable *Base = nullptr; | 5096 Variable *Base = nullptr; |
5097 std::string Buffer; | 5097 std::string Buffer; |
5098 llvm::raw_string_ostream StrBuf(Buffer); | 5098 llvm::raw_string_ostream StrBuf(Buffer); |
5099 llvm::cast<Constant>(From)->emitPoolLabel(StrBuf); | 5099 llvm::cast<Constant>(From)->emitPoolLabel(StrBuf, Ctx); |
5100 llvm::cast<Constant>(From)->setShouldBePooled(true); | 5100 llvm::cast<Constant>(From)->setShouldBePooled(true); |
5101 Constant *Offset = Ctx->getConstantSym(0, StrBuf.str(), true); | 5101 Constant *Offset = Ctx->getConstantSym(0, StrBuf.str(), true); |
5102 From = Traits::X86OperandMem::create(Func, Ty, Base, Offset); | 5102 From = Traits::X86OperandMem::create(Func, Ty, Base, Offset); |
5103 } | 5103 } |
5104 bool NeedsReg = false; | 5104 bool NeedsReg = false; |
5105 if (!(Allowed & Legal_Imm) && !isScalarFloatingType(Ty)) | 5105 if (!(Allowed & Legal_Imm) && !isScalarFloatingType(Ty)) |
5106 // Immediate specifically not allowed | 5106 // Immediate specifically not allowed |
5107 NeedsReg = true; | 5107 NeedsReg = true; |
5108 if (!(Allowed & Legal_Mem) && isScalarFloatingType(Ty)) | 5108 if (!(Allowed & Legal_Mem) && isScalarFloatingType(Ty)) |
5109 // On x86, FP constants are lowered to mem operands. | 5109 // On x86, FP constants are lowered to mem operands. |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5286 Ostream &Str = Ctx->getStrEmit(); | 5286 Ostream &Str = Ctx->getStrEmit(); |
5287 Str << getConstantPrefix() << C->getValue(); | 5287 Str << getConstantPrefix() << C->getValue(); |
5288 } | 5288 } |
5289 } | 5289 } |
5290 | 5290 |
5291 template <class Machine> | 5291 template <class Machine> |
5292 void TargetX86Base<Machine>::emit(const ConstantFloat *C) const { | 5292 void TargetX86Base<Machine>::emit(const ConstantFloat *C) const { |
5293 if (!BuildDefs::dump()) | 5293 if (!BuildDefs::dump()) |
5294 return; | 5294 return; |
5295 Ostream &Str = Ctx->getStrEmit(); | 5295 Ostream &Str = Ctx->getStrEmit(); |
5296 C->emitPoolLabel(Str); | 5296 C->emitPoolLabel(Str, Ctx); |
5297 } | 5297 } |
5298 | 5298 |
5299 template <class Machine> | 5299 template <class Machine> |
5300 void TargetX86Base<Machine>::emit(const ConstantDouble *C) const { | 5300 void TargetX86Base<Machine>::emit(const ConstantDouble *C) const { |
5301 if (!BuildDefs::dump()) | 5301 if (!BuildDefs::dump()) |
5302 return; | 5302 return; |
5303 Ostream &Str = Ctx->getStrEmit(); | 5303 Ostream &Str = Ctx->getStrEmit(); |
5304 C->emitPoolLabel(Str); | 5304 C->emitPoolLabel(Str, Ctx); |
5305 } | 5305 } |
5306 | 5306 |
5307 template <class Machine> | 5307 template <class Machine> |
5308 void TargetX86Base<Machine>::emit(const ConstantUndef *) const { | 5308 void TargetX86Base<Machine>::emit(const ConstantUndef *) const { |
5309 llvm::report_fatal_error("undef value encountered by emitter."); | 5309 llvm::report_fatal_error("undef value encountered by emitter."); |
5310 } | 5310 } |
5311 | 5311 |
5312 /// Randomize or pool an Immediate. | 5312 /// Randomize or pool an Immediate. |
5313 template <class Machine> | 5313 template <class Machine> |
5314 Operand *TargetX86Base<Machine>::randomizeOrPoolImmediate(Constant *Immediate, | 5314 Operand *TargetX86Base<Machine>::randomizeOrPoolImmediate(Constant *Immediate, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5360 // => Reg | 5360 // => Reg |
5361 assert(Ctx->getFlags().getRandomizeAndPoolImmediatesOption() == RPI_Pool); | 5361 assert(Ctx->getFlags().getRandomizeAndPoolImmediatesOption() == RPI_Pool); |
5362 Immediate->setShouldBePooled(true); | 5362 Immediate->setShouldBePooled(true); |
5363 // if we have already assigned a phy register, we must come from | 5363 // if we have already assigned a phy register, we must come from |
5364 // advancedPhiLowering()=>lowerAssign(). In this case we should reuse the | 5364 // advancedPhiLowering()=>lowerAssign(). In this case we should reuse the |
5365 // assigned register as this assignment is that start of its use-def | 5365 // assigned register as this assignment is that start of its use-def |
5366 // chain. So we add RegNum argument here. | 5366 // chain. So we add RegNum argument here. |
5367 Variable *Reg = makeReg(Immediate->getType(), RegNum); | 5367 Variable *Reg = makeReg(Immediate->getType(), RegNum); |
5368 IceString Label; | 5368 IceString Label; |
5369 llvm::raw_string_ostream Label_stream(Label); | 5369 llvm::raw_string_ostream Label_stream(Label); |
5370 Immediate->emitPoolLabel(Label_stream); | 5370 Immediate->emitPoolLabel(Label_stream, Ctx); |
5371 const RelocOffsetT Offset = 0; | 5371 const RelocOffsetT Offset = 0; |
5372 const bool SuppressMangling = true; | 5372 const bool SuppressMangling = true; |
5373 Constant *Symbol = | 5373 Constant *Symbol = |
5374 Ctx->getConstantSym(Offset, Label_stream.str(), SuppressMangling); | 5374 Ctx->getConstantSym(Offset, Label_stream.str(), SuppressMangling); |
5375 typename Traits::X86OperandMem *MemOperand = | 5375 typename Traits::X86OperandMem *MemOperand = |
5376 Traits::X86OperandMem::create(Func, Immediate->getType(), nullptr, | 5376 Traits::X86OperandMem::create(Func, Immediate->getType(), nullptr, |
5377 Symbol); | 5377 Symbol); |
5378 _mov(Reg, MemOperand); | 5378 _mov(Reg, MemOperand); |
5379 return Reg; | 5379 return Reg; |
5380 } | 5380 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5456 // Memory operand should never exist as source operands in phi lowering | 5456 // Memory operand should never exist as source operands in phi lowering |
5457 // assignments, so there is no need to reuse any registers here. For | 5457 // assignments, so there is no need to reuse any registers here. For |
5458 // phi lowering, we should not ask for new physical registers in | 5458 // phi lowering, we should not ask for new physical registers in |
5459 // general. However, if we do meet Memory Operand during phi lowering, | 5459 // general. However, if we do meet Memory Operand during phi lowering, |
5460 // we should not blind or pool the immediates for now. | 5460 // we should not blind or pool the immediates for now. |
5461 if (RegNum != Variable::NoRegister) | 5461 if (RegNum != Variable::NoRegister) |
5462 return MemOperand; | 5462 return MemOperand; |
5463 Variable *RegTemp = makeReg(IceType_i32); | 5463 Variable *RegTemp = makeReg(IceType_i32); |
5464 IceString Label; | 5464 IceString Label; |
5465 llvm::raw_string_ostream Label_stream(Label); | 5465 llvm::raw_string_ostream Label_stream(Label); |
5466 MemOperand->getOffset()->emitPoolLabel(Label_stream); | 5466 MemOperand->getOffset()->emitPoolLabel(Label_stream, Ctx); |
5467 MemOperand->getOffset()->setShouldBePooled(true); | 5467 MemOperand->getOffset()->setShouldBePooled(true); |
5468 const RelocOffsetT SymOffset = 0; | 5468 const RelocOffsetT SymOffset = 0; |
5469 bool SuppressMangling = true; | 5469 bool SuppressMangling = true; |
5470 Constant *Symbol = Ctx->getConstantSym(SymOffset, Label_stream.str(), | 5470 Constant *Symbol = Ctx->getConstantSym(SymOffset, Label_stream.str(), |
5471 SuppressMangling); | 5471 SuppressMangling); |
5472 typename Traits::X86OperandMem *SymbolOperand = | 5472 typename Traits::X86OperandMem *SymbolOperand = |
5473 Traits::X86OperandMem::create( | 5473 Traits::X86OperandMem::create( |
5474 Func, MemOperand->getOffset()->getType(), nullptr, Symbol); | 5474 Func, MemOperand->getOffset()->getType(), nullptr, Symbol); |
5475 _mov(RegTemp, SymbolOperand); | 5475 _mov(RegTemp, SymbolOperand); |
5476 // If we have a base variable here, we should add the lea instruction | 5476 // If we have a base variable here, we should add the lea instruction |
(...skipping 18 matching lines...) Expand all Loading... |
5495 } | 5495 } |
5496 // the offset is not eligible for blinding or pooling, return the original | 5496 // the offset is not eligible for blinding or pooling, return the original |
5497 // mem operand | 5497 // mem operand |
5498 return MemOperand; | 5498 return MemOperand; |
5499 } | 5499 } |
5500 | 5500 |
5501 } // end of namespace X86Internal | 5501 } // end of namespace X86Internal |
5502 } // end of namespace Ice | 5502 } // end of namespace Ice |
5503 | 5503 |
5504 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H | 5504 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H |
OLD | NEW |