[PATCH] D97942: [TableGen] Fix warning when compiling generated MCCodeEmitter

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 06:02:56 PST 2021


foad created this revision.
foad added reviewers: jmolloy, dsanders, Joe_Nash, Paul-C-Anagnostopoulos.
foad requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This fixes an instance of:
warning: cast from 'const unsigned long *' to 'unsigned char *' drops const qualifier [-Wcast-qual]
when compiling the generated MCCodeEmitter for an out-of-tree target
that uses the optional support for instruction widths > 64 bits.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97942

Files:
  llvm/utils/TableGen/CodeEmitterGen.cpp


Index: llvm/utils/TableGen/CodeEmitterGen.cpp
===================================================================
--- llvm/utils/TableGen/CodeEmitterGen.cpp
+++ llvm/utils/TableGen/CodeEmitterGen.cpp
@@ -481,8 +481,8 @@
       << "    Inst = Inst.zext(" << BitWidth << ");\n"
       << "  if (Scratch.getBitWidth() != " << BitWidth << ")\n"
       << "    Scratch = Scratch.zext(" << BitWidth << ");\n"
-      << "  LoadIntFromMemory(Inst, (uint8_t *)&InstBits[opcode * " << NumWords
-      << "], " << NumBytes << ");\n"
+      << "  LoadIntFromMemory(Inst, (const uint8_t *)&InstBits[opcode * "
+      << NumWords << "], " << NumBytes << ");\n"
       << "  APInt &Value = Inst;\n"
       << "  APInt &op = Scratch;\n"
       << "  switch (opcode) {\n";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97942.328144.patch
Type: text/x-patch
Size: 756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/f1499909/attachment.bin>


More information about the llvm-commits mailing list