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

Unified Diff: src/IceCfg.cpp

Issue 916653004: Subzero: Emit functions and global initializers in a separate thread. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Const change Created 5 years, 10 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/IceCfg.h ('k') | src/IceCfgNode.cpp » ('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 6526da21c65d2ae39d6d5d28990ead98c633e714..bae6c7752942bccf939a7ecaf7edce19355fe0de 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -31,10 +31,10 @@ ArenaAllocator<> *getCurrentCfgAllocator() {
return Cfg::getCurrentCfgAllocator();
}
-Cfg::Cfg(GlobalContext *Ctx)
- : Ctx(Ctx), VMask(Ctx->getVerbose()), FunctionName(""),
- ReturnType(IceType_void), IsInternalLinkage(false), HasError(false),
- FocusedTiming(false), ErrorMessage(""), Entry(nullptr),
+Cfg::Cfg(GlobalContext *Ctx, uint32_t SequenceNumber)
+ : Ctx(Ctx), SequenceNumber(SequenceNumber), VMask(Ctx->getVerbose()),
+ FunctionName(""), ReturnType(IceType_void), IsInternalLinkage(false),
+ HasError(false), FocusedTiming(false), ErrorMessage(""), Entry(nullptr),
NextInstNumber(Inst::NumberInitial), Allocator(new ArenaAllocator<>()),
Live(nullptr),
Target(TargetLowering::createLowering(Ctx->getTargetArch(), this)),
@@ -418,17 +418,20 @@ void Cfg::doBranchOpt() {
// ======================== Dump routines ======================== //
-void Cfg::emitTextHeader(const IceString &MangledName) {
+// emitTextHeader() is not target-specific (apart from what is
+// abstracted by the Assembler), so it is defined here rather than in
+// the target lowering class.
+void Cfg::emitTextHeader(const IceString &MangledName, GlobalContext *Ctx,
+ const Assembler *Asm) {
// Note: Still used by emit IAS.
Ostream &Str = Ctx->getStrEmit();
Str << "\t.text\n";
if (Ctx->getFlags().getFunctionSections())
Str << "\t.section\t.text." << MangledName << ",\"ax\",@progbits\n";
- if (!getInternal() || Ctx->getFlags().getDisableInternal()) {
+ if (!Asm->getInternal() || Ctx->getFlags().getDisableInternal()) {
Str << "\t.globl\t" << MangledName << "\n";
Str << "\t.type\t" << MangledName << ",@function\n";
}
- Assembler *Asm = getAssembler<Assembler>();
Str << "\t.p2align " << Asm->getBundleAlignLog2Bytes() << ",0x";
for (uint8_t I : Asm->getNonExecBundlePadding())
Str.write_hex(I);
@@ -449,7 +452,7 @@ void Cfg::emit() {
OstreamLocker L(Ctx);
Ostream &Str = Ctx->getStrEmit();
IceString MangledName = getContext()->mangleName(getFunctionName());
- emitTextHeader(MangledName);
+ emitTextHeader(MangledName, Ctx, getAssembler<>());
for (CfgNode *Node : Nodes)
Node->emit(this);
Str << "\n";
@@ -458,22 +461,10 @@ void Cfg::emit() {
void Cfg::emitIAS() {
TimerMarker T(TimerStack::TT_emit, this);
assert(!Ctx->getFlags().getDecorateAsm());
- IceString MangledName = getContext()->mangleName(getFunctionName());
// The emitIAS() routines emit into the internal assembler buffer,
- // so there's no need to lock the streams until we're ready to call
- // emitIASBytes().
+ // so there's no need to lock the streams.
for (CfgNode *Node : Nodes)
Node->emitIAS(this);
- // Now write the function to the file and track.
- if (Ctx->getFlags().getUseELFWriter()) {
- getAssembler<Assembler>()->alignFunction();
- Ctx->getObjectWriter()->writeFunctionCode(MangledName, getInternal(),
- getAssembler<Assembler>());
- } else {
- OstreamLocker L(Ctx);
- emitTextHeader(MangledName);
- getAssembler<Assembler>()->emitIASBytes(Ctx);
- }
}
// Dumps the IR with an optional introductory message.
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCfgNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698