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