Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:29

0001 //===- llvm/Codegen/LinkAllCodegenComponents.h ------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This header file pulls in all codegen related passes for tools like lli and
0010 // llc that need this functionality.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CODEGEN_LINKALLCODEGENCOMPONENTS_H
0015 #define LLVM_CODEGEN_LINKALLCODEGENCOMPONENTS_H
0016 
0017 #include "llvm/CodeGen/Passes.h"
0018 #include "llvm/CodeGen/SchedulerRegistry.h"
0019 #include "llvm/Target/TargetMachine.h"
0020 #include <cstdlib>
0021 
0022 namespace {
0023   struct ForceCodegenLinking {
0024     ForceCodegenLinking() {
0025       // We must reference the passes in such a way that compilers will not
0026       // delete it all as dead code, even with whole program optimization,
0027       // yet is effectively a NO-OP. As the compiler isn't smart enough
0028       // to know that getenv() never returns -1, this will do the job.
0029       // This is so that globals in the translation units where these functions
0030       // are defined are forced to be initialized, populating various
0031       // registries.
0032       if (std::getenv("bar") != (char*) -1)
0033         return;
0034 
0035       (void) llvm::createFastRegisterAllocator();
0036       (void) llvm::createBasicRegisterAllocator();
0037       (void) llvm::createGreedyRegisterAllocator();
0038       (void) llvm::createDefaultPBQPRegisterAllocator();
0039 
0040       (void)llvm::createBURRListDAGScheduler(nullptr,
0041                                              llvm::CodeGenOptLevel::Default);
0042       (void)llvm::createSourceListDAGScheduler(nullptr,
0043                                                llvm::CodeGenOptLevel::Default);
0044       (void)llvm::createHybridListDAGScheduler(nullptr,
0045                                                llvm::CodeGenOptLevel::Default);
0046       (void)llvm::createFastDAGScheduler(nullptr,
0047                                          llvm::CodeGenOptLevel::Default);
0048       (void)llvm::createDefaultScheduler(nullptr,
0049                                          llvm::CodeGenOptLevel::Default);
0050       (void)llvm::createVLIWDAGScheduler(nullptr,
0051                                          llvm::CodeGenOptLevel::Default);
0052     }
0053   } ForceCodegenLinking; // Force link by creating a global definition.
0054 }
0055 
0056 #endif