LLVM 22.0.0git
RISCVAttributeParser.cpp
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
8
11
12using namespace llvm;
13
14const RISCVAttributeParser::DisplayHandler
15 RISCVAttributeParser::displayRoutines[] = {
16 {
19 },
20 {
23 },
24 {
27 },
28 {
31 },
32 {
34 &RISCVAttributeParser::stackAlign,
35 },
36 {
38 &RISCVAttributeParser::unalignedAccess,
39 },
40 {
42 &RISCVAttributeParser::atomicAbi,
43 },
44};
45
46Error RISCVAttributeParser::atomicAbi(unsigned Tag) {
47 uint64_t Value = de.getULEB128(cursor);
48 printAttribute(Tag, Value, "Atomic ABI is " + utostr(Value));
49 return Error::success();
50}
51
52Error RISCVAttributeParser::unalignedAccess(unsigned tag) {
53 static const char *const strings[] = {"No unaligned access",
54 "Unaligned access"};
55 return parseStringAttribute("Unaligned_access", tag, ArrayRef(strings));
56}
57
58Error RISCVAttributeParser::stackAlign(unsigned tag) {
59 uint64_t value = de.getULEB128(cursor);
60 std::string description =
61 "Stack alignment is " + utostr(value) + std::string("-bytes");
62 printAttribute(tag, value, description);
63 return Error::success();
64}
65
66Error RISCVAttributeParser::handler(uint64_t tag, bool &handled) {
67 handled = false;
68 for (const auto &AH : displayRoutines) {
69 if (uint64_t(AH.attribute) == tag) {
70 if (Error e = (this->*AH.routine)(tag))
71 return e;
72 handled = true;
73 break;
74 }
75 }
76
77 return Error::success();
78}
This file contains some functions that are useful when dealing with strings.
void printAttribute(unsigned tag, unsigned value, StringRef valueDesc)
Error parseStringAttribute(const char *name, unsigned tag, ArrayRef< const char * > strings)
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
constexpr double e
Definition MathExtras.h:47
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
std::string utostr(uint64_t X, bool isNeg=false)
ArrayRef(const T &OneElt) -> ArrayRef< T >