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

Side by Side Diff: src/IceFixups.cpp

Issue 1838753002: Subzero: Remove IceString. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 8 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
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 /// \file 10 /// \file
(...skipping 13 matching lines...) Expand all
24 RelocOffsetT AssemblerFixup::offset() const { 24 RelocOffsetT AssemblerFixup::offset() const {
25 if (isNullSymbol()) 25 if (isNullSymbol())
26 return addend_; 26 return addend_;
27 if (!ValueIsSymbol) { 27 if (!ValueIsSymbol) {
28 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(ConstValue)) 28 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(ConstValue))
29 return CR->getOffset() + addend_; 29 return CR->getOffset() + addend_;
30 } 30 }
31 return addend_; 31 return addend_;
32 } 32 }
33 33
34 IceString AssemblerFixup::symbol() const { 34 GlobalString AssemblerFixup::symbol() const {
35 assert(!isNullSymbol()); 35 assert(!isNullSymbol());
36 assert(!ValueIsSymbol); 36 assert(!ValueIsSymbol);
37 const Constant *C = ConstValue; 37 const Constant *C = ConstValue;
38 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(C)) { 38 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(C)) {
39 return CR->getName(); 39 return CR->getName();
40 } 40 }
41 // NOTE: currently only float/doubles are put into constant pools. In the 41 // NOTE: currently only float/doubles are put into constant pools. In the
42 // future we may put integers as well. 42 // future we may put integers as well.
43 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); 43 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C));
44 std::string Buffer; 44 return C->getLabelName();
45 llvm::raw_string_ostream Str(Buffer);
46 C->emitPoolLabel(Str);
47 return Str.str();
48 } 45 }
49 46
50 size_t AssemblerFixup::emit(GlobalContext *Ctx, const Assembler &Asm) const { 47 size_t AssemblerFixup::emit(GlobalContext *Ctx, const Assembler &Asm) const {
51 static constexpr const size_t FixupSize = 4; 48 static constexpr const size_t FixupSize = 4;
52 if (!BuildDefs::dump()) 49 if (!BuildDefs::dump())
53 return FixupSize; 50 return FixupSize;
54 Ostream &Str = Ctx->getStrEmit(); 51 Ostream &Str = Ctx->getStrEmit();
55 Str << "\t.long "; 52 Str << "\t.long ";
56 IceString Symbol; 53 std::string Symbol;
57 if (isNullSymbol()) { 54 if (isNullSymbol()) {
58 Str << "__Sz_AbsoluteZero"; 55 Str << "__Sz_AbsoluteZero";
59 } else { 56 } else {
60 Symbol = symbol(); 57 Symbol = symbol().toString();
61 Str << Symbol; 58 Str << Symbol;
62 assert(!ValueIsSymbol); 59 assert(!ValueIsSymbol);
63 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(ConstValue)) { 60 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(ConstValue)) {
64 if (!Asm.fixupIsPCRel(kind()) && 61 if (!Asm.fixupIsPCRel(kind()) &&
65 GlobalContext::getFlags().getUseNonsfi() && 62 GlobalContext::getFlags().getUseNonsfi() &&
66 CR->getName() != GlobalOffsetTable) { 63 CR->getName().toString() != GlobalOffsetTable) {
67 Str << "@GOTOFF"; 64 Str << "@GOTOFF";
68 } 65 }
69 } 66 }
70 } 67 }
71 68
72 assert(Asm.load<RelocOffsetT>(position()) == 0); 69 assert(Asm.load<RelocOffsetT>(position()) == 0);
73 70
74 RelocOffsetT Offset = offset(); 71 RelocOffsetT Offset = offset();
75 if (Offset != 0) { 72 if (Offset != 0) {
76 if (Offset > 0) { 73 if (Offset > 0) {
(...skipping 16 matching lines...) Expand all
93 void AssemblerFixup::emitOffset(Assembler *Asm) const { 90 void AssemblerFixup::emitOffset(Assembler *Asm) const {
94 Asm->store(position(), offset()); 91 Asm->store(position(), offset());
95 } 92 }
96 93
97 size_t AssemblerTextFixup::emit(GlobalContext *Ctx, const Assembler &) const { 94 size_t AssemblerTextFixup::emit(GlobalContext *Ctx, const Assembler &) const {
98 Ctx->getStrEmit() << Message << "\n"; 95 Ctx->getStrEmit() << Message << "\n";
99 return NumBytes; 96 return NumBytes;
100 } 97 }
101 98
102 } // end of namespace Ice 99 } // 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