[PATCH] D116464: [SPIRV 5/6] Add LegalizerInfo, InstructionSelector and utilities

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 3 16:04:12 PST 2022


MaskRay added a comment.

`LLVM_ENABLE_EXPENSIVE_CHECKS`



================
Comment at: llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h:768
+std::string getSPIRVStringOperand(const InstType &MI, unsigned int StartIndex) {
+  std::string s = ""; // Iteratively append to this string
+
----------------



================
Comment at: llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h:776
+      break;
+    uint32_t Imm = Op.getImm(); // Each i32 word is up to 4 characters
+    for (unsigned ShiftAmount = 0; ShiftAmount < 32; ShiftAmount += 8) {
----------------
May consider `assert` instead of a comment


================
Comment at: llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp:518
+  assert(I.hasOneMemOperand());
+  auto MemOp = *I.memoperands_begin();
+  auto Scope = getScope(MemOp->getSyncScopeID());
----------------
The file may have too many `auto`. See https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable


================
Comment at: llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp:26
+using namespace llvm;
+using namespace LegalizeActions;
+using namespace LegalityPredicates;
----------------



================
Comment at: llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp:27
+using namespace LegalizeActions;
+using namespace LegalityPredicates;
+
----------------



================
Comment at: llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp:29
+
+static const std::unordered_set<unsigned> TypeFoldingSupportingOpcs = {
+    TargetOpcode::G_ADD,
----------------
There is a non-trivial ctor. If you iterate it, the order is not deterministic (https://llvm.org/docs/ProgrammersManual.html).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116464



More information about the llvm-commits mailing list