Skip to content

Commit

Permalink
Implement NZCVSelectV for selection on FPRs
Browse files Browse the repository at this point in the history
Behaves like NZCVSelect for FPRs.
  • Loading branch information
pmatos committed Sep 30, 2024
1 parent e902ad5 commit d62dd50
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
8 changes: 8 additions & 0 deletions FEXCore/Source/Interface/Core/JIT/Arm64/ALUOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,14 @@ DEF_OP(NZCVSelect) {
}
}

DEF_OP(NZCVSelectV) {
auto Op = IROp->C<IR::IROp_NZCVSelectV>();

auto cc = MapCC(Op->Cond);
const auto SubRegSize = ConvertSubRegSizePair248(IROp);
fcsel(SubRegSize.Scalar, GetVReg(Node), GetVReg(Op->TrueVal.ID()), GetVReg(Op->FalseVal.ID()), cc);
}

DEF_OP(NZCVSelectIncrement) {
auto Op = IROp->C<IR::IROp_NZCVSelectIncrement>();

Expand Down
24 changes: 19 additions & 5 deletions FEXCore/Source/Interface/IR/IR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1531,13 +1531,27 @@
]
},
"GPR = NZCVSelect OpSize:#ResultSize, CondClass:$Cond, GPR:$TrueVal, GPR:$FalseVal": {
"Desc": ["Select based on value in NZCV flags",
"op:",
"Dest = Cond ? TrueVal : FalseVal"
],
"Desc": [
"Select based on value in NZCV flags, where TrueVal and FalseVal are both GPRs.",
"op:",
"Dest = Cond ? TrueVal : FalseVal"
],
"DestSize": "ResultSize",
"EmitValidation": [
"ResultSize == FEXCore::IR::OpSize::i32Bit || ResultSize == FEXCore::IR::OpSize::i64Bit"
"ResultSize == FEXCore::IR::OpSize::i32Bit || ResultSize == FEXCore::IR::OpSize::i64Bit",
"WalkFindRegClass($TrueVal) == GPRClass && WalkFindRegClass($FalseVal) == GPRClass"
]
},
"FPR = NZCVSelectV OpSize:#ResultSize, u8:$ElementSize, CondClass:$Cond, FPR:$TrueVal, FPR:$FalseVal": {
"Desc": [
"Select based on value in NZCV flags, where TrueVal and FalseVal are both FPRs.",
"op:",
"Dest = Cond ? TrueVal : FalseVal"
],
"DestSize": "ResultSize",
"EmitValidation": [
"ResultSize == FEXCore::IR::OpSize::i32Bit || ResultSize == FEXCore::IR::OpSize::i64Bit",
"WalkFindRegClass($TrueVal) == FPRClass && WalkFindRegClass($FalseVal) == FPRClass"
]
},
"GPR = NZCVSelectIncrement OpSize:#ResultSize, CondClass:$Cond, GPR:$TrueVal, GPR:$FalseVal": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ constexpr FlagInfo ClassifyConst(IROps Op) {
case OP_STOREAF: return FlagInfo::Pack({.Write = FLAG_A, .CanEliminate = true});

case OP_NZCVSELECT:
case OP_NZCVSELECTV:
case OP_NZCVSELECTINCREMENT:
case OP_NEG:
case OP_CONDJUMP:
Expand Down Expand Up @@ -353,6 +354,11 @@ FlagInfo DeadFlagCalculationEliminination::Classify(IROp_Header* IROp) {
return FlagInfo::Pack({.Read = FlagsForCondClassType(Op->Cond)});
}

case OP_NZCVSELECTV: {
auto Op = IROp->CW<IR::IROp_NZCVSelectV>();
return FlagInfo::Pack({.Read = FlagsForCondClassType(Op->Cond)});
}

case OP_NEG: {
auto Op = IROp->CW<IR::IROp_Neg>();
return FlagInfo::Pack({.Read = FlagsForCondClassType(Op->Cond)});
Expand Down

0 comments on commit d62dd50

Please sign in to comment.