Go to the documentation of this file.
20 char *&ResultPtr,
const UTF8 *&ErrorPtr) {
21 assert(WideCharWidth == 1 || WideCharWidth == 2 || WideCharWidth == 4);
24 if (WideCharWidth == 1) {
31 ResultPtr +=
Source.size();
33 }
else if (WideCharWidth == 2) {
37 UTF16 *targetStart =
reinterpret_cast<UTF16*
>(ResultPtr);
40 &sourceStart, sourceStart +
Source.size(),
41 &targetStart, targetStart +
Source.size(), flags);
43 ResultPtr =
reinterpret_cast<char*
>(targetStart);
45 ErrorPtr = sourceStart;
46 }
else if (WideCharWidth == 4) {
50 UTF32 *targetStart =
reinterpret_cast<UTF32*
>(ResultPtr);
53 &sourceStart, sourceStart +
Source.size(),
54 &targetStart, targetStart +
Source.size(), flags);
56 ResultPtr =
reinterpret_cast<char*
>(targetStart);
58 ErrorPtr = sourceStart;
61 &&
"ConvertUTF8toUTFXX exhausted target buffer");
67 const UTF32 *SourceEnd = SourceStart + 1;
68 UTF8 *TargetStart =
reinterpret_cast<UTF8 *
>(ResultPtr);
69 UTF8 *TargetEnd = TargetStart + 4;
71 &TargetStart, TargetEnd,
76 ResultPtr =
reinterpret_cast<char*
>(TargetStart);
81 return (
S.size() >= 2 &&
82 ((
S[0] ==
'\xff' &&
S[1] ==
'\xfe') ||
83 (
S[0] ==
'\xfe' &&
S[1] ==
'\xff')));
90 if (SrcBytes.
size() % 2)
98 const UTF16 *SrcEnd =
reinterpret_cast<const UTF16 *
>(SrcBytes.
end());
103 std::vector<UTF16> ByteSwapped;
105 ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
106 for (
unsigned I = 0,
E = ByteSwapped.size();
I !=
E; ++
I)
108 Src = &ByteSwapped[0];
109 SrcEnd = &ByteSwapped[ByteSwapped.size() - 1] + 1;
119 UTF8 *Dst =
reinterpret_cast<UTF8 *
>(&Out[0]);
120 UTF8 *DstEnd = Dst + Out.size();
131 Out.resize(
reinterpret_cast<char *
>(Dst) - &Out[0]);
149 if (SrcUTF8.
empty()) {
150 DstUTF16.push_back(0);
155 const UTF8 *Src =
reinterpret_cast<const UTF8 *
>(SrcUTF8.
begin());
156 const UTF8 *SrcEnd =
reinterpret_cast<const UTF8 *
>(SrcUTF8.
end());
164 UTF16 *Dst = &DstUTF16[0];
165 UTF16 *DstEnd = Dst + DstUTF16.size();
176 DstUTF16.
resize(Dst - &DstUTF16[0]);
177 DstUTF16.push_back(0);
182 static_assert(
sizeof(
wchar_t) == 1 ||
sizeof(
wchar_t) == 2 ||
183 sizeof(
wchar_t) == 4,
184 "Expected wchar_t to be 1, 2, or 4 bytes");
186 template <
typename TResult>
192 Result.resize(
Source.size() + 1);
193 char *ResultPtr =
reinterpret_cast<char *
>(&Result[0]);
194 const UTF8 *ErrorPtr;
199 Result.resize(
reinterpret_cast<wchar_t *
>(ResultPtr) - &Result[0]);
216 if (
sizeof(
wchar_t) == 1) {
217 const UTF8 *Start =
reinterpret_cast<const UTF8 *
>(
Source.data());
222 Result.resize(
Source.size());
225 }
else if (
sizeof(
wchar_t) == 2) {
230 }
else if (
sizeof(
wchar_t) == 4) {
235 UTF8 *ResultPtr =
reinterpret_cast<UTF8 *
>(&Result[0]);
236 UTF8 *ResultEnd =
reinterpret_cast<UTF8 *
>(&Result[0] + Result.size());
239 Result.resize(
reinterpret_cast<char *
>(ResultPtr) - &Result[0]);
247 "Control should never reach this point; see static_assert further up");
This class represents lattice values for constants.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
#define UNI_UTF16_BYTE_ORDER_MARK_NATIVE
bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr)
Convert an Unicode code point to UTF8 sequence.
bool hasUTF16ByteOrderMark(ArrayRef< char > SrcBytes)
Returns true if a blob of text starts with a UTF-16 big or little endian byte order mark.
#define UNI_MAX_UTF8_BYTES_PER_CODE_POINT
bool empty() const
empty - Check if the array is empty.
It looks like we only need to define PPCfmarto for these because according to these instructions perform RTO on fma s result
ConversionResult ConvertUTF32toUTF8(const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED
bool convertUTF16ToUTF8String(ArrayRef< char > SrcBytes, std::string &Out)
Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
uint16_t ByteSwap_16(uint16_t value)
ByteSwap_16 - This function returns a byte-swapped representation of the 16-bit argument.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
ConversionResult ConvertUTF8toUTF32(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
Convert a partial UTF8 sequence to UTF32.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef - Represent a constant reference to a string, i.e.
bool convertWideToUTF8(const std::wstring &Source, std::string &Result)
Converts a std::wstring to a UTF-8 encoded std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
bool convertUTF8ToUTF16String(StringRef SrcUTF8, SmallVectorImpl< UTF16 > &DstUTF16)
Converts a UTF-8 string into a UTF-16 string with native endianness.
ConversionResult ConvertUTF8toUTF16(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
ConversionResult ConvertUTF16toUTF8(const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
static bool ConvertUTF8toWideInternal(llvm::StringRef Source, TResult &Result)
Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd)
bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source, char *&ResultPtr, const UTF8 *&ErrorPtr)
Convert an UTF8 StringRef to UTF8, UTF16, or UTF32 depending on WideCharWidth.
size_t size() const
size - Get the array size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
LLVM_NODISCARD size_t size() const
size - Get the string size.