[ARM] sext of a load is free
[llvm-core.git] / tools / llvm-c-test / main.c
blob0be48930f0b6562f9b4c281f3761b13a6f4e67ef
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 form stdin - list sections\n\n");
40 fprintf(stderr, " * --object-list-symbols\n");
41 fprintf(stderr,
42 " Read object file form 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, " * --echo\n");
51 fprintf(stderr,
52 " Read bitcode file form stdin - print it back out\n\n");
53 fprintf(stderr, " * --test-diagnostic-handler\n");
54 fprintf(stderr,
55 " Read bitcode file form stdin with a diagnostic handler set\n\n");
56 fprintf(stderr, " * --test-dibuilder\n");
57 fprintf(stderr,
58 " Run tests for the DIBuilder C API - print generated module\n\n");
61 int main(int argc, char **argv) {
62 LLVMPassRegistryRef pr = LLVMGetGlobalPassRegistry();
64 LLVMInitializeCore(pr);
66 if (argc == 2 && !strcmp(argv[1], "--lazy-new-module-dump")) {
67 return llvm_module_dump(true, true);
68 } else if (argc == 2 && !strcmp(argv[1], "--new-module-dump")) {
69 return llvm_module_dump(false, true);
70 } else if (argc == 2 && !strcmp(argv[1], "--lazy-module-dump")) {
71 return llvm_module_dump(true, false);
72 } else if (argc == 2 && !strcmp(argv[1], "--module-dump")) {
73 return llvm_module_dump(false, false);
74 } else if (argc == 2 && !strcmp(argv[1], "--module-list-functions")) {
75 return llvm_module_list_functions();
76 } else if (argc == 2 && !strcmp(argv[1], "--module-list-globals")) {
77 return llvm_module_list_globals();
78 } else if (argc == 2 && !strcmp(argv[1], "--targets-list")) {
79 return llvm_targets_list();
80 } else if (argc == 2 && !strcmp(argv[1], "--object-list-sections")) {
81 return llvm_object_list_sections();
82 } else if (argc == 2 && !strcmp(argv[1], "--object-list-symbols")) {
83 return llvm_object_list_symbols();
84 } else if (argc == 2 && !strcmp(argv[1], "--disassemble")) {
85 return llvm_disassemble();
86 } else if (argc == 2 && !strcmp(argv[1], "--calc")) {
87 return llvm_calc();
88 } else if (argc == 2 && !strcmp(argv[1], "--add-named-metadata-operand")) {
89 return llvm_add_named_metadata_operand();
90 } else if (argc == 2 && !strcmp(argv[1], "--set-metadata")) {
91 return llvm_set_metadata();
92 } else if (argc == 2 && !strcmp(argv[1], "--test-function-attributes")) {
93 return llvm_test_function_attributes();
94 } else if (argc == 2 && !strcmp(argv[1], "--test-callsite-attributes")) {
95 return llvm_test_callsite_attributes();
96 } else if (argc == 2 && !strcmp(argv[1], "--echo")) {
97 return llvm_echo();
98 } else if (argc == 2 && !strcmp(argv[1], "--test-diagnostic-handler")) {
99 return llvm_test_diagnostic_handler();
100 } else if (argc == 2 && !strcmp(argv[1], "--test-dibuilder")) {
101 return llvm_test_dibuilder();
102 } else {
103 print_usage();
106 return 1;