diff options
author | Stephen Hines <srhines@google.com> | 2014-12-01 14:51:49 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-12-02 16:08:10 -0800 |
commit | 37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch) | |
tree | 8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /tools/llvm-c-test | |
parent | d2327b22152ced7bc46dc629fc908959e8a52d03 (diff) | |
download | external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2 |
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'tools/llvm-c-test')
-rw-r--r-- | tools/llvm-c-test/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tools/llvm-c-test/disassemble.c | 20 |
2 files changed, 22 insertions, 7 deletions
diff --git a/tools/llvm-c-test/CMakeLists.txt b/tools/llvm-c-test/CMakeLists.txt index 34fea3d..989678b 100644 --- a/tools/llvm-c-test/CMakeLists.txt +++ b/tools/llvm-c-test/CMakeLists.txt @@ -7,6 +7,10 @@ set(LLVM_LINK_COMPONENTS Target ) +if(TARGET LLVM) + set(LLVM_LINK_COMPONENTS) +endif() + if (LLVM_COMPILER_IS_GCC_COMPATIBLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wstrict-prototypes") endif () @@ -21,3 +25,8 @@ add_llvm_tool(llvm-c-test object.c targets.c ) + +# Use libLLVM.so if it is available. +if(TARGET LLVM) + target_link_libraries(llvm-c-test LLVM) +endif() diff --git a/tools/llvm-c-test/disassemble.c b/tools/llvm-c-test/disassemble.c index eb40bf3..05a9218 100644 --- a/tools/llvm-c-test/disassemble.c +++ b/tools/llvm-c-test/disassemble.c @@ -18,6 +18,7 @@ #include "llvm-c/Target.h" #include <stdio.h> #include <stdlib.h> +#include <string.h> static void pprint(int pos, unsigned char *buf, int len, const char *disasm) { int i; @@ -33,13 +34,15 @@ static void pprint(int pos, unsigned char *buf, int len, const char *disasm) { printf(" %s\n", disasm); } -static void do_disassemble(const char *triple, unsigned char *buf, int siz) { - LLVMDisasmContextRef D = LLVMCreateDisasm(triple, NULL, 0, NULL, NULL); +static void do_disassemble(const char *triple, const char *features, + unsigned char *buf, int siz) { + LLVMDisasmContextRef D = LLVMCreateDisasmCPUFeatures(triple, "", features, + NULL, 0, NULL, NULL); char outline[1024]; int pos; if (!D) { - printf("ERROR: Couldn't create disassebler for triple %s\n", triple); + printf("ERROR: Couldn't create disassembler for triple %s\n", triple); return; } @@ -62,19 +65,22 @@ static void do_disassemble(const char *triple, unsigned char *buf, int siz) { static void handle_line(char **tokens, int ntokens) { unsigned char disbuf[128]; size_t disbuflen = 0; - char *triple = tokens[0]; + const char *triple = tokens[0]; + const char *features = tokens[1]; int i; - printf("triple: %s\n", triple); + printf("triple: %s, features: %s\n", triple, features); + if (!strcmp(features, "NULL")) + features = ""; - for (i = 1; i < ntokens; i++) { + for (i = 2; i < ntokens; i++) { disbuf[disbuflen++] = strtol(tokens[i], NULL, 16); if (disbuflen >= sizeof(disbuf)) { fprintf(stderr, "Warning: Too long line, truncating\n"); break; } } - do_disassemble(triple, disbuf, disbuflen); + do_disassemble(triple, features, disbuf, disbuflen); } int disassemble(void) { |