Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[examples] Move loop unroller passes into anonymous namespace. #523

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions examples/example_unrolling_service/loop_unroller/loop_unroller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

using namespace llvm;

namespace llvm {
namespace {

/// Input LLVM module file name.
cl::opt<std::string> InputFilename(cl::Positional, cl::desc("Specify input filename"),
cl::value_desc("filename"), cl::init("-"));
Expand Down Expand Up @@ -65,9 +66,6 @@ static cl::opt<bool> PreserveAssemblyUseListOrder(
"preserve-ll-uselistorder", cl::desc("Preserve use-list order when writing LLVM assembly."),
cl::init(false), cl::Hidden);

// The INITIALIZE_PASS_XXX macros put the initialiser in the llvm namespace.
void initializeLoopCounterPass(PassRegistry& Registry);

class LoopCounter : public llvm::FunctionPass {
public:
static char ID;
Expand All @@ -90,15 +88,6 @@ class LoopCounter : public llvm::FunctionPass {
}
};

// Initialise the pass. We have to declare the dependencies we use.
char LoopCounter::ID = 0;
INITIALIZE_PASS_BEGIN(LoopCounter, "count-loops", "Count loops", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LoopCounter, "count-loops", "Count loops", false, false)

// The INITIALIZE_PASS_XXX macros put the initialiser in the llvm namespace.
void initializeLoopUnrollConfiguratorPass(PassRegistry& Registry);

class LoopUnrollConfigurator : public llvm::FunctionPass {
public:
static char ID;
Expand All @@ -125,13 +114,7 @@ class LoopUnrollConfigurator : public llvm::FunctionPass {
}
};

// Initialise the pass. We have to declare the dependencies we use.
char LoopUnrollConfigurator::ID = 1;
INITIALIZE_PASS_BEGIN(LoopUnrollConfigurator, "unroll-loops-configurator",
"Configurates loop unrolling", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LoopUnrollConfigurator, "unroll-loops-configurator",
"Configurates loop unrolling", false, false)

/// Reads a module from a file.
/// On error, messages are written to stderr and null is returned.
Expand All @@ -148,8 +131,29 @@ static std::unique_ptr<Module> readModule(LLVMContext& Context, StringRef Name)
return Module;
}

char LoopCounter::ID = 0;

} // anonymous namespace

namespace llvm {

// The INITIALIZE_PASS_XXX macros put the initialiser in the llvm namespace.
void initializeLoopCounterPass(PassRegistry& Registry);
void initializeLoopUnrollConfiguratorPass(PassRegistry& Registry);

} // namespace llvm

// Initialise the passes. We have to declare the dependencies we use.
INITIALIZE_PASS_BEGIN(LoopUnrollConfigurator, "unroll-loops-configurator",
"Configurates loop unrolling", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LoopUnrollConfigurator, "unroll-loops-configurator",
"Configurates loop unrolling", false, false)

INITIALIZE_PASS_BEGIN(LoopCounter, "count-loops", "Count loops", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LoopCounter, "count-loops", "Count loops", false, false)

int main(int argc, char** argv) {
cl::ParseCommandLineOptions(argc, argv,
" LLVM-Counter\n\n"
Expand Down