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 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); | |
Jim Stichnoth
2015/01/12 21:39:32
This assert will probably eventually be incorrect,
jvoung (off chromium)
2015/01/12 22:41:28
Added a comment.
| |
37 C->emitPoolLabel(Str); | |
38 } | |
39 return Str.str(); | |
40 } | |
41 | |
42 void AssemblerFixup::emit(GlobalContext *Ctx) const { | |
43 Ostream &Str = Ctx->getStrEmit(); | |
44 Str << symbol(Ctx); | |
45 RelocOffsetT Offset = offset(); | |
46 if (Offset) | |
47 Str << " + " << Offset; | |
48 } | |
49 | |
50 } // end of namespace Ice | |
OLD | NEW |