[Orc] Add support for emitting indirect stubs directly into the JIT target's
[oota-llvm.git] / tools / llvm-c-test / disassemble.c
index eb40bf3d4461d2579ca633eace818eadde2bdab3..05a9218d014a6e03549ae719459be77de705bc5d 100644 (file)
@@ -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) {