| 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 |
| 11 /// This file implements the AssemblerFixup class, a very basic | 11 /// This file implements the AssemblerFixup class, a very basic |
| 12 /// target-independent representation of a fixup or relocation. | 12 /// target-independent representation of a fixup or relocation. |
| 13 /// | 13 /// |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #include "IceFixups.h" | 16 #include "IceFixups.h" |
| 17 | 17 |
| 18 #include "IceOperand.h" | 18 #include "IceOperand.h" |
| 19 | 19 |
| 20 namespace Ice { | 20 namespace Ice { |
| 21 | 21 |
| 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 0; | 26 return 0; |
| 27 if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(value_)) | 27 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(value_)) |
| 28 return CR->getOffset(); | 28 return CR->getOffset(); |
| 29 return 0; | 29 return 0; |
| 30 } | 30 } |
| 31 | 31 |
| 32 IceString AssemblerFixup::symbol(const GlobalContext *Ctx) const { | 32 IceString AssemblerFixup::symbol(const GlobalContext *Ctx) const { |
| 33 std::string Buffer; | 33 std::string Buffer; |
| 34 llvm::raw_string_ostream Str(Buffer); | 34 llvm::raw_string_ostream Str(Buffer); |
| 35 const Constant *C = value_; | 35 const Constant *C = value_; |
| 36 assert(!isNullSymbol()); | 36 assert(!isNullSymbol()); |
| 37 if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(C)) { | 37 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(C)) { |
| 38 if (CR->getSuppressMangling()) | 38 if (CR->getSuppressMangling()) |
| 39 Str << CR->getName(); | 39 Str << CR->getName(); |
| 40 else | 40 else |
| 41 Str << Ctx->mangleName(CR->getName()); | 41 Str << Ctx->mangleName(CR->getName()); |
| 42 } else { | 42 } else { |
| 43 // NOTE: currently only float/doubles are put into constant pools. In the | 43 // NOTE: currently only float/doubles are put into constant pools. In the |
| 44 // future we may put integers as well. | 44 // future we may put integers as well. |
| 45 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); | 45 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); |
| 46 C->emitPoolLabel(Str, Ctx); | 46 C->emitPoolLabel(Str, Ctx); |
| 47 } | 47 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 70 Str << "\n"; | 70 Str << "\n"; |
| 71 return FixupSize; | 71 return FixupSize; |
| 72 } | 72 } |
| 73 | 73 |
| 74 size_t AssemblerTextFixup::emit(GlobalContext *Ctx, const Assembler &) const { | 74 size_t AssemblerTextFixup::emit(GlobalContext *Ctx, const Assembler &) const { |
| 75 Ctx->getStrEmit() << Message << "\n"; | 75 Ctx->getStrEmit() << Message << "\n"; |
| 76 return NumBytes; | 76 return NumBytes; |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // end of namespace Ice | 79 } // end of namespace Ice |
| OLD | NEW |