Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: src/IceFixups.cpp

Issue 828873002: Subzero: Start writing out some relocation sections (text) (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: review fixes Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceFixups.h ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « src/IceFixups.h ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698