- Add a variable HasRegOp to record if the instruction has a register operand
- Enumerate all the formats with a register operand in the switch
- Add a default (unreachable) label in the switch (suggested by @reames)
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | ||
---|---|---|
1196 | It is reachable b/c the format can have an implicit register operand. If we removed this, the following command would crash echo "movabsq 0x123456789abcdef, %rax" | llvm-mc --show-encoding where movabsq is MOV64ao64 in TD |
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | ||
---|---|---|
1193 | You intend to !NumOps || !HasRegOp? |
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | ||
---|---|---|
1193 | !NumOps || !HasRegOp is same as !HasRegOp b/c !NumOps implies !HasRegOp |
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | ||
---|---|---|
1195 | How about move the check here: if (HasRegOp) llvm_unreachable("Unexpected form in emitREXPrefix!"); Then you don't need the lambda expression. |
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | ||
---|---|---|
1195 | I haven't got your idea. Lambda is used to check HighByteReg. How can we achieve the same effect with your code? |
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | ||
---|---|---|
1195 | Because you don't need to do the check and return twice with the change. Just do it in the end of the function. |
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | ||
---|---|---|
1195 | Got it, will do |
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | ||
---|---|---|
1196 | assert(!HasRegOp && "Unexpected form in emitREXPrefix!") |
You intend to !NumOps || !HasRegOp?