[Support] Remove unused includes (NFC) (#116752)
[llvm-project.git] / llvm / lib / Support / MSP430AttributeParser.cpp
blobbfc69cb2bb3ce23f48640a90884632464355f9fa
1 //===-- MSP430AttributeParser.cpp - MSP430 Attribute Parser ---------------===//
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 "llvm/Support/MSP430AttributeParser.h"
10 #include "llvm/ADT/ArrayRef.h"
12 using namespace llvm;
13 using namespace llvm::MSP430Attrs;
15 constexpr std::array<MSP430AttributeParser::DisplayHandler, 4>
16 MSP430AttributeParser::DisplayRoutines{
17 {{MSP430Attrs::TagISA, &MSP430AttributeParser::parseISA},
18 {MSP430Attrs::TagCodeModel, &MSP430AttributeParser::parseCodeModel},
19 {MSP430Attrs::TagDataModel, &MSP430AttributeParser::parseDataModel},
20 {MSP430Attrs::TagEnumSize, &MSP430AttributeParser::parseEnumSize}}};
22 Error MSP430AttributeParser::parseISA(AttrType Tag) {
23 static const char *const StringVals[] = {"None", "MSP430", "MSP430X"};
24 return parseStringAttribute("ISA", Tag, ArrayRef(StringVals));
27 Error MSP430AttributeParser::parseCodeModel(AttrType Tag) {
28 static const char *const StringVals[] = {"None", "Small", "Large"};
29 return parseStringAttribute("Code Model", Tag, ArrayRef(StringVals));
32 Error MSP430AttributeParser::parseDataModel(AttrType Tag) {
33 static const char *const StringVals[] = {"None", "Small", "Large",
34 "Restricted"};
35 return parseStringAttribute("Data Model", Tag, ArrayRef(StringVals));
38 Error MSP430AttributeParser::parseEnumSize(AttrType Tag) {
39 static const char *const StringVals[] = {"None", "Small", "Integer",
40 "Don't Care"};
41 return parseStringAttribute("Enum Size", Tag, ArrayRef(StringVals));
44 Error MSP430AttributeParser::handler(uint64_t Tag, bool &Handled) {
45 Handled = false;
46 for (const DisplayHandler &Disp : DisplayRoutines) {
47 if (uint64_t(Disp.Attribute) != Tag)
48 continue;
49 if (Error E = (this->*Disp.Routine)(static_cast<AttrType>(Tag)))
50 return E;
51 Handled = true;
52 break;
54 return Error::success();