Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===- Configuration.h - Configuration Data Mgmt ----------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 5f5a573 | 2007-12-29 20:44:31 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file declares the LLVMC_ConfigDataProvider class which implements the |
| 11 | // generation of ConfigData objects for the CompilerDriver. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_TOOLS_LLVMC_CONFIGDATA_H |
| 16 | #define LLVM_TOOLS_LLVMC_CONFIGDATA_H |
| 17 | |
| 18 | #include "CompilerDriver.h" |
| 19 | #include <llvm/ADT/hash_map> |
| 20 | |
| 21 | namespace llvm { |
| 22 | /// This class provides the high level interface to the LLVM Compiler Driver. |
| 23 | /// The driver's purpose is to make it easier for compiler writers and users |
| 24 | /// of LLVM to utilize the compiler toolkits and LLVM toolset by learning only |
| 25 | /// the interface of one program (llvmc). |
| 26 | /// |
| 27 | /// @see llvmc.cpp |
| 28 | /// @brief The interface to the LLVM Compiler Driver. |
| 29 | class LLVMC_ConfigDataProvider : public CompilerDriver::ConfigDataProvider { |
| 30 | /// @name Constructor |
| 31 | /// @{ |
| 32 | public: |
| 33 | virtual ~LLVMC_ConfigDataProvider(); |
| 34 | |
| 35 | /// @name Methods |
| 36 | /// @{ |
| 37 | public: |
| 38 | /// @brief Provide the configuration data to the CompilerDriver. |
| 39 | virtual CompilerDriver::ConfigData* |
| 40 | ProvideConfigData(const std::string& filetype); |
| 41 | |
| 42 | /// @brief Allow the configuration directory to be set |
| 43 | virtual void setConfigDir(const sys::Path& dirName) { |
| 44 | configDir = dirName; |
| 45 | } |
| 46 | |
| 47 | private: |
| 48 | CompilerDriver::ConfigData* ReadConfigData(const std::string& ftype); |
| 49 | |
| 50 | /// @} |
| 51 | /// @name Data |
| 52 | /// @{ |
| 53 | private: |
| 54 | /// @brief This type is used internally to hold the configuration data. |
| 55 | typedef hash_map<std::string,CompilerDriver::ConfigData*> ConfigDataMap; |
| 56 | ConfigDataMap Configurations; ///< The cache of configurations |
| 57 | sys::Path configDir; |
| 58 | /// @} |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | #endif |