1 /*===-- main.c - tool for testing libLLVM and llvm-c API ------------------===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
8 |*===----------------------------------------------------------------------===*|
10 |* Main file for llvm-c-tests. "Parses" arguments and dispatches. *|
12 \*===----------------------------------------------------------------------===*/
14 #include "llvm-c-test.h"
15 #include "llvm-c/BitReader.h"
16 #include "llvm-c/Core.h"
21 static void print_usage(void) {
22 fprintf(stderr, "llvm-c-test command\n\n");
23 fprintf(stderr, " Commands:\n");
24 fprintf(stderr, " * --module-dump\n");
25 fprintf(stderr, " Read bytecode from stdin - print disassembly\n\n");
26 fprintf(stderr, " * --module-list-functions\n");
28 " Read bytecode from stdin - list summary of functions\n\n");
29 fprintf(stderr, " * --module-list-globals\n");
30 fprintf(stderr, " Read bytecode from stdin - list summary of globals\n\n");
31 fprintf(stderr, " * --targets-list\n");
32 fprintf(stderr, " List available targets\n\n");
33 fprintf(stderr, " * --object-list-sections\n");
34 fprintf(stderr, " Read object file form stdin - list sections\n\n");
35 fprintf(stderr, " * --object-list-symbols\n");
37 " Read object file form stdin - list symbols (like nm)\n\n");
38 fprintf(stderr, " * --disassemble\n");
39 fprintf(stderr, " Read lines of triple, hex ascii machine code from stdin "
40 "- print disassembly\n\n");
41 fprintf(stderr, " * --calc\n");
44 " Read lines of name, rpn from stdin - print generated module\n\n");
47 int main(int argc, char **argv) {
48 LLVMPassRegistryRef pr = LLVMGetGlobalPassRegistry();
50 LLVMInitializeCore(pr);
52 if (argc == 2 && !strcmp(argv[1], "--module-dump")) {
54 } else if (argc == 2 && !strcmp(argv[1], "--module-list-functions")) {
55 return module_list_functions();
56 } else if (argc == 2 && !strcmp(argv[1], "--module-list-globals")) {
57 return module_list_globals();
58 } else if (argc == 2 && !strcmp(argv[1], "--targets-list")) {
59 return targets_list();
60 } else if (argc == 2 && !strcmp(argv[1], "--object-list-sections")) {
61 return object_list_sections();
62 } else if (argc == 2 && !strcmp(argv[1], "--object-list-symbols")) {
63 return object_list_symbols();
64 } else if (argc == 2 && !strcmp(argv[1], "--disassemble")) {
66 } else if (argc == 2 && !strcmp(argv[1], "--calc")) {