OLD | NEW |
(Empty) | |
| 1 //===- subzero/src/IceFixups.cpp - Implementation of Assembler Fixups -----===// |
| 2 // |
| 3 // The Subzero Code Generator |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 // |
| 10 // This file implements the AssemblerFixup class, a very basic |
| 11 // target-independent representation of a fixup or relocation. |
| 12 // |
| 13 //===----------------------------------------------------------------------===// |
| 14 |
| 15 #include "IceFixups.h" |
| 16 #include "IceOperand.h" |
| 17 |
| 18 namespace Ice { |
| 19 |
| 20 RelocOffsetT AssemblerFixup::offset() const { |
| 21 if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(value_)) |
| 22 return CR->getOffset(); |
| 23 return 0; |
| 24 } |
| 25 |
| 26 IceString AssemblerFixup::symbol(const GlobalContext *Ctx) const { |
| 27 std::string Buffer; |
| 28 llvm::raw_string_ostream Str(Buffer); |
| 29 const Constant *C = value_; |
| 30 if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(C)) { |
| 31 if (CR->getSuppressMangling()) |
| 32 Str << CR->getName(); |
| 33 else |
| 34 Str << Ctx->mangleName(CR->getName()); |
| 35 } else { |
| 36 // NOTE: currently only float/doubles are put into constant pools. |
| 37 // In the future we may put integers as well. |
| 38 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); |
| 39 C->emitPoolLabel(Str); |
| 40 } |
| 41 return Str.str(); |
| 42 } |
| 43 |
| 44 void AssemblerFixup::emit(GlobalContext *Ctx) const { |
| 45 Ostream &Str = Ctx->getStrEmit(); |
| 46 Str << symbol(Ctx); |
| 47 RelocOffsetT Offset = offset(); |
| 48 if (Offset) |
| 49 Str << " + " << Offset; |
| 50 } |
| 51 |
| 52 } // end of namespace Ice |
OLD | NEW |