LLVM: include/llvm/Support/BCD.h Source File (original) (raw)
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_SUPPORT_BCD_H
14#define LLVM_SUPPORT_BCD_H
15
16#include <assert.h>
17#include
18#include
19
20namespace llvm {
21
22
23
24
25
27 bool IsSigned = true) {
28 assert(ByteLen >= 1 && ByteLen <= 9 && "Invalid BCD number");
29 int64_t Value = 0;
30 size_t RunLen = ByteLen - static_cast<unsigned>(IsSigned);
31 for (size_t I = 0; I < RunLen; ++I) {
32 uint8_t DecodedByteValue = ((Ptr[I] >> 4) & 0x0f) * 10 + (Ptr[I] & 0x0f);
33 Value = (Value * 100) + DecodedByteValue;
34 }
35 if (IsSigned) {
36 uint8_t DecodedByteValue = (Ptr[ByteLen - 1] >> 4) & 0x0f;
37 uint8_t Sign = Ptr[ByteLen - 1] & 0x0f;
38 Value = (Value * 10) + DecodedByteValue;
39 if (Sign == 0x0d || Sign == 0x0b)
41 }
43}
44
45template <typename ResultT, typename ValT>
48 reinterpret_cast<const uint8_t *>(&Val), sizeof(ValT), IsSigned));
49}
50
51}
52
53#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
int64_t decodePackedBCD(const uint8_t *Ptr, size_t ByteLen, bool IsSigned=true)
Definition BCD.h:26