LLVM 19.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
41Error RISCVAttributeParser::unalignedAccess(unsigned tag) {
42 static const char *strings[] = {"No unaligned access", "Unaligned access"};
43 return parseStringAttribute("Unaligned_access", tag, ArrayRef(strings));
44}
45
46Error RISCVAttributeParser::stackAlign(unsigned tag) {
48 std::string description =
49 "Stack alignment is " + utostr(value) + std::string("-bytes");
50 printAttribute(tag, value, description);
51 return Error::success();
52}
53
54Error 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;
62 }
63 }
64
65 return Error::success();
66}
Given that RA is a live value
This file contains some functions that are useful when dealing with strings.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
uint64_t getULEB128(uint64_t *offset_ptr, llvm::Error *Err=nullptr) const
Extract a unsigned LEB128 value from *offset_ptr.
Error integerAttribute(unsigned tag)
DataExtractor::Cursor cursor
Error stringAttribute(unsigned tag)
Error parseStringAttribute(const char *name, unsigned tag, ArrayRef< const char * > strings)
void printAttribute(unsigned tag, unsigned value, StringRef valueDesc)
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:334
constexpr double e
Definition: MathExtras.h:31
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18