[PATCH] D135190: [DirectX backend] Add analysis to collect DXILResources

Chris Bieneman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 6 12:22:41 PDT 2022


beanz added inline comments.


================
Comment at: llvm/lib/Target/DirectX/DXILResource.cpp:70
+         "invalid component type");
+  return TypeKindNames[(unsigned)CompType];
+}
----------------
Instead of a static array if you use a switch statement we don't need the asserts above.


================
Comment at: llvm/lib/Target/DirectX/DXILResource.cpp:101
+      "buf",     "rawbuf",  "structbuf", "cbuffer",      "sampler",
+      "tbuffer", "ras",     "fbtex2d",   "fbtex2darray",
+  };
----------------
Using a switch here makes sense too.


================
Comment at: llvm/lib/Target/DirectX/DXILResource.cpp:176
+void UAVResource::print(raw_ostream &OS) const {
+  const StringRef comment = ";";
+  OS << comment << " " << left_justify(Name, 31);
----------------
"comment" is a lot longer to write than just adding a `;` to the front of the lines, and just including it in the string avoids double-calling `operator<<`


================
Comment at: llvm/lib/Target/DirectX/DXILResource.cpp:292
+void Resources::print(raw_ostream &O) const {
+  const StringRef comment = ";";
+  O << comment << "\n"
----------------
here too


================
Comment at: llvm/lib/Target/DirectX/DXILResource.h:83
 
+  static StringRef getResourceDimName(Kinds Kind);
+  static void printResourceDimension(Kinds Kind, unsigned alignment,
----------------



================
Comment at: llvm/lib/Target/DirectX/DXILResource.h:84
+  static StringRef getResourceDimName(Kinds Kind);
+  static void printResourceDimension(Kinds Kind, unsigned alignment,
+                                     raw_ostream &OS, bool SRV = false,
----------------



================
Comment at: llvm/lib/Target/DirectX/DXILResource.h:115
+  static StringRef getComponentTypeName(ComponentType CompType);
+  static void printResourceFormat(Kinds Kind, ComponentType CompType,
+                                  unsigned alignment, raw_ostream &OS);
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135190/new/

https://reviews.llvm.org/D135190



More information about the llvm-commits mailing list