[llvm] 784da8a - [ARM] Simplify the creation of escaped build attribute values
Victor Campos via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 16 03:49:38 PDT 2022
Author: Victor Campos
Date: 2022-08-16T11:49:33+01:00
New Revision: 784da8a722b3a85121162340e904d7b5172bdfc0
URL: https://github.com/llvm/llvm-project/commit/784da8a722b3a85121162340e904d7b5172bdfc0
DIFF: https://github.com/llvm/llvm-project/commit/784da8a722b3a85121162340e904d7b5172bdfc0.diff
LOG: [ARM] Simplify the creation of escaped build attribute values
There is an existing mechanism to escape strings, therefore the
functions created to escape Tag_also_compatible_with values are not
really needed. We can simply use the pre-existing utilities.
Reviewed By: pratlucas
Differential Revision: https://reviews.llvm.org/D131680
Added:
Modified:
llvm/include/llvm/Support/ARMBuildAttributes.h
llvm/lib/Support/ARMBuildAttrs.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/ARMBuildAttributes.h b/llvm/include/llvm/Support/ARMBuildAttributes.h
index 1965beed29273..35f8992ca9329 100644
--- a/llvm/include/llvm/Support/ARMBuildAttributes.h
+++ b/llvm/include/llvm/Support/ARMBuildAttributes.h
@@ -263,8 +263,6 @@ enum {
PACRETUsed = 1
};
-std::string encodeAttrTagValuePair(StringRef OriginalString);
-
} // namespace ARMBuildAttrs
} // namespace llvm
diff --git a/llvm/lib/Support/ARMBuildAttrs.cpp b/llvm/lib/Support/ARMBuildAttrs.cpp
index c39013659a275..11fe0c6d49979 100644
--- a/llvm/lib/Support/ARMBuildAttrs.cpp
+++ b/llvm/lib/Support/ARMBuildAttrs.cpp
@@ -75,40 +75,4 @@ static const TagNameItem tagData[] = {
constexpr TagNameMap ARMAttributeTags{tagData};
const TagNameMap &llvm::ARMBuildAttrs::getARMAttributeTags() {
return ARMAttributeTags;
-}
-
-static std::string getEncodedULEB128AsText(const uint8_t *Value,
- unsigned Size) {
- std::stringstream SS;
- for (unsigned i = 0; i < Size; ++i) {
- SS << "\\" << std::setfill('0') << std::setw(3) << std::oct
- << int(Value[i]);
- }
- return SS.str();
-}
-
-std::string
-llvm::ARMBuildAttrs::encodeAttrTagValuePair(StringRef OriginalString) {
- auto BytesBegin = reinterpret_cast<const uint8_t *>(OriginalString.data());
- auto BytesEnd = BytesBegin + OriginalString.size();
-
- unsigned N = 0;
- const char *Error = nullptr;
- unsigned Tag = decodeULEB128(BytesBegin, &N, BytesEnd, &Error);
- if (Error)
- report_fatal_error("Could not decode Tag value: " + Twine(Error));
-
- std::string EncodedPair = getEncodedULEB128AsText(BytesBegin, N);
- switch (Tag) {
- case ARMBuildAttrs::CPU_raw_name:
- case ARMBuildAttrs::CPU_name:
- case ARMBuildAttrs::compatibility:
- case ARMBuildAttrs::conformance:
- EncodedPair += OriginalString.substr(N);
- break;
- default:
- EncodedPair +=
- getEncodedULEB128AsText(BytesBegin + N, OriginalString.size() - N);
- }
- return EncodedPair;
-}
+}
\ No newline at end of file
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
index 24ffa0c0703fc..15188e0d59d71 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -204,7 +204,7 @@ void ARMTargetAsmStreamer::emitTextAttribute(unsigned Attribute,
default:
OS << "\t.eabi_attribute\t" << Attribute << ", \"";
if (Attribute == ARMBuildAttrs::also_compatible_with)
- OS << ARMBuildAttrs::encodeAttrTagValuePair(String);
+ OS.write_escaped(String);
else
OS << String;
OS << "\"";
More information about the llvm-commits
mailing list