LLVM: lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
17
18namespace llvm {
20namespace dxbc {
21
22using namespace object;
23
26 for (const Part &P : Obj.Parts)
27 if (P.Name == PartName) {
29 PartObj.Header = Obj.Header;
30 PartObj.Parts.push_back({P.Name, P.Data});
32
38 };
39
41 }
42
44 "part '%s' not found", PartName.str().c_str());
45}
46
50 Obj.Parts, [&PartName](const Part &P) { return P.Name == PartName; });
51 if (PartIter == Obj.Parts.end())
53 std::make_error_code(std::errc::invalid_argument),
54 "part '%s' not found", PartName.str().c_str());
56
57
58
59
60
61
62
63
64
65 if (PartName == "DXIL" || PartName == "STAT")
67 if (Contents.empty())
68 return createFileError(Filename, object_error::parse_failed,
69 "part '%s' is empty", PartName.str().c_str());
72 if (!BufferOrErr)
74 std::unique_ptr Buf = std::move(*BufferOrErr);
75 llvm::copy(Contents, Buf->getBufferStart());
76 if (Error E = Buf->commit())
79}
80
83 auto [SecName, FileName] = Flag.split("=");
85 return E;
86 }
87
88
92 std::tie(SectionName, FileName) = Flag.split('=');
95 return E;
96 }
97
98 std::function<bool(const Part &)> RemovePred = [](const Part &) {
99 return false;
100 };
101
103 RemovePred = [&Config](const Part &P) {
105 };
106
108 RemovePred = [&Config](const Part &P) {
109
110
112 };
113
114 if (auto E = Obj.removeParts(RemovePred))
115 return E;
116
117 Obj.recomputeHeader();
119}
120
126 if (!ObjOrErr)
129 assert(Obj && "Unable to deserialize DXContainer object");
130
132 return E;
133
138}
139
140}
141}
142}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static cl::opt< std::string > InputFilename(cl::Positional, cl::desc(""), cl::init("-"))
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
static LLVM_ABI Expected< std::unique_ptr< FileOutputBuffer > > create(StringRef FilePath, size_t Size, unsigned Flags=0)
Factory method to create an OutputBuffer object which manages a read/write buffer of the specified si...
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
bool matches(StringRef S) const
Expected< std::unique_ptr< Object > > create() const
This class implements an extremely fast bulk output stream that can only output to a stream.
static Error extractPartAsObject(StringRef PartName, StringRef OutFilename, StringRef InputFilename, const Object &Obj)
Definition DXContainerObjcopy.cpp:24
static Error dumpPartToFile(StringRef PartName, StringRef Filename, StringRef InputFilename, Object &Obj)
Definition DXContainerObjcopy.cpp:47
Error executeObjcopyOnBinary(const CommonConfig &Config, const DXContainerConfig &, object::DXContainerObjectFile &In, raw_ostream &Out)
Apply the transformations described by Config and DXContainerConfig to In and writes the result into ...
Definition DXContainerObjcopy.cpp:121
static Error handleArgs(const CommonConfig &Config, Object &Obj)
Definition DXContainerObjcopy.cpp:81
This is an optimization pass for GlobalISel generic memory operations.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
LLVM_ABI Error writeToOutput(StringRef OutputFileName, std::function< Error(raw_ostream &)> Write)
This helper creates an output stream and then passes it to Write.
OutputIt copy(R &&Range, OutputIt Out)
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
SmallVector< StringRef, 0 > ExtractSection
SmallVector< StringRef, 0 > DumpSection
::llvm::dxbc::Header Header
SmallVector< Part > Parts