2013-10-23 10:10:20 +02:00
|
|
|
/*===-- main.c - tool for testing libLLVM and llvm-c API ------------------===*\
|
|
|
|
|* *|
|
|
|
|
|* The LLVM Compiler Infrastructure *|
|
|
|
|
|* *|
|
|
|
|
|* This file is distributed under the University of Illinois Open Source *|
|
|
|
|
|* License. See LICENSE.TXT for details. *|
|
|
|
|
|* *|
|
|
|
|
|*===----------------------------------------------------------------------===*|
|
|
|
|
|* *|
|
|
|
|
|* Main file for llvm-c-tests. "Parses" arguments and dispatches. *|
|
|
|
|
|* *|
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
#include "llvm-c-test.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static void print_usage(void) {
|
|
|
|
fprintf(stderr, "llvm-c-test command\n\n");
|
|
|
|
fprintf(stderr, " Commands:\n");
|
|
|
|
fprintf(stderr, " * --module-dump\n");
|
2016-04-08 11:19:02 +02:00
|
|
|
fprintf(stderr, " Read bitcode from stdin - print disassembly\n\n");
|
2015-12-18 04:57:26 +01:00
|
|
|
fprintf(stderr, " * --lazy-module-dump\n");
|
2015-12-19 00:46:42 +01:00
|
|
|
fprintf(stderr,
|
2016-04-08 11:19:02 +02:00
|
|
|
" Lazily read bitcode from stdin - print disassembly\n\n");
|
2015-12-19 00:46:42 +01:00
|
|
|
fprintf(stderr, " * --new-module-dump\n");
|
2016-04-08 11:19:02 +02:00
|
|
|
fprintf(stderr, " Read bitcode from stdin - print disassembly\n\n");
|
2015-12-19 00:46:42 +01:00
|
|
|
fprintf(stderr, " * --lazy-new-module-dump\n");
|
2015-12-18 04:57:26 +01:00
|
|
|
fprintf(stderr,
|
2016-04-08 11:19:02 +02:00
|
|
|
" Lazily read bitcode from stdin - print disassembly\n\n");
|
2013-10-23 10:10:20 +02:00
|
|
|
fprintf(stderr, " * --module-list-functions\n");
|
|
|
|
fprintf(stderr,
|
2016-04-08 11:19:02 +02:00
|
|
|
" Read bitcode from stdin - list summary of functions\n\n");
|
2013-10-23 10:10:20 +02:00
|
|
|
fprintf(stderr, " * --module-list-globals\n");
|
2016-04-08 11:19:02 +02:00
|
|
|
fprintf(stderr, " Read bitcode from stdin - list summary of globals\n\n");
|
2013-10-23 10:10:20 +02:00
|
|
|
fprintf(stderr, " * --targets-list\n");
|
|
|
|
fprintf(stderr, " List available targets\n\n");
|
|
|
|
fprintf(stderr, " * --object-list-sections\n");
|
|
|
|
fprintf(stderr, " Read object file form stdin - list sections\n\n");
|
|
|
|
fprintf(stderr, " * --object-list-symbols\n");
|
|
|
|
fprintf(stderr,
|
|
|
|
" Read object file form stdin - list symbols (like nm)\n\n");
|
|
|
|
fprintf(stderr, " * --disassemble\n");
|
|
|
|
fprintf(stderr, " Read lines of triple, hex ascii machine code from stdin "
|
|
|
|
"- print disassembly\n\n");
|
|
|
|
fprintf(stderr, " * --calc\n");
|
|
|
|
fprintf(
|
|
|
|
stderr,
|
|
|
|
" Read lines of name, rpn from stdin - print generated module\n\n");
|
2016-04-08 11:19:02 +02:00
|
|
|
fprintf(stderr, " * --echo\n");
|
|
|
|
fprintf(stderr,
|
|
|
|
" Read bitcode file form stdin - print it back out\n\n");
|
|
|
|
fprintf(stderr, " * --test-diagnostic-handler\n");
|
|
|
|
fprintf(stderr,
|
|
|
|
" Read bitcode file form stdin with a diagnostic handler set\n\n");
|
2017-11-01 23:18:52 +01:00
|
|
|
fprintf(stderr, " * --test-dibuilder\n");
|
|
|
|
fprintf(stderr,
|
|
|
|
" Run tests for the DIBuilder C API - print generated module\n\n");
|
2013-10-23 10:10:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
LLVMPassRegistryRef pr = LLVMGetGlobalPassRegistry();
|
|
|
|
|
|
|
|
LLVMInitializeCore(pr);
|
|
|
|
|
2015-12-19 00:46:42 +01:00
|
|
|
if (argc == 2 && !strcmp(argv[1], "--lazy-new-module-dump")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_module_dump(true, true);
|
2015-12-19 00:46:42 +01:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--new-module-dump")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_module_dump(false, true);
|
2015-12-19 00:46:42 +01:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--lazy-module-dump")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_module_dump(true, false);
|
2015-12-18 04:57:26 +01:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--module-dump")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_module_dump(false, false);
|
2013-10-23 10:10:20 +02:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--module-list-functions")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_module_list_functions();
|
2013-10-23 10:10:20 +02:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--module-list-globals")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_module_list_globals();
|
2013-10-23 10:10:20 +02:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--targets-list")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_targets_list();
|
2013-10-23 10:10:20 +02:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--object-list-sections")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_object_list_sections();
|
2013-10-23 10:10:20 +02:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--object-list-symbols")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_object_list_symbols();
|
2013-10-23 10:10:20 +02:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--disassemble")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_disassemble();
|
2013-10-23 10:10:20 +02:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--calc")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_calc();
|
2015-01-28 17:35:59 +01:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--add-named-metadata-operand")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_add_named_metadata_operand();
|
2015-01-28 17:35:59 +01:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--set-metadata")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_set_metadata();
|
2016-11-15 23:19:59 +01:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--test-function-attributes")) {
|
|
|
|
return llvm_test_function_attributes();
|
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--test-callsite-attributes")) {
|
|
|
|
return llvm_test_callsite_attributes();
|
2016-02-05 00:26:19 +01:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--echo")) {
|
2016-02-05 14:31:14 +01:00
|
|
|
return llvm_echo();
|
2016-04-08 11:19:02 +02:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--test-diagnostic-handler")) {
|
|
|
|
return llvm_test_diagnostic_handler();
|
2017-11-01 23:18:52 +01:00
|
|
|
} else if (argc == 2 && !strcmp(argv[1], "--test-dibuilder")) {
|
|
|
|
return llvm_test_dibuilder();
|
2013-10-23 10:10:20 +02:00
|
|
|
} else {
|
|
|
|
print_usage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|