| Index: src/IceTranslator.cpp
|
| diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp
|
| index c0331a8718df28fe05546d2812995340e76db6ca..d20b25ab4bff82e5a283d3dd336559a8871253fc 100644
|
| --- a/src/IceTranslator.cpp
|
| +++ b/src/IceTranslator.cpp
|
| @@ -12,13 +12,6 @@
|
| //
|
| //===----------------------------------------------------------------------===//
|
|
|
| -#include <iostream>
|
| -#include <memory>
|
| -
|
| -#include "llvm/IR/Constant.h"
|
| -#include "llvm/IR/Constants.h"
|
| -#include "llvm/IR/Module.h"
|
| -
|
| #include "IceCfg.h"
|
| #include "IceClFlags.h"
|
| #include "IceDefs.h"
|
| @@ -28,16 +21,11 @@
|
|
|
| using namespace Ice;
|
|
|
| -namespace {
|
| -
|
| -// Match a symbol name against a match string. An empty match string
|
| -// means match everything. Returns true if there is a match.
|
| -bool matchSymbolName(const IceString &SymbolName, const IceString &Match) {
|
| - return Match.empty() || Match == SymbolName;
|
| +Translator::Translator(GlobalContext *Ctx, const ClFlags &Flags)
|
| + : Ctx(Ctx), Flags(Flags),
|
| + GlobalLowering(TargetGlobalLowering::createLowering(Ctx)), ErrorStatus() {
|
| }
|
|
|
| -} // end of anonymous namespace
|
| -
|
| Translator::~Translator() {}
|
|
|
| IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) {
|
| @@ -66,49 +54,23 @@ bool Translator::checkIfUnnamedNameSafe(const IceString &Name, const char *Kind,
|
| return false;
|
| }
|
|
|
| -void Translator::translateFcn(Cfg *Fcn) {
|
| - Ctx->resetStats();
|
| - Func.reset(Fcn);
|
| - VerboseMask OldVerboseMask = Ctx->getVerbose();
|
| - if (!matchSymbolName(Func->getFunctionName(), Ctx->getFlags().VerboseFocusOn))
|
| - Ctx->setVerbose(IceV_None);
|
| -
|
| - if (Ctx->getFlags().DisableTranslation ||
|
| - !matchSymbolName(Func->getFunctionName(),
|
| - Ctx->getFlags().TranslateOnly)) {
|
| - Func->dump();
|
| - } else {
|
| - Func->translate();
|
| - if (Func->hasError()) {
|
| - std::cerr << "ICE translation error: " << Func->getError() << "\n";
|
| - ErrorStatus = true;
|
| - }
|
| -
|
| - if (!ErrorStatus) {
|
| - if (Ctx->getFlags().UseIntegratedAssembler) {
|
| - Func->emitIAS();
|
| - } else {
|
| - Func->emit();
|
| - }
|
| - }
|
| - Ctx->dumpStats(Func->getFunctionName());
|
| +void Translator::translateFcn(Cfg *Func) {
|
| + Ctx->cfgQueueAdd(Func);
|
| + if (Ctx->getFlags().NumTranslationThreads == 0) {
|
| + Ctx->translateFunctions();
|
| }
|
| -
|
| - Ctx->setVerbose(OldVerboseMask);
|
| }
|
|
|
| void Translator::emitConstants() {
|
| - if (!Ctx->getFlags().DisableTranslation && Func)
|
| - Func->getTarget()->emitConstants();
|
| + if (!getErrorStatus())
|
| + GlobalLowering->lowerConstants(Ctx);
|
| }
|
|
|
| void Translator::lowerGlobals(
|
| const VariableDeclarationListType &VariableDeclarations) {
|
| - std::unique_ptr<TargetGlobalInitLowering> GlobalLowering(
|
| - TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx));
|
| bool DisableTranslation = Ctx->getFlags().DisableTranslation;
|
| const bool DumpGlobalVariables =
|
| - ALLOW_DUMP && Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
|
| + ALLOW_DUMP && Ctx->getVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
|
| OstreamLocker L(Ctx);
|
| Ostream &Stream = Ctx->getStrDump();
|
| const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly;
|
| @@ -116,8 +78,7 @@ void Translator::lowerGlobals(
|
| if (DumpGlobalVariables)
|
| Global->dump(getContext(), Stream);
|
| if (!DisableTranslation &&
|
| - matchSymbolName(Global->getName(), TranslateOnly))
|
| - GlobalLowering->lower(*Global);
|
| + GlobalContext::matchSymbolName(Global->getName(), TranslateOnly))
|
| + GlobalLowering->lowerInit(*Global);
|
| }
|
| - GlobalLowering.reset();
|
| }
|
|
|