[llvm-dev] Obtaining llvm::Target::OpTypes from MCInstrDesc

Alexandru Guduleasa via llvm-dev llvm-dev at lists.llvm.org
Wed Nov 25 07:56:50 PST 2015


Hi all,

I've noticed that tablegen can generate a list with enums for all the
operands in InstrInfo.inc, such as:

#ifdef GET_INSTRINFO_OPERAND_TYPES_ENUM
#undef GET_INSTRINFO_OPERAND_TYPES_ENUM
namespace llvm {namespace Cpl {
namespace OpTypes {
enum OperandType {
...
  s5Imm = 10,
...

I can't figure out how to obtain this enum from a particular instruction.
What I'm trying to do is figure out the number of bits that I can use
for encoding an immediate value.

In the FoldImmediate method, assuming that I have an ADD instruction
and an immediate value, I want to change the ADD to an ADDI
instruction, but before I can do this I need to make sure the
immediate will fit.

Is there a way to obtain the OperandType for an operand?
If I know that the OperandType is 's5Imm', I know that I can encode a
signed value, in 5 bits.

Or maybe I'm trying to approach this in a wrong way.
If that's the case, any help is appreciated.

Best regards,
Alex Guduleasa


More information about the llvm-dev mailing list