Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/Support/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,26 @@ void MappingTraits<offloadtest::Buffer>::mapping(IO &I,
I.mapRequired("Data", Arr); \
} else { \
int64_t ZeroInitSize; \
int64_t Size = 0; \
std::optional<Type> Fill; \
I.mapOptional("ZeroInitSize", ZeroInitSize, 0); \
I.mapOptional("Fill", Fill); \
I.mapOptional("Size", Size, 0); \
if (ZeroInitSize > 0) { \
B.Size = ZeroInitSize; \
B.Data.reset(new char[B.Size]); \
memset(B.Data.get(), 0, B.Size); \
break; \
} \
if (Fill.has_value()) { \
if (Size == 0) \
return I.setError("'Size' must be provided when using 'Fill'"); \
B.Size = Size * sizeof(Type); \
B.Data.reset(new char[B.Size]); \
std::fill_n(reinterpret_cast<Type *>(B.Data.get()), Size, \
Fill.value()); \
break; \
} \
llvm::SmallVector<Type, 64> Arr; \
I.mapRequired("Data", Arr); \
B.Size = Arr.size() * sizeof(Type); \
Expand All @@ -139,7 +152,8 @@ void MappingTraits<offloadtest::Buffer>::mapping(IO &I,
DATA_CASE(Float16, llvm::yaml::Hex16)
DATA_CASE(Float32, float)
DATA_CASE(Float64, double)
DATA_CASE(Bool, uint32_t) // Because sizeof(bool) is 1 but HLSL represents a bool using 4 bytes.
DATA_CASE(Bool, uint32_t) // Because sizeof(bool) is 1 but HLSL represents a
// bool using 4 bytes.
}

I.mapOptional("OutputProps", B.OutputProps);
Expand Down
Loading