diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index e36d92c6..08a6a990 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -111,13 +111,26 @@ void MappingTraits::mapping(IO &I, I.mapRequired("Data", Arr); \ } else { \ int64_t ZeroInitSize; \ + int64_t Size = 0; \ + std::optional 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(B.Data.get()), Size, \ + Fill.value()); \ + break; \ + } \ llvm::SmallVector Arr; \ I.mapRequired("Data", Arr); \ B.Size = Arr.size() * sizeof(Type); \ @@ -139,7 +152,8 @@ void MappingTraits::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);