[LLVMdev] Selection Condition Codes
Villmow, Micah
Micah.Villmow at amd.com
Thu Sep 11 18:14:41 PDT 2008
I am attempting to lower the selectCC instruction to the instruction set
of the backend I'm working on and I cannot seem to find a way to
correctly implement this instruction. I know how this instruction should
get implemented; I just have yet to find a way to do it. I want the
select_cc instruction to be lowered into a comparison followed by a
conditional move. I've attempted to use a custom rule pasted below, but
it keeps giving me an error about the first argument.
What I attempted is as follows:
class InstFormat<dag outs, dag ins, string asmstr, list<dag> pattern>
: Instruction {
let Namespace = "Inst";
dag OutOperandList = outs;
dag InOperandList = ins;
let Pattern = pattern;
let AsmString = asmstr;
}
def SDTGenTernaryOp : SDTypeProfile<1, 3, [ SDTCisSameAs<0,
1>,SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3> ]>;
def cmov_logical : SDNode<"INSTISD::CMOVLOG", SDTGenTernaryOp>;
let PrintMethod = "printCCOperand" in
def CCOp : Operand<i32>;
def CMOVLOG : InstFormat<(outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS,
GPR:$TVAL, GPR:$FVAL, CCOp:$cond),
"$cond $LHS, $LHS, $RHS\ncmov_logical
$dst, $LHS, $TVAL, $FVAL",
[(set GPR:$dst, (selectcc GPR:$LHS,
GPR:$RHS, GPR:$TVAL, GPR:$FVAL, CCOp:$cond))]>;
Maybe I'm approaching this from the wrong way, but I don't think this
transformation should be that difficult.
Basically I want dst = select $LHS, $RHS, $TVAL, $FVAL, $condOp to be
transformed into
$condOp tmp, $LHS, $RHS
cmov_logical dst, tmp, $TVAL, $FVAL
My attempt at doing so with a custom OperationAction also failed. So,
what would I need to do to figure out how to implement this correctly?
Is there any place you can point me to which shows how to go from a
single instruction to multiple consecutive instructions? A function that
I can study would be nice since my problem is even though I can look at
the other backends, I don't completely understand everything that is
going on so I probably overlooked this already.
Thanks,
Micah Villmow
Systems Engineer
Advanced Technology & Performance
Advanced Micro Devices Inc.
4555 Great America Pkwy,
Santa Clara, CA. 95054
P: 408-572-6219
F: 408-572-6596
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080911/94270692/attachment.html>
More information about the llvm-dev
mailing list