summaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/lib/Support/RISCVAttributeParser.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/llvm12/lib/Support/RISCVAttributeParser.cpp
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/llvm12/lib/Support/RISCVAttributeParser.cpp')
-rw-r--r--contrib/libs/llvm12/lib/Support/RISCVAttributeParser.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/contrib/libs/llvm12/lib/Support/RISCVAttributeParser.cpp b/contrib/libs/llvm12/lib/Support/RISCVAttributeParser.cpp
new file mode 100644
index 00000000000..393861c73a4
--- /dev/null
+++ b/contrib/libs/llvm12/lib/Support/RISCVAttributeParser.cpp
@@ -0,0 +1,67 @@
+//===-- RISCVAttributeParser.cpp - RISCV Attribute Parser -----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/RISCVAttributeParser.h"
+#include "llvm/ADT/StringExtras.h"
+
+using namespace llvm;
+
+const RISCVAttributeParser::DisplayHandler
+ RISCVAttributeParser::displayRoutines[] = {
+ {
+ RISCVAttrs::ARCH,
+ &ELFAttributeParser::stringAttribute,
+ },
+ {
+ RISCVAttrs::PRIV_SPEC,
+ &ELFAttributeParser::integerAttribute,
+ },
+ {
+ RISCVAttrs::PRIV_SPEC_MINOR,
+ &ELFAttributeParser::integerAttribute,
+ },
+ {
+ RISCVAttrs::PRIV_SPEC_REVISION,
+ &ELFAttributeParser::integerAttribute,
+ },
+ {
+ RISCVAttrs::STACK_ALIGN,
+ &RISCVAttributeParser::stackAlign,
+ },
+ {
+ RISCVAttrs::UNALIGNED_ACCESS,
+ &RISCVAttributeParser::unalignedAccess,
+ }};
+
+Error RISCVAttributeParser::unalignedAccess(unsigned tag) {
+ static const char *strings[] = {"No unaligned access", "Unaligned access"};
+ return parseStringAttribute("Unaligned_access", tag, makeArrayRef(strings));
+}
+
+Error RISCVAttributeParser::stackAlign(unsigned tag) {
+ uint64_t value = de.getULEB128(cursor);
+ std::string description =
+ "Stack alignment is " + utostr(value) + std::string("-bytes");
+ printAttribute(tag, value, description);
+ return Error::success();
+}
+
+Error RISCVAttributeParser::handler(uint64_t tag, bool &handled) {
+ handled = false;
+ for (unsigned AHI = 0, AHE = array_lengthof(displayRoutines); AHI != AHE;
+ ++AHI) {
+ if (uint64_t(displayRoutines[AHI].attribute) == tag) {
+ if (Error e = (this->*displayRoutines[AHI].routine)(tag))
+ return e;
+ handled = true;
+ break;
+ }
+ }
+
+ return Error::success();
+}