Type inference in TableGen DAG patterns

Given the following definitions:

def SDT_XSTGMVINI : SDTypeProfile<1, 1, [SDTCisInt<0>]>;
def XSTGMVINI : SDNode<“XSTGISD::MVINI”, SDT_XSTGMVINI>;

def SDT_RELADDR : SDTypeProfile<1, 2, >;
def XSTGRELADDR : SDNode<“XSTGISD::RELADDR”, SDT_RELADDR>;

let Constraints = “$dst = $addr”, Uses= [GRP] in {
def RelAddr : XSTGPseudo< (outs GPRC:$dst),
//(ins GPRC:$spoff, GPRC:$addr),
(ins i64imm:$spoff, i64imm:$addr),
“! RELADDR $spoff, $dst”,
[(set GPRC:$dst, (XSTGRELADDR i64:$spoff,
(XSTGMVINI i64:$addr)
)
)]>;
}

When I compile I get:
XSTGInstrInfo.td:903:3: error: In RelAddr: Could not infer all types in pattern!
def RelAddr : XSTGPseudo< (outs GPRC:$dst),
^

I thought that perhaps I could explicitly add the type in like this:

let Constraints = “$dst = $addr”, Uses= [GRP] in {
def RelAddr : XSTGPseudo< (outs GPRC:$dst),
//(ins GPRC:$spoff, GPRC:$addr),
(ins i64imm:$spoff, i64imm:$addr),
“! RELADDR $spoff, $dst”,
[(set GPRC:$dst, (XSTGRELADDR i64:$spoff,
i64:(XSTGMVINI i64:$addr)
)
)]>;
}

But that causes another problem:

XSTGInstrInfo.td:908:73: error: expected variable name in dag literal
i64:(XSTGMVINI i64:$addr)
^

How can this be resolved?

Phil

Try (i64 (XSTGMVINI ...))

-Krzysztof

Thanks, that worked. So that’s basically a cast, then?

I have another question about expanding that pseudo op, but I’ll post it separately.

Phil

Yes.

-Krzysztof

Actually, it's more like "explicitly stating the type". The type here has to agree with the types that tablegen could infer itself.

-Krzysztof