Introduce the notion of function addresses in Subzero.
Introduces the notion of a function address, to replace using LLVM
IR's Function class. Modifies Ice converter, and Subzero's bitcode
reader, to build function addresses.
BUG=None
R=jvoung@chromium.org, stichnot@chromium.org
Review URL: https://codereview.chromium.org/641193002
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp
index e86d60a..6d4af11 100644
--- a/src/IceTranslator.cpp
+++ b/src/IceTranslator.cpp
@@ -22,6 +22,7 @@
#include "IceCfg.h"
#include "IceClFlags.h"
#include "IceDefs.h"
+#include "IceGlobalInits.h"
#include "IceTargetLowering.h"
#include "IceTranslator.h"
@@ -54,38 +55,6 @@
return false;
}
-void Translator::nameUnnamedGlobalAddresses(llvm::Module *Mod) {
- const IceString &GlobalPrefix = Flags.DefaultGlobalPrefix;
- if (GlobalPrefix.empty())
- return;
- uint32_t NameIndex = 0;
- Ostream &errs = Ctx->getStrDump();
- for (auto V = Mod->global_begin(), E = Mod->global_end(); V != E; ++V) {
- if (!V->hasName()) {
- V->setName(createUnnamedName(GlobalPrefix, NameIndex));
- ++NameIndex;
- } else {
- checkIfUnnamedNameSafe(V->getName(), "global", GlobalPrefix, errs);
- }
- }
-}
-
-void Translator::nameUnnamedFunctions(llvm::Module *Mod) {
- const IceString &FunctionPrefix = Flags.DefaultFunctionPrefix;
- if (FunctionPrefix.empty())
- return;
- uint32_t NameIndex = 0;
- Ostream &errs = Ctx->getStrDump();
- for (llvm::Function &F : *Mod) {
- if (!F.hasName()) {
- F.setName(createUnnamedName(FunctionPrefix, NameIndex));
- ++NameIndex;
- } else {
- checkIfUnnamedNameSafe(F.getName(), "function", FunctionPrefix, errs);
- }
- }
-}
-
void Translator::translateFcn(Cfg *Fcn) {
Ctx->resetStats();
Func.reset(Fcn);
@@ -110,12 +79,18 @@
Func->getTarget()->emitConstants();
}
-void Translator::lowerGlobals(const GlobalAddressList &GlobalAddresses) {
- llvm::OwningPtr<Ice::TargetGlobalInitLowering> GlobalLowering(
- Ice::TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx));
+void Translator::lowerGlobals(
+ const VariableDeclarationListType &VariableDeclarations) {
+ llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering(
+ TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx));
bool DisableTranslation = Ctx->getFlags().DisableTranslation;
- for (const Ice::GlobalAddress *Addr : GlobalAddresses) {
- GlobalLowering->lower(*Addr, DisableTranslation);
+ bool DumpGlobalVariables = Ctx->isVerbose();
+ Ostream &Stream = Ctx->getStrDump();
+ for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
+ if (DumpGlobalVariables)
+ Global->dump(Stream);
+ if(!DisableTranslation)
+ GlobalLowering->lower(*Global);
}
GlobalLowering.reset();
}