lower 64 bits constant

Hi, All,

I want to lower 64 Bits constant such as ‘long’ and ‘double’. So I define them like this:

def CONSTI64 : InstFOO<(outs GRWideRegs:$dst),
(ins i64imm:$src),
“const-long $dst, $src”,
[(set (i64 GRWideRegs:$dst), imm:$src)]>{
let isMoveImm = 1;
}

def CONSTF64 : InstFOO<(outs GRWideRegs:$dst),
(ins f64imm:$src),
“const-double $dst, $src”,
[(set (f64 GRWideRegs:$dst), fpimm:$src)]>{
let isMoveImm = 1;
}

GRWideRegs can be f64 and i64. However, the ‘const-long’ works while the ‘const-double’ doesn’t work. From the -debug log, it seems “f64 = ConstantFP” is replaced by “f64,ch = load” and this is where the error happens. Can anyone tell me why this happens and how to make this work?

Any suggestion is appreciated.

Regards,

Xiangyang

It's probably being lowered to a litpool load by default. You need to
call "setOperationAction(ISD::ConstantFP, MVT::f64, Legal)" in
ISelLowering.cpp.

Cheers.

Tim.

Is f64 a valid type for GRWideRegs?

-Krzysztof

Thanks, Tim.

“setOperationAction(ISD::ConstantFP, MVT::f64, Legal)” and some modification of “LowerOperand” and “printOperand” make this lowering “double” works.

Regards,

Xiangyang

Thanks for your reply.

Yes, f64 is valid type. “setOperationAction(ISD::ConstantFP, MVT::f64, Legal)” does the trick.

Regards,

Xiangyang