xref: /llvm-project/llvm/tools/llvm-c-test/targets.c (revision 2946cd701067404b99c39fb29dc9c74bd7193eb3)
1b932c669SAnders Waldenborg /*===-- targets.c - tool for testing libLLVM and llvm-c API ---------------===*\
2b932c669SAnders Waldenborg |*                                                                            *|
3*2946cd70SChandler Carruth |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
4*2946cd70SChandler Carruth |* Exceptions.                                                                *|
5*2946cd70SChandler Carruth |* See https://llvm.org/LICENSE.txt for license information.                  *|
6*2946cd70SChandler Carruth |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
7b932c669SAnders Waldenborg |*                                                                            *|
8b932c669SAnders Waldenborg |*===----------------------------------------------------------------------===*|
9b932c669SAnders Waldenborg |*                                                                            *|
10b932c669SAnders Waldenborg |* This file implements the --targets command in llvm-c-test.                 *|
11b932c669SAnders Waldenborg |*                                                                            *|
12b932c669SAnders Waldenborg \*===----------------------------------------------------------------------===*/
13b932c669SAnders Waldenborg 
14b932c669SAnders Waldenborg #include "llvm-c/TargetMachine.h"
15b932c669SAnders Waldenborg #include <stdio.h>
16b932c669SAnders Waldenborg 
llvm_targets_list(void)179a3bd236SBenjamin Kramer int llvm_targets_list(void) {
18c4914695SNAKAMURA Takumi   LLVMTargetRef t;
19b932c669SAnders Waldenborg   LLVMInitializeAllTargetInfos();
20b932c669SAnders Waldenborg   LLVMInitializeAllTargets();
21b932c669SAnders Waldenborg 
22c4914695SNAKAMURA Takumi   for (t = LLVMGetFirstTarget(); t; t = LLVMGetNextTarget(t)) {
23b932c669SAnders Waldenborg     printf("%s", LLVMGetTargetName(t));
24b932c669SAnders Waldenborg     if (LLVMTargetHasJIT(t))
25b932c669SAnders Waldenborg       printf(" (+jit)");
26b932c669SAnders Waldenborg     printf("\n - %s\n", LLVMGetTargetDescription(t));
27b932c669SAnders Waldenborg   }
28b932c669SAnders Waldenborg 
29b932c669SAnders Waldenborg   return 0;
30b932c669SAnders Waldenborg }
31