[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / libc / utils / HdrGen / Main.cpp
blobd1487476637062778892668bbe5f3a7a5f259815
1 //===-- "main" function of libc-hdrgen ------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "Generator.h"
11 #include "llvm/ADT/StringRef.h"
12 #include "llvm/Support/CommandLine.h"
13 #include "llvm/TableGen/Main.h"
15 #include <string>
16 #include <unordered_map>
18 namespace {
20 llvm::cl::opt<std::string>
21 HeaderDefFile("def", llvm::cl::desc("Path to the .h.def file."),
22 llvm::cl::value_desc("<filename>"), llvm::cl::Required);
23 llvm::cl::opt<std::string> StandardHeader(
24 "header",
25 llvm::cl::desc("The standard header file which is to be generated."),
26 llvm::cl::value_desc("<header file>"));
27 llvm::cl::list<std::string> EntrypointNamesOption(
28 "e", llvm::cl::value_desc("<list of entrypoints>"),
29 llvm::cl::desc(
30 "Each --e is one entrypoint (generated from entrypoints.txt)"),
31 llvm::cl::OneOrMore);
32 llvm::cl::list<std::string> ReplacementValues(
33 "args", llvm::cl::desc("Command separated <argument name>=<value> pairs."),
34 llvm::cl::value_desc("<name=value>[,name=value]"));
36 void ParseArgValuePairs(std::unordered_map<std::string, std::string> &Map) {
37 for (std::string &R : ReplacementValues) {
38 auto Pair = llvm::StringRef(R).split('=');
39 Map[std::string(Pair.first)] = std::string(Pair.second);
43 } // anonymous namespace
45 namespace llvm_libc {
47 bool HeaderGeneratorMain(llvm::raw_ostream &OS, llvm::RecordKeeper &Records) {
48 std::unordered_map<std::string, std::string> ArgMap;
49 ParseArgValuePairs(ArgMap);
50 Generator G(HeaderDefFile, EntrypointNamesOption, StandardHeader, ArgMap);
51 G.generate(OS, Records);
53 return false;
56 } // namespace llvm_libc
58 int main(int argc, char *argv[]) {
59 llvm::cl::ParseCommandLineOptions(argc, argv);
60 return TableGenMain(argv[0], &llvm_libc::HeaderGeneratorMain);