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. |