1 //===--- unittests/DebugInfo/DWARF/DwarfUtils.cpp ---------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "DwarfUtils.h"
10 #include "llvm/ADT/Triple.h"
11 #include "llvm/Config/llvm-config.h"
12 #include "llvm/Support/TargetRegistry.h"
13 #include "llvm/Support/TargetSelect.h"
17 static void initLLVMIfNeeded() {
18 static bool gInitialized
= false;
21 InitializeAllTargets();
22 InitializeAllTargetMCs();
23 InitializeAllAsmPrinters();
24 InitializeAllAsmParsers();
28 Triple
llvm::dwarf::utils::getHostTripleForAddrSize(uint8_t AddrSize
) {
29 Triple
T(Triple::normalize(LLVM_HOST_TRIPLE
));
31 if (AddrSize
== 8 && T
.isArch32Bit())
32 return T
.get64BitArchVariant();
33 if (AddrSize
== 4 && T
.isArch64Bit())
34 return T
.get32BitArchVariant();
38 bool llvm::dwarf::utils::isConfigurationSupported(Triple
&T
) {
41 return TargetRegistry::lookupTarget(T
.getTriple(), Err
);