[MIParser] Set RegClassOrRegBank during instruction parsing
[llvm-complete.git] / unittests / DebugInfo / DWARF / DwarfUtils.cpp
blob249cfb42271ae12bf96479fa430ba5a3fbfcfc5f
1 //===--- unittests/DebugInfo/DWARF/DwarfUtils.cpp ---------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "DwarfUtils.h"
10 #include "llvm/ADT/Triple.h"
11 #include "llvm/Config/llvm-config.h"
12 #include "llvm/Support/Host.h"
13 #include "llvm/Support/TargetRegistry.h"
14 #include "llvm/Support/TargetSelect.h"
16 using namespace llvm;
18 static void initLLVMIfNeeded() {
19 static bool gInitialized = false;
20 if (!gInitialized) {
21 gInitialized = true;
22 InitializeAllTargets();
23 InitializeAllTargetMCs();
24 InitializeAllAsmPrinters();
25 InitializeAllAsmParsers();
29 Triple llvm::dwarf::utils::getNormalizedDefaultTargetTriple() {
30 Triple T(Triple::normalize(sys::getDefaultTargetTriple()));
32 return T;
35 Triple llvm::dwarf::utils::getDefaultTargetTripleForAddrSize(uint8_t AddrSize) {
36 Triple T = getNormalizedDefaultTargetTriple();
38 assert((AddrSize == 4 || AddrSize == 8) &&
39 "Only 32-bit/64-bit address size variants are supported");
41 // If a 32-bit/64-bit address size was specified, try to convert the triple
42 // if it is for the wrong variant.
43 if (AddrSize == 8 && T.isArch32Bit())
44 return T.get64BitArchVariant();
45 if (AddrSize == 4 && T.isArch64Bit())
46 return T.get32BitArchVariant();
47 return T;
50 bool llvm::dwarf::utils::isConfigurationSupported(Triple &T) {
51 initLLVMIfNeeded();
52 std::string Err;
53 return TargetRegistry::lookupTarget(T.getTriple(), Err);