LLVM 23.0.0git
AVRTargetParser.cpp
Go to the documentation of this file.
1//===-- AVRTargetParser - Parser for AVR target features ------------------===//
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//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file implements a target parser to recognise AVR hardware features.
11///
12//===----------------------------------------------------------------------===//
13
15#include "llvm/ADT/DenseMap.h"
17#include "llvm/Support/Errc.h"
18
19using namespace llvm;
20
22 static const DenseMap<unsigned, StringRef> EFlagToFeatureSet = {
23 {ELF::EF_AVR_ARCH_AVR1, "avr1"},
24 {ELF::EF_AVR_ARCH_AVR2, "avr2"},
25 {ELF::EF_AVR_ARCH_AVR25, "avr25"},
26 {ELF::EF_AVR_ARCH_AVR3, "avr3"},
27 {ELF::EF_AVR_ARCH_AVR31, "avr31"},
28 {ELF::EF_AVR_ARCH_AVR35, "avr35"},
29 {ELF::EF_AVR_ARCH_AVR4, "avr4"},
30 {ELF::EF_AVR_ARCH_AVR5, "avr5"},
31 {ELF::EF_AVR_ARCH_AVR51, "avr51"},
32 {ELF::EF_AVR_ARCH_AVR6, "avr6"},
33 {ELF::EF_AVR_ARCH_AVRTINY, "avrtiny"},
34 {ELF::EF_AVR_ARCH_XMEGA1, "xmega1"},
35 {ELF::EF_AVR_ARCH_XMEGA2, "xmega2"},
36 {ELF::EF_AVR_ARCH_XMEGA3, "xmega3"},
37 {ELF::EF_AVR_ARCH_XMEGA4, "xmega4"},
38 {ELF::EF_AVR_ARCH_XMEGA5, "xmega"},
39 {ELF::EF_AVR_ARCH_XMEGA6, "xmega"},
40 {ELF::EF_AVR_ARCH_XMEGA7, "xmega"},
41 };
42
43 auto It = EFlagToFeatureSet.find(EFlag);
44 if (It != EFlagToFeatureSet.end())
45 return It->second.str();
46
48 "unrecognised AVR version, 0x" +
49 Twine::utohexstr(EFlag));
50}
This file implements a target parser to recognise AVR hardware features.
This file defines the DenseMap class.
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:178
iterator end()
Definition DenseMap.h:81
Tagged union holding either a T or a Error.
Definition Error.h:485
static Twine utohexstr(uint64_t Val)
Definition Twine.h:385
LLVM_ABI Expected< std::string > getFeatureSetFromEFlag(const unsigned EFlag)
@ EF_AVR_ARCH_XMEGA1
Definition ELF.h:502
@ EF_AVR_ARCH_AVR35
Definition ELF.h:496
@ EF_AVR_ARCH_AVR51
Definition ELF.h:499
@ EF_AVR_ARCH_AVR1
Definition ELF.h:491
@ EF_AVR_ARCH_AVRTINY
Definition ELF.h:501
@ EF_AVR_ARCH_XMEGA3
Definition ELF.h:504
@ EF_AVR_ARCH_XMEGA5
Definition ELF.h:506
@ EF_AVR_ARCH_AVR6
Definition ELF.h:500
@ EF_AVR_ARCH_AVR2
Definition ELF.h:492
@ EF_AVR_ARCH_XMEGA2
Definition ELF.h:503
@ EF_AVR_ARCH_XMEGA7
Definition ELF.h:508
@ EF_AVR_ARCH_XMEGA6
Definition ELF.h:507
@ EF_AVR_ARCH_AVR5
Definition ELF.h:498
@ EF_AVR_ARCH_AVR25
Definition ELF.h:493
@ EF_AVR_ARCH_AVR3
Definition ELF.h:494
@ EF_AVR_ARCH_XMEGA4
Definition ELF.h:505
@ EF_AVR_ARCH_AVR31
Definition ELF.h:495
@ EF_AVR_ARCH_AVR4
Definition ELF.h:497
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition Error.h:1305
@ invalid_argument
Definition Errc.h:56