[AMDGPU] Test codegen'ing True16 additions.
[llvm-project.git] / llvm / lib / Support / RISCVAttributeParser.cpp
blob7ce4b6ab161cd38c150097a264a9eb94dd733e25
1 //===-- RISCVAttributeParser.cpp - RISCV 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/RISCVAttributeParser.h"
10 #include "llvm/ADT/StringExtras.h"
12 using namespace llvm;
14 const RISCVAttributeParser::DisplayHandler
15 RISCVAttributeParser::displayRoutines[] = {
17 RISCVAttrs::ARCH,
18 &ELFAttributeParser::stringAttribute,
21 RISCVAttrs::PRIV_SPEC,
22 &ELFAttributeParser::integerAttribute,
25 RISCVAttrs::PRIV_SPEC_MINOR,
26 &ELFAttributeParser::integerAttribute,
29 RISCVAttrs::PRIV_SPEC_REVISION,
30 &ELFAttributeParser::integerAttribute,
33 RISCVAttrs::STACK_ALIGN,
34 &RISCVAttributeParser::stackAlign,
37 RISCVAttrs::UNALIGNED_ACCESS,
38 &RISCVAttributeParser::unalignedAccess,
39 }};
41 Error RISCVAttributeParser::unalignedAccess(unsigned tag) {
42 static const char *strings[] = {"No unaligned access", "Unaligned access"};
43 return parseStringAttribute("Unaligned_access", tag, ArrayRef(strings));
46 Error RISCVAttributeParser::stackAlign(unsigned tag) {
47 uint64_t value = de.getULEB128(cursor);
48 std::string description =
49 "Stack alignment is " + utostr(value) + std::string("-bytes");
50 printAttribute(tag, value, description);
51 return Error::success();
54 Error RISCVAttributeParser::handler(uint64_t tag, bool &handled) {
55 handled = false;
56 for (const auto &AH : displayRoutines) {
57 if (uint64_t(AH.attribute) == tag) {
58 if (Error e = (this->*AH.routine)(tag))
59 return e;
60 handled = true;
61 break;
65 return Error::success();