| OLD | NEW |
| 1 //===- subzero/src/IceFixups.cpp - Implementation of Assembler Fixups -----===// | 1 //===- subzero/src/IceFixups.cpp - Implementation of Assembler Fixups -----===// |
| 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 const Constant *AssemblerFixup::NullSymbol = nullptr; | 22 const Constant *AssemblerFixup::NullSymbol = nullptr; |
| 23 | 23 |
| 24 RelocOffsetT AssemblerFixup::offset() const { | 24 RelocOffsetT AssemblerFixup::offset() const { |
| 25 if (isNullSymbol()) | 25 if (isNullSymbol()) |
| 26 return addend_; | 26 return addend_; |
| 27 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(value_)) | 27 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(value_)) |
| 28 return CR->getOffset() + addend_; | 28 return CR->getOffset() + addend_; |
| 29 return addend_; | 29 return addend_; |
| 30 } | 30 } |
| 31 | 31 |
| 32 IceString AssemblerFixup::symbol(const GlobalContext *Ctx, | 32 IceString AssemblerFixup::symbol(const Assembler *Asm) const { |
| 33 const Assembler *Asm) const { | |
| 34 std::string Buffer; | 33 std::string Buffer; |
| 35 llvm::raw_string_ostream Str(Buffer); | 34 llvm::raw_string_ostream Str(Buffer); |
| 36 const Constant *C = value_; | 35 const Constant *C = value_; |
| 37 assert(!isNullSymbol()); | 36 assert(!isNullSymbol()); |
| 38 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(C)) { | 37 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(C)) { |
| 39 if (CR->getSuppressMangling()) | 38 Str << CR->getName(); |
| 40 Str << CR->getName(); | 39 if (Asm && !Asm->fixupIsPCRel(kind()) && |
| 41 else | 40 GlobalContext::getFlags().getUseNonsfi() && |
| 42 Str << Ctx->mangleName(CR->getName()); | |
| 43 if (Asm && !Asm->fixupIsPCRel(kind()) && Ctx->getFlags().getUseNonsfi() && | |
| 44 CR->getName() != GlobalOffsetTable) { | 41 CR->getName() != GlobalOffsetTable) { |
| 45 // TODO(jpp): remove the special GOT test. | 42 // TODO(jpp): remove the special GOT test. |
| 46 Str << "@GOTOFF"; | 43 Str << "@GOTOFF"; |
| 47 } | 44 } |
| 48 } else { | 45 } else { |
| 49 // NOTE: currently only float/doubles are put into constant pools. In the | 46 // NOTE: currently only float/doubles are put into constant pools. In the |
| 50 // future we may put integers as well. | 47 // future we may put integers as well. |
| 51 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); | 48 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); |
| 52 C->emitPoolLabel(Str, Ctx); | 49 C->emitPoolLabel(Str); |
| 53 } | 50 } |
| 54 return Str.str(); | 51 return Str.str(); |
| 55 } | 52 } |
| 56 | 53 |
| 57 size_t AssemblerFixup::emit(GlobalContext *Ctx, const Assembler &Asm) const { | 54 size_t AssemblerFixup::emit(GlobalContext *Ctx, const Assembler &Asm) const { |
| 58 static constexpr const size_t FixupSize = 4; | 55 static constexpr const size_t FixupSize = 4; |
| 59 if (!BuildDefs::dump()) | 56 if (!BuildDefs::dump()) |
| 60 return FixupSize; | 57 return FixupSize; |
| 61 Ostream &Str = Ctx->getStrEmit(); | 58 Ostream &Str = Ctx->getStrEmit(); |
| 62 Str << "\t.long "; | 59 Str << "\t.long "; |
| 63 IceString Symbol; | 60 IceString Symbol; |
| 64 if (isNullSymbol()) { | 61 if (isNullSymbol()) { |
| 65 Str << "__Sz_AbsoluteZero"; | 62 Str << "__Sz_AbsoluteZero"; |
| 66 } else { | 63 } else { |
| 67 Symbol = symbol(Ctx, &Asm); | 64 Symbol = symbol(&Asm); |
| 68 Str << Symbol; | 65 Str << Symbol; |
| 69 } | 66 } |
| 70 | 67 |
| 71 assert(Asm.load<RelocOffsetT>(position()) == 0); | 68 assert(Asm.load<RelocOffsetT>(position()) == 0); |
| 72 | 69 |
| 73 RelocOffsetT Offset = offset(); | 70 RelocOffsetT Offset = offset(); |
| 74 if (Offset != 0) { | 71 if (Offset != 0) { |
| 75 if (Offset > 0) { | 72 if (Offset > 0) { |
| 76 Str << " + " << Offset; | 73 Str << " + " << Offset; |
| 77 } else { | 74 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 92 void AssemblerFixup::emitOffset(Assembler *Asm) const { | 89 void AssemblerFixup::emitOffset(Assembler *Asm) const { |
| 93 Asm->store(position(), offset()); | 90 Asm->store(position(), offset()); |
| 94 } | 91 } |
| 95 | 92 |
| 96 size_t AssemblerTextFixup::emit(GlobalContext *Ctx, const Assembler &) const { | 93 size_t AssemblerTextFixup::emit(GlobalContext *Ctx, const Assembler &) const { |
| 97 Ctx->getStrEmit() << Message << "\n"; | 94 Ctx->getStrEmit() << Message << "\n"; |
| 98 return NumBytes; | 95 return NumBytes; |
| 99 } | 96 } |
| 100 | 97 |
| 101 } // end of namespace Ice | 98 } // end of namespace Ice |
| OLD | NEW |