[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / Support / CSKYAttributeParser.cpp
blob7f39a78fe08b4dfcb8365bf9cc56483e10b990df
1 //===-- CSKYAttributeParser.cpp - CSKY 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/CSKYAttributeParser.h"
10 #include "llvm/ADT/StringExtras.h"
11 #include "llvm/Support/Errc.h"
13 using namespace llvm;
15 const CSKYAttributeParser::DisplayHandler
16 CSKYAttributeParser::displayRoutines[] = {
18 CSKYAttrs::CSKY_ARCH_NAME,
19 &ELFAttributeParser::stringAttribute,
22 CSKYAttrs::CSKY_CPU_NAME,
23 &ELFAttributeParser::stringAttribute,
26 CSKYAttrs::CSKY_ISA_FLAGS,
27 &ELFAttributeParser::integerAttribute,
30 CSKYAttrs::CSKY_ISA_EXT_FLAGS,
31 &ELFAttributeParser::integerAttribute,
34 CSKYAttrs::CSKY_DSP_VERSION,
35 &CSKYAttributeParser::dspVersion,
38 CSKYAttrs::CSKY_VDSP_VERSION,
39 &CSKYAttributeParser::vdspVersion,
42 CSKYAttrs::CSKY_FPU_VERSION,
43 &CSKYAttributeParser::fpuVersion,
46 CSKYAttrs::CSKY_FPU_ABI,
47 &CSKYAttributeParser::fpuABI,
50 CSKYAttrs::CSKY_FPU_ROUNDING,
51 &CSKYAttributeParser::fpuRounding,
54 CSKYAttrs::CSKY_FPU_DENORMAL,
55 &CSKYAttributeParser::fpuDenormal,
58 CSKYAttrs::CSKY_FPU_EXCEPTION,
59 &CSKYAttributeParser::fpuException,
62 CSKYAttrs::CSKY_FPU_NUMBER_MODULE,
63 &ELFAttributeParser::stringAttribute,
66 CSKYAttrs::CSKY_FPU_HARDFP,
67 &CSKYAttributeParser::fpuHardFP,
68 }};
70 Error CSKYAttributeParser::handler(uint64_t tag, bool &handled) {
71 handled = false;
72 for (const auto &AH : displayRoutines) {
73 if (uint64_t(AH.attribute) == tag) {
74 if (Error e = (this->*AH.routine)(tag))
75 return e;
76 handled = true;
77 break;
81 return Error::success();
84 Error CSKYAttributeParser::dspVersion(unsigned tag) {
85 static const char *strings[] = {"Error", "DSP Extension", "DSP 2.0"};
86 return parseStringAttribute("Tag_CSKY_DSP_VERSION", tag, ArrayRef(strings));
89 Error CSKYAttributeParser::vdspVersion(unsigned tag) {
90 static const char *strings[] = {"Error", "VDSP Version 1", "VDSP Version 2"};
91 return parseStringAttribute("Tag_CSKY_VDSP_VERSION", tag, ArrayRef(strings));
94 Error CSKYAttributeParser::fpuVersion(unsigned tag) {
95 static const char *strings[] = {"Error", "FPU Version 1", "FPU Version 2",
96 "FPU Version 3"};
97 return parseStringAttribute("Tag_CSKY_FPU_VERSION", tag, ArrayRef(strings));
100 Error CSKYAttributeParser::fpuABI(unsigned tag) {
101 static const char *strings[] = {"Error", "Soft", "SoftFP", "Hard"};
102 return parseStringAttribute("Tag_CSKY_FPU_ABI", tag, ArrayRef(strings));
105 Error CSKYAttributeParser::fpuRounding(unsigned tag) {
106 static const char *strings[] = {"None", "Needed"};
107 return parseStringAttribute("Tag_CSKY_FPU_ROUNDING", tag, ArrayRef(strings));
110 Error CSKYAttributeParser::fpuDenormal(unsigned tag) {
111 static const char *strings[] = {"None", "Needed"};
112 return parseStringAttribute("Tag_CSKY_FPU_DENORMAL", tag, ArrayRef(strings));
115 Error CSKYAttributeParser::fpuException(unsigned tag) {
116 static const char *strings[] = {"None", "Needed"};
117 return parseStringAttribute("Tag_CSKY_FPU_EXCEPTION", tag, ArrayRef(strings));
120 Error CSKYAttributeParser::fpuHardFP(unsigned tag) {
121 uint64_t value = de.getULEB128(cursor);
122 ListSeparator LS(" ");
124 std::string description;
126 if (value & 0x1) {
127 description += LS;
128 description += "Half";
130 if ((value >> 1) & 0x1) {
131 description += LS;
132 description += "Single";
134 if ((value >> 2) & 0x1) {
135 description += LS;
136 description += "Double";
139 if (description.empty()) {
140 printAttribute(tag, value, "");
141 return createStringError(errc::invalid_argument,
142 "unknown Tag_CSKY_FPU_HARDFP value: " +
143 Twine(value));
146 printAttribute(tag, value, description);
147 return Error::success();