LLVM API Documentation

LinkAllAsmWriterComponents.h
Go to the documentation of this file.
00001 //===- llvm/Codegen/LinkAllAsmWriterComponents.h ----------------*- C++ -*-===//
00002 //
00003 //                      The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This header file pulls in all assembler writer related passes for tools like
00011 // llc that need this functionality.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
00016 #define LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H
00017 
00018 #include "llvm/CodeGen/GCs.h"
00019 #include <cstdlib>
00020 
00021 namespace {
00022   struct ForceAsmWriterLinking {
00023     ForceAsmWriterLinking() {
00024       // We must reference the plug-ins in such a way that compilers will not
00025       // delete it all as dead code, even with whole program optimization,
00026       // yet is effectively a NO-OP. As the compiler isn't smart enough
00027       // to know that getenv() never returns -1, this will do the job.
00028       if (std::getenv("bar") != (char*) -1)
00029         return;
00030 
00031       llvm::linkOcamlGCPrinter();
00032       llvm::linkErlangGCPrinter();
00033 
00034     }
00035   } ForceAsmWriterLinking; // Force link by creating a global definition.
00036 }
00037 
00038 #endif // LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H