LLVM: lib/Frontend/Offloading/PropertySet.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

13

14using namespace llvm;

16

21 for (const auto &[CategoryName, PropSet] : PSRegistry) {

22 auto PropSetCapture = PropSet;

24 for (const auto &[PropName, PropVal] : PropSetCapture) {

25 switch (PropVal.index()) {

26 case 0:

27 J.attribute(PropName, std::get<uint32_t>(PropVal));

28 break;

29 case 1:

31 break;

32 default:

34 }

35 }

36 });

37 }

38 });

39}

40

41

42

43

44

48

51 if (std::optional<uint64_t> Val = PropValueVal.getAsUINT64())

53

54 if (std::optional Val = PropValueVal.getAsString()) {

55 std::vector Decoded;

57 return createStringErrorV("unable to base64 decode the string {0}: {1}",

60 }

61

63 PropValueVal);

64}

65

70 if (Error E = V.takeError())

71 return E;

72

74 if (!O)

76 "error while deserializing property set registry: "

77 "expected JSON object, got {0}",

78 *V);

79

80 for (const auto &[CategoryName, Value] : *O) {

82 if (!PropSetVal)

83 return createStringErrorV("error while deserializing property set {0}: "

84 "expected JSON array, got {1}",

85 CategoryName.str(), Value);

86

87 PropertySet &PropSet = Res[CategoryName.str()];

88 for (const auto &[PropName, PropValueVal] : *PropSetVal) {

92 "error while deserializing property {0} in property set {1}: {2}",

93 PropName.str(), CategoryName.str(), toString(std::move(E)));

94

95 auto [It, Inserted] =

96 PropSet.try_emplace(PropName.str(), std::move(*Prop));

97 assert(Inserted && "Property already exists in PropertySet");

98 (void)Inserted;

99 }

100 }

101 return Res;

102}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file supports working with JSON data.

Expected< PropertyValue > readPropertyValueFromJSON(const json::Value &PropValueVal)

Definition PropertySet.cpp:50

auto createStringErrorV(Ts &&...Args)

Definition PropertySet.cpp:45

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

StringRef getBuffer() const

LLVM Value Representation.

json::OStream allows writing well-formed JSON without materializing all structures as json::Value ahe...

void object(Block Contents)

Emit an object whose elements are emitted in the provided Block.

void attributeObject(llvm::StringRef Key, Block Contents)

Emit an attribute whose value is an object with attributes from the Block.

void attribute(llvm::StringRef Key, const Value &Contents)

Emit an attribute whose value is self-contained (number, vector etc).

An Object is a JSON object, which maps strings to heterogenous JSON values.

A Value is an JSON value of unknown type.

std::optional< uint64_t > getAsUINT64() const

std::optional< llvm::StringRef > getAsString() const

This class implements an extremely fast bulk output stream that can only output to a stream.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

LLVM_ABI llvm::Expected< Value > parse(llvm::StringRef JSON)

Parses the provided JSON source, or returns a ParseError.

LLVM_ABI Expected< PropertySetRegistry > readPropertiesFromJSON(MemoryBufferRef Buf)

Definition PropertySet.cpp:67

std::map< std::string, PropertySet > PropertySetRegistry

LLVM_ABI void writePropertiesToJSON(const PropertySetRegistry &P, raw_ostream &O)

Definition PropertySet.cpp:17

SmallVector< unsigned char, 0 > ByteArray

std::variant< uint32_t, ByteArray > PropertyValue

std::map< std::string, PropertyValue > PropertySet

This is an optimization pass for GlobalISel generic memory operations.

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)

std::string encodeBase64(InputBytes const &Bytes)

LLVM_ABI llvm::Error decodeBase64(llvm::StringRef Input, std::vector< char > &Output)

std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)