Add llvm-c-test tool for testing llvm-c
[oota-llvm.git] / tools / llvm-c-test / targets.c
1 /*===-- targets.c - tool for testing libLLVM and llvm-c API ---------------===*\
2 |*                                                                            *|
3 |*                     The LLVM Compiler Infrastructure                       *|
4 |*                                                                            *|
5 |* This file is distributed under the University of Illinois Open Source      *|
6 |* License. See LICENSE.TXT for details.                                      *|
7 |*                                                                            *|
8 |*===----------------------------------------------------------------------===*|
9 |*                                                                            *|
10 |* This file implements the --targets command in llvm-c-test.                 *|
11 |*                                                                            *|
12 \*===----------------------------------------------------------------------===*/
13
14 #include "llvm-c/TargetMachine.h"
15 #include <stdio.h>
16
17 int targets_list(void) {
18   LLVMInitializeAllTargetInfos();
19   LLVMInitializeAllTargets();
20
21   for (LLVMTargetRef t = LLVMGetFirstTarget(); t; t = LLVMGetNextTarget(t)) {
22     printf("%s", LLVMGetTargetName(t));
23     if (LLVMTargetHasJIT(t))
24       printf(" (+jit)");
25     printf("\n - %s\n", LLVMGetTargetDescription(t));
26   }
27
28   return 0;
29 }