<div dir="ltr"><div><div>I'm getting this incompatible type assertion when I run tblgen on my .td files:<br><br>llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::DefInit; Y = llvm::Init; typename llvm::cast_retty<X, Y*>::ret_type = llvm::DefInit*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.<br><br></div>Looks like the incompatible types are DefInit and Init. The offending line is in this definition:<br><br>class LoadOpIdx< bits<7> op,<br>                   string instr_asm,<br>                   OperandInfo info,<br>                   InstrItinClass itin=II_LOAD1_RR > <br>    //<br>    // load: r1 = mem[r2 + (r3 << sizeof(operand) ]<br>    //<br>    : FR3< op,<br>        (outs info.regClass:$r1),<br>        (ins ADDR_SHLI:$addr),  //<<-this line causes assert<br>        instr_asm # "\t\t$r1, $addr, " # info.sizeStr,<br>        [(set info.regClass:$r1, (load ADDR_SHLI:$addr))],<br>        itin > {<br>       }<br><br></div><div>The other related definitions are:<br><br>// This class provides load/store address format selection support<br>//<br>class Addr< int numArgs, string funcName, dag opInfo ><br>  : Operand<i64>,<br>    ComplexPattern< i64, numArgs, funcName, [], [SDNPWantParent] > {<br>      let MIOperandInfo = opInfo;<br>    }<br><br>let PrintMethod = "printMemOperand" in {<br>  def ADDR_RR : Addr< 2, "SelectAddrRegReg",<br>                      (ops GPRC:$base, GPRC:$offsetreg) >;<br>  def ADDR_RI : Addr< 2, "SelectAddrRegImm",<br>                      (ops GPRC:$base, i64imm:$offsetimm) >;<br>  def ADDR_SHLI : Addr< 2, "SelectAddrShlImm", <br>                      (ops GPRC:$base, ( shl GPRC:$offsetreg, (i64 3))) >;<br>}<br><br><br></div><div>If I change the LoadOpIdx definition to:<br><br>class LoadOpIdx< bits<7> op,<br>                   string instr_asm,<br>                   OperandInfo info,<br>                   InstrItinClass itin=II_LOAD1_RR > <br>    //<br>    // load: r1 = mem[r2 + (r3 << sizeof(operand) ]<br>    //<br>    : FR3< op,<br>        (outs info.regClass:$r1),<br>        (ins ADDR_RR:$addr),  //<<-this is fine<br>        instr_asm # "\t\t$r1, $addr, " # info.sizeStr,<br>        [(set info.regClass:$r1, (load ADDR_SHLI:$addr))],<br>        itin > {<br>       }<br><br></div><div>I'm not sure what the difference is between the ADDR_RR and ADDR_SHLI defs that's causing this - any ideas?  Is the DAG portion for ADDR_SHLI ok? ((ops GPRC:$base, ( shl GPRC:$offsetreg, (i64 3))))<br><br></div><div>Phil<br></div><div><br><br></div><div><br></div><div><br></div></div>