1 //===-- The main header generation class ------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H 10 #define LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H 11 12 #include "Command.h" 13 14 #include "llvm/ADT/SmallVector.h" 15 #include "llvm/ADT/StringRef.h" 16 17 #include <memory> 18 #include <string> 19 #include <unordered_map> 20 21 namespace llvm { 22 23 class raw_ostream; 24 class RecordKeeper; 25 26 } // namespace llvm 27 28 namespace llvm_libc { 29 30 class Command; 31 32 class Generator { 33 llvm::StringRef HeaderDefFile; 34 const std::vector<std::string> &EntrypointNameList; 35 llvm::StringRef StdHeader; 36 std::unordered_map<std::string, std::string> &ArgMap; 37 38 std::unique_ptr<Command> IncludeFileCmd; 39 std::unique_ptr<Command> PublicAPICmd; 40 41 Command *getCommandHandler(llvm::StringRef CommandName); 42 43 void parseCommandArgs(llvm::StringRef ArgStr, ArgVector &Args); 44 45 void printError(llvm::StringRef Msg); 46 47 public: Generator(const std::string & DefFile,const std::vector<std::string> & EN,const std::string & Header,std::unordered_map<std::string,std::string> & Map)48 Generator(const std::string &DefFile, const std::vector<std::string> &EN, 49 const std::string &Header, 50 std::unordered_map<std::string, std::string> &Map) 51 : HeaderDefFile(DefFile), EntrypointNameList(EN), StdHeader(Header), 52 ArgMap(Map) {} 53 54 void generate(llvm::raw_ostream &OS, llvm::RecordKeeper &Records); 55 }; 56 57 } // namespace llvm_libc 58 59 #endif // LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H 60