[RISCV] Rename a lambda to have plural nouns to reflect that it contains a loop. NFC
[llvm-project.git] / llvm / tools / llvm-c-test / main.c
blobbadbe4b13b6ba566bb0b289f5b57e1505140ec73
1 /*===-- main.c - tool for testing libLLVM and llvm-c API ------------------===*\
2 |* *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4 |* Exceptions. *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* Main file for llvm-c-tests. "Parses" arguments and dispatches. *|
11 |* *|
12 \*===----------------------------------------------------------------------===*/
14 #include "llvm-c-test.h"
15 #include <stdio.h>
16 #include <string.h>
18 static void print_usage(void) {
19 fprintf(stderr, "llvm-c-test command\n\n");
20 fprintf(stderr, " Commands:\n");
21 fprintf(stderr, " * --module-dump\n");
22 fprintf(stderr, " Read bitcode from stdin - print disassembly\n\n");
23 fprintf(stderr, " * --lazy-module-dump\n");
24 fprintf(stderr,
25 " Lazily read bitcode from stdin - print disassembly\n\n");
26 fprintf(stderr, " * --new-module-dump\n");
27 fprintf(stderr, " Read bitcode from stdin - print disassembly\n\n");
28 fprintf(stderr, " * --lazy-new-module-dump\n");
29 fprintf(stderr,
30 " Lazily read bitcode from stdin - print disassembly\n\n");
31 fprintf(stderr, " * --module-list-functions\n");
32 fprintf(stderr,
33 " Read bitcode from stdin - list summary of functions\n\n");
34 fprintf(stderr, " * --module-list-globals\n");
35 fprintf(stderr, " Read bitcode from stdin - list summary of globals\n\n");
36 fprintf(stderr, " * --targets-list\n");
37 fprintf(stderr, " List available targets\n\n");
38 fprintf(stderr, " * --object-list-sections\n");
39 fprintf(stderr, " Read object file from stdin - list sections\n\n");
40 fprintf(stderr, " * --object-list-symbols\n");
41 fprintf(stderr,
42 " Read object file from stdin - list symbols (like nm)\n\n");
43 fprintf(stderr, " * --disassemble\n");
44 fprintf(stderr, " Read lines of triple, hex ascii machine code from stdin "
45 "- print disassembly\n\n");
46 fprintf(stderr, " * --calc\n");
47 fprintf(
48 stderr,
49 " Read lines of name, rpn from stdin - print generated module\n\n");
50 fprintf(stderr, " * --get-di-tag\n");
51 fprintf(stderr, " Run test for getting MDNode dwarf tag\n");
52 fprintf(stderr, " * --di-type-get-name\n");
53 fprintf(stderr, " Run test for getting MDNode type name\n");
54 fprintf(stderr, " * --replace-md-operand\n");
55 fprintf(stderr, " Run test for replacing MDNode operands\n");
56 fprintf(stderr, " * --is-a-value-as-metadata\n");
57 fprintf(stderr,
58 " Run test for checking if LLVMValueRef is a ValueAsMetadata\n");
59 fprintf(stderr, " * --echo\n");
60 fprintf(stderr, " Read bitcode file from stdin - print it back out\n\n");
61 fprintf(stderr, " * --test-diagnostic-handler\n");
62 fprintf(stderr,
63 " Read bitcode file from stdin with a diagnostic handler set\n\n");
64 fprintf(stderr, " * --test-dibuilder\n");
65 fprintf(stderr,
66 " Run tests for the DIBuilder C API - print generated module\n\n");
69 int main(int argc, char **argv) {
70 if (argc == 2 && !strcmp(argv[1], "--lazy-new-module-dump")) {
71 return llvm_module_dump(true, true);
72 } else if (argc == 2 && !strcmp(argv[1], "--new-module-dump")) {
73 return llvm_module_dump(false, true);
74 } else if (argc == 2 && !strcmp(argv[1], "--lazy-module-dump")) {
75 return llvm_module_dump(true, false);
76 } else if (argc == 2 && !strcmp(argv[1], "--module-dump")) {
77 return llvm_module_dump(false, false);
78 } else if (argc == 2 && !strcmp(argv[1], "--module-list-functions")) {
79 return llvm_module_list_functions();
80 } else if (argc == 2 && !strcmp(argv[1], "--module-list-globals")) {
81 return llvm_module_list_globals();
82 } else if (argc == 2 && !strcmp(argv[1], "--targets-list")) {
83 return llvm_targets_list();
84 } else if (argc == 2 && !strcmp(argv[1], "--object-list-sections")) {
85 return llvm_object_list_sections();
86 } else if (argc == 2 && !strcmp(argv[1], "--object-list-symbols")) {
87 return llvm_object_list_symbols();
88 } else if (argc == 2 && !strcmp(argv[1], "--disassemble")) {
89 return llvm_disassemble();
90 } else if (argc == 2 && !strcmp(argv[1], "--calc")) {
91 return llvm_calc();
92 } else if (argc == 2 && !strcmp(argv[1], "--add-named-metadata-operand")) {
93 return llvm_add_named_metadata_operand();
94 } else if (argc == 2 && !strcmp(argv[1], "--set-metadata")) {
95 return llvm_set_metadata();
96 } else if (argc == 2 && !strcmp(argv[1], "--get-di-tag")) {
97 return llvm_get_di_tag();
98 } else if (argc == 2 && !strcmp(argv[1], "--di-type-get-name")) {
99 return llvm_di_type_get_name();
100 } else if (argc == 2 && !strcmp(argv[1], "--replace-md-operand")) {
101 return llvm_replace_md_operand();
102 } else if (argc == 2 && !strcmp(argv[1], "--is-a-value-as-metadata")) {
103 return llvm_is_a_value_as_metadata();
104 } else if (argc == 2 && !strcmp(argv[1], "--test-function-attributes")) {
105 return llvm_test_function_attributes();
106 } else if (argc == 2 && !strcmp(argv[1], "--test-callsite-attributes")) {
107 return llvm_test_callsite_attributes();
108 } else if (argc == 2 && !strcmp(argv[1], "--echo")) {
109 return llvm_echo();
110 } else if (argc == 2 && !strcmp(argv[1], "--test-diagnostic-handler")) {
111 return llvm_test_diagnostic_handler();
112 } else if (argc == 2 && !strcmp(argv[1], "--test-dibuilder")) {
113 return llvm_test_dibuilder();
114 } else {
115 print_usage();
118 return 1;