Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ pythonenv*
/clang/utils/analyzer/projects/*/RefScanBuildResults
# automodapi puts generated documentation files here.
/lldb/docs/python_api/
output_tmp/
output_tmp/
.venv
43 changes: 42 additions & 1 deletion llvm/utils/TableGen/PrinterCapstone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,47 @@ std::string getPrimaryCSOperandType(Record const *OpRec) {
return "CS_OP_REG";
else if (OperandType == "OPERAND_NM_SAVE_REGLIST")
return "CS_OP_INVALID";
// WebAssembly
else if (OperandType == "OPERAND_BASIC_BLOCK")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_LOCAL")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_GLOBAL")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_I32IMM")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_I64IMM")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_F32IMM")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_F64IMM")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_VEC_I8IMM")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_VEC_I16IMM")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_VEC_I32IMM")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_VEC_I64IMM")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_FUNCTION32")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_OFFSET32")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_OFFSET64")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_P2ALIGN")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_SIGNATURE")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_TYPEINDEX")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_TAG")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_BRLIST")
return "CS_OP_IMM";
else if (OperandType == "OPERAND_TABLE")
return "CS_OP_IMM";
else
PrintFatalNote("Unhandled OperandType: " + OperandType);
return OperandType;
Expand Down Expand Up @@ -3413,7 +3454,7 @@ void printInsnOpMapEntry(
std::move(OpDataTypes), AccessFlag});
}

if (InsOps.size() > 15) {
Copy link
Author

@OBarronCS OBarronCS Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certain WebAssembly vector instructions can have 16 operands, like v128.const that takes 16 8-bit integers as the operand.

What was the original rationale for setting the maximum count of operands to 15?

Copy link
Collaborator

@Rot127 Rot127 Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea.

You can increase it as you wish. Just save the constant in a macro named NUM_WASM_OPS, this is a naming convention required for functions in Mapping.h

Please make yourself familiar with the helper functions in Mapping.h, MathExtras.h and utils.h. So you don't implemented something twice.

Sorry, wrong repo. I thought this was the Capstone PR :D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is <capstone-repo>/Mapping.h::MAX_NO_INSN_MAP_OPS.
Can you please rename it here and add comment why it is set to this value.

if (InsOps.size() > 16) {
for (OpData const &OD : InsOps) {
PrintNote(OD.str());
OD.Rec->dump();
Expand Down
Loading