[llvm] 594d0c3 - [TableGen] Fix warning when compiling generated MCCodeEmitter

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 10:35:35 PST 2021


Author: Jay Foad
Date: 2021-03-04T18:35:25Z
New Revision: 594d0c34961d3065d7abfbace5892dd42be040c9

URL: https://github.com/llvm/llvm-project/commit/594d0c34961d3065d7abfbace5892dd42be040c9
DIFF: https://github.com/llvm/llvm-project/commit/594d0c34961d3065d7abfbace5892dd42be040c9.diff

LOG: [TableGen] Fix warning when compiling generated MCCodeEmitter

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.

Differential Revision: https://reviews.llvm.org/D97942

Added: 
    

Modified: 
    llvm/utils/TableGen/CodeEmitterGen.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp
index 24cb485c032f..ffc2878d3508 100644
--- a/llvm/utils/TableGen/CodeEmitterGen.cpp
+++ b/llvm/utils/TableGen/CodeEmitterGen.cpp
@@ -481,8 +481,8 @@ void CodeEmitterGen::run(raw_ostream &o) {
       << "    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";


        


More information about the llvm-commits mailing list