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

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: format 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
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 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
OLDNEW
« src/IceFixups.h ('K') | « src/IceFixups.h ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698