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

Unified Diff: src/assembler.cpp

Issue 837553009: Make fixups reference any constant (allow const float/double pool literals). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: go back to one arenaallocator type alias 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/assembler.h ('k') | src/assembler_ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/assembler.cpp
diff --git a/src/assembler.cpp b/src/assembler.cpp
index a9516e869b05a0213e96557245d9ef270f513493..d4f566ba3ee093e5f4f7177cc7cda2765c4765a3 100644
--- a/src/assembler.cpp
+++ b/src/assembler.cpp
@@ -124,14 +124,7 @@ void Assembler::emitIASBytes(GlobalContext *Ctx) const {
Str << "\n";
}
Str << "\t.long ";
- const ConstantRelocatable *Reloc = NextFixup->value();
- if (Reloc->getSuppressMangling())
- Str << Reloc->getName();
- else
- Str << Ctx->mangleName(Reloc->getName());
- if (Reloc->getOffset()) {
- Str << " + " << Reloc->getOffset();
- }
+ NextFixup->emit(Ctx);
bool IsPCRel = NextFixup->kind() == FK_PcRel_4;
if (IsPCRel)
Str << " - (. + " << FixupSize << ")";
@@ -147,4 +140,34 @@ void Assembler::emitIASBytes(GlobalContext *Ctx) const {
}
}
+RelocOffsetT AssemblerFixup::offset() const {
+ if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(value_))
+ return CR->getOffset();
+ return 0;
+}
+
+IceString AssemblerFixup::symbol(GlobalContext *Ctx) const {
+ std::string Buffer;
+ llvm::raw_string_ostream Str(Buffer);
+ const Constant *C = value_;
+ if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(C)) {
+ if (CR->getSuppressMangling())
+ Str << CR->getName();
+ else
+ Str << Ctx->mangleName(CR->getName());
+ } else {
+ assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C));
+ C->emitPoolLabel(Str);
+ }
+ return Str.str();
+}
+
+void AssemblerFixup::emit(GlobalContext *Ctx) const {
+ Ostream &Str = Ctx->getStrEmit();
+ Str << symbol(Ctx);
+ RelocOffsetT Offset = offset();
+ if (Offset)
+ Str << " + " << Offset;
+}
+
} // end of namespace Ice
« no previous file with comments | « src/assembler.h ('k') | src/assembler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698