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

Unified Diff: src/IceCfg.cpp

Issue 678533005: Subzero: Add basic ELFObjectWriter (text section, symtab, strtab, headers) (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: minor cleanup Created 6 years 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 | « Makefile.standalone ('k') | src/IceClFlags.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceCfg.cpp
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index 950a3f8ee6e9572abf6fbe4f64399264ff9d4be2..e40bd1609c0088d28d2ae4be7034c3da3b579218 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -405,8 +405,9 @@ void Cfg::emitTextHeader(const IceString &MangledName) {
Str << "\t.globl\t" << MangledName << "\n";
Str << "\t.type\t" << MangledName << ",@function\n";
}
- Str << "\t.p2align " << getTarget()->getBundleAlignLog2Bytes() << ",0x";
- for (AsmCodeByte I : getTarget()->getNonExecBundlePadding())
+ Assembler *Asm = getAssembler<Assembler>();
+ Str << "\t.p2align " << Asm->getBundleAlignLog2Bytes() << ",0x";
+ for (uint8_t I : Asm->getNonExecBundlePadding())
Str.write_hex(I);
Str << "\n";
Str << MangledName << ":\n";
@@ -444,10 +445,20 @@ void Cfg::emitIAS() {
TimerMarker T(TimerStack::TT_emit, this);
assert(!Ctx->getFlags().DecorateAsm);
IceString MangledName = getContext()->mangleName(getFunctionName());
- emitTextHeader(MangledName);
+ if (!Ctx->getFlags().UseELFWriter)
+ emitTextHeader(MangledName);
for (CfgNode *Node : Nodes)
Node->emitIAS(this);
- getAssembler<Assembler>()->emitIASBytes(Ctx);
+ // Now write the function to the file and track.
+ if (Ctx->getFlags().UseELFWriter) {
+ getAssembler<Assembler>()->alignFunction();
+ // TODO(jvoung): Transfer remaining fixups too. They may need their
+ // offsets adjusted.
+ Ctx->getObjectWriter()->writeFunctionCode(
+ MangledName, getInternal(), getAssembler<Assembler>()->getBufferView());
+ } else {
+ getAssembler<Assembler>()->emitIASBytes(Ctx);
+ }
}
// Dumps the IR with an optional introductory message.
« no previous file with comments | « Makefile.standalone ('k') | src/IceClFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698