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

Side by Side Diff: src/IceFixups.cpp

Issue 1017373002: Subzero: Assemble calls to constant addresses. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: move test back Created 5 years, 9 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/IceInstX8632.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file implements the AssemblerFixup class, a very basic 10 // This file implements the AssemblerFixup class, a very basic
11 // target-independent representation of a fixup or relocation. 11 // target-independent representation of a fixup or relocation.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "IceFixups.h" 15 #include "IceFixups.h"
16 #include "IceOperand.h" 16 #include "IceOperand.h"
17 17
18 namespace Ice { 18 namespace Ice {
19 19
20 const Constant *AssemblerFixup::NullSymbol = nullptr;
21
20 RelocOffsetT AssemblerFixup::offset() const { 22 RelocOffsetT AssemblerFixup::offset() const {
23 if (isNullSymbol())
24 return 0;
21 if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(value_)) 25 if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(value_))
22 return CR->getOffset(); 26 return CR->getOffset();
23 return 0; 27 return 0;
24 } 28 }
25 29
26 IceString AssemblerFixup::symbol(const GlobalContext *Ctx) const { 30 IceString AssemblerFixup::symbol(const GlobalContext *Ctx) const {
27 std::string Buffer; 31 std::string Buffer;
28 llvm::raw_string_ostream Str(Buffer); 32 llvm::raw_string_ostream Str(Buffer);
29 const Constant *C = value_; 33 const Constant *C = value_;
34 assert(!isNullSymbol());
30 if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(C)) { 35 if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(C)) {
31 if (CR->getSuppressMangling()) 36 if (CR->getSuppressMangling())
32 Str << CR->getName(); 37 Str << CR->getName();
33 else 38 else
34 Str << Ctx->mangleName(CR->getName()); 39 Str << Ctx->mangleName(CR->getName());
35 } else { 40 } else {
36 // NOTE: currently only float/doubles are put into constant pools. 41 // NOTE: currently only float/doubles are put into constant pools.
37 // In the future we may put integers as well. 42 // In the future we may put integers as well.
38 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); 43 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C));
39 C->emitPoolLabel(Str); 44 C->emitPoolLabel(Str);
40 } 45 }
41 return Str.str(); 46 return Str.str();
42 } 47 }
43 48
44 void AssemblerFixup::emit(GlobalContext *Ctx) const { 49 void AssemblerFixup::emit(GlobalContext *Ctx) const {
45 Ostream &Str = Ctx->getStrEmit(); 50 Ostream &Str = Ctx->getStrEmit();
51 // TODO(jvoung): Not yet clear how to emit a relocation against
52 // the null symbol.
53 assert(!isNullSymbol());
46 Str << symbol(Ctx); 54 Str << symbol(Ctx);
47 RelocOffsetT Offset = offset(); 55 RelocOffsetT Offset = offset();
48 if (Offset) 56 if (Offset)
49 Str << " + " << Offset; 57 Str << " + " << Offset;
50 } 58 }
51 59
52 } // end of namespace Ice 60 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceFixups.h ('k') | src/IceInstX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698