[LLVMdev] DAGOperand problem

Matt Arsenault arsenm2 at gmail.com
Tue Nov 4 12:10:49 PST 2014


Hi,

I'm having trouble trying to use a DAGOperand to abstract between a RegisterClass and a custom Operand.

I have something like this:

class SrcModifiers<ValueType vt,
                   RegisterClass regclass> : OperandWithDefaultOps<vt, (ops (i32 0))> {
  let MIOperandInfo = (ops regclass, i32imm:$modifiers);
}

and I would like to factor instruction definitions to use this or just a register class for an operand. I would like to do something like:
 
 field DAGOperand Src2Op64 = !if(HasModifiers, SrcModifiers<Src2VT, Src2RC>, Src2RC);

However I'm getting an error I don't understand just from the use of the custom operand. Reducing this to just

  DAGOperand Src2Op64 = SrcModifiers<Src2VT, Src2RC64>;

gives me this error (twice):
 error: Record `anonymous_690', field `Type' does not have a def initializer!
  DAGOperand Src2Op64 = SrcModifiers<Src2VT, Src2RC64>;
                                           ^

Type is a field of Operand which is theoretically set by the vt parameter to Operand. DAGOperand is also the superclass without Type, so I don’t know why it would care about it either. Why this doesn't work? Is this a bug in tablegen?

Thanks,

Matt



More information about the llvm-dev mailing list