Skip to content

Commit 70ae109

Browse files
committed
[X86] X86ISelLowering.cpp - add clang-format on/off tags around 'compressed' switch code. NFC.
Stop clang-format trying to expand manually compressed lookup switch() code - if it still fits into 80col, then keep it to a single line instead of expanding across multiple lines each.
1 parent 04d20b1 commit 70ae109

File tree

1 file changed

+60
-10
lines changed

1 file changed

+60
-10
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,6 +2730,7 @@ static bool isX86CCSigned(unsigned X86CC) {
27302730

27312731
static X86::CondCode TranslateIntegerX86CC(ISD::CondCode SetCCOpcode) {
27322732
switch (SetCCOpcode) {
2733+
// clang-format off
27332734
default: llvm_unreachable("Invalid integer condition!");
27342735
case ISD::SETEQ: return X86::COND_E;
27352736
case ISD::SETGT: return X86::COND_G;
@@ -2741,6 +2742,7 @@ static X86::CondCode TranslateIntegerX86CC(ISD::CondCode SetCCOpcode) {
27412742
case ISD::SETUGT: return X86::COND_A;
27422743
case ISD::SETULE: return X86::COND_BE;
27432744
case ISD::SETUGE: return X86::COND_AE;
2745+
// clang-format on
27442746
}
27452747
}
27462748

@@ -2801,6 +2803,7 @@ static X86::CondCode TranslateX86CC(ISD::CondCode SetCCOpcode, const SDLoc &DL,
28012803
// 1 | 0 | 0 | X == Y
28022804
// 1 | 1 | 1 | unordered
28032805
switch (SetCCOpcode) {
2806+
// clang-format off
28042807
default: llvm_unreachable("Condcode should be pre-legalized away");
28052808
case ISD::SETUEQ:
28062809
case ISD::SETEQ: return X86::COND_E;
@@ -2822,6 +2825,7 @@ static X86::CondCode TranslateX86CC(ISD::CondCode SetCCOpcode, const SDLoc &DL,
28222825
case ISD::SETO: return X86::COND_NP;
28232826
case ISD::SETOEQ:
28242827
case ISD::SETUNE: return X86::COND_INVALID;
2828+
// clang-format on
28252829
}
28262830
}
28272831

@@ -7997,11 +8001,13 @@ static bool isHopBuildVector(const BuildVectorSDNode *BV, SelectionDAG &DAG,
79978001
if (HOpcode == ISD::DELETED_NODE) {
79988002
GenericOpcode = Op.getOpcode();
79998003
switch (GenericOpcode) {
8004+
// clang-format off
80008005
case ISD::ADD: HOpcode = X86ISD::HADD; break;
80018006
case ISD::SUB: HOpcode = X86ISD::HSUB; break;
80028007
case ISD::FADD: HOpcode = X86ISD::FHADD; break;
80038008
case ISD::FSUB: HOpcode = X86ISD::FHSUB; break;
80048009
default: return false;
8010+
// clang-format on
80058011
}
80068012
}
80078013

@@ -21575,12 +21581,14 @@ static SDValue lowerAddSubToHorizontalOp(SDValue Op, SelectionDAG &DAG,
2157521581
// TODO: Allow commuted (f)sub by negating the result of (F)HSUB?
2157621582
unsigned HOpcode;
2157721583
switch (Op.getOpcode()) {
21578-
case ISD::ADD: HOpcode = X86ISD::HADD; break;
21579-
case ISD::SUB: HOpcode = X86ISD::HSUB; break;
21580-
case ISD::FADD: HOpcode = X86ISD::FHADD; break;
21581-
case ISD::FSUB: HOpcode = X86ISD::FHSUB; break;
21582-
default:
21583-
llvm_unreachable("Trying to lower unsupported opcode to horizontal op");
21584+
// clang-format off
21585+
case ISD::ADD: HOpcode = X86ISD::HADD; break;
21586+
case ISD::SUB: HOpcode = X86ISD::HSUB; break;
21587+
case ISD::FADD: HOpcode = X86ISD::FHADD; break;
21588+
case ISD::FSUB: HOpcode = X86ISD::FHSUB; break;
21589+
default:
21590+
llvm_unreachable("Trying to lower unsupported opcode to horizontal op");
21591+
// clang-format on
2158421592
}
2158521593
unsigned LExtIndex = LHS.getConstantOperandVal(1);
2158621594
unsigned RExtIndex = RHS.getConstantOperandVal(1);
@@ -22482,12 +22490,14 @@ static SDValue EmitTest(SDValue Op, unsigned X86CC, const SDLoc &dl,
2248222490

2248322491
// Otherwise use a regular EFLAGS-setting instruction.
2248422492
switch (ArithOp.getOpcode()) {
22493+
// clang-format off
2248522494
default: llvm_unreachable("unexpected operator!");
2248622495
case ISD::ADD: Opcode = X86ISD::ADD; break;
2248722496
case ISD::SUB: Opcode = X86ISD::SUB; break;
2248822497
case ISD::XOR: Opcode = X86ISD::XOR; break;
2248922498
case ISD::AND: Opcode = X86ISD::AND; break;
2249022499
case ISD::OR: Opcode = X86ISD::OR; break;
22500+
// clang-format on
2249122501
}
2249222502

2249322503
NumOperands = 2;
@@ -22876,6 +22886,7 @@ static unsigned translateX86FSETCC(ISD::CondCode SetCCOpcode, SDValue &Op0,
2287622886
// 6 - NLE
2287722887
// 7 - ORD
2287822888
switch (SetCCOpcode) {
22889+
// clang-format off
2287922890
default: llvm_unreachable("Unexpected SETCC condition");
2288022891
case ISD::SETOEQ:
2288122892
case ISD::SETEQ: SSECC = 0; break;
@@ -22897,6 +22908,7 @@ static unsigned translateX86FSETCC(ISD::CondCode SetCCOpcode, SDValue &Op0,
2289722908
case ISD::SETO: SSECC = 7; break;
2289822909
case ISD::SETUEQ: SSECC = 8; break;
2289922910
case ISD::SETONE: SSECC = 12; break;
22911+
// clang-format on
2290022912
}
2290122913
if (Swap)
2290222914
std::swap(Op0, Op1);
@@ -23237,6 +23249,7 @@ static SDValue LowerVSETCC(SDValue Op, const X86Subtarget &Subtarget,
2323723249
// Translate compare code to XOP PCOM compare mode.
2323823250
unsigned CmpMode = 0;
2323923251
switch (Cond) {
23252+
// clang-format off
2324023253
default: llvm_unreachable("Unexpected SETCC condition");
2324123254
case ISD::SETULT:
2324223255
case ISD::SETLT: CmpMode = 0x00; break;
@@ -23248,6 +23261,7 @@ static SDValue LowerVSETCC(SDValue Op, const X86Subtarget &Subtarget,
2324823261
case ISD::SETGE: CmpMode = 0x03; break;
2324923262
case ISD::SETEQ: CmpMode = 0x04; break;
2325023263
case ISD::SETNE: CmpMode = 0x05; break;
23264+
// clang-format on
2325123265
}
2325223266

2325323267
// Are we comparing unsigned or signed integers?
@@ -23351,11 +23365,13 @@ static SDValue LowerVSETCC(SDValue Op, const X86Subtarget &Subtarget,
2335123365
bool Invert = false;
2335223366
unsigned Opc;
2335323367
switch (Cond) {
23368+
// clang-format off
2335423369
default: llvm_unreachable("Unexpected condition code");
2335523370
case ISD::SETUGT: Invert = true; [[fallthrough]];
2335623371
case ISD::SETULE: Opc = ISD::UMIN; break;
2335723372
case ISD::SETULT: Invert = true; [[fallthrough]];
2335823373
case ISD::SETUGE: Opc = ISD::UMAX; break;
23374+
// clang-format on
2335923375
}
2336023376

2336123377
SDValue Result = DAG.getNode(Opc, dl, VT, Op0, Op1);
@@ -27492,12 +27508,14 @@ SDValue X86TargetLowering::LowerSET_ROUNDING(SDValue Op,
2749227508
uint64_t RM = CVal->getZExtValue();
2749327509
int FieldVal;
2749427510
switch (static_cast<RoundingMode>(RM)) {
27511+
// clang-format off
2749527512
case RoundingMode::NearestTiesToEven: FieldVal = X86::rmToNearest; break;
2749627513
case RoundingMode::TowardNegative: FieldVal = X86::rmDownward; break;
2749727514
case RoundingMode::TowardPositive: FieldVal = X86::rmUpward; break;
2749827515
case RoundingMode::TowardZero: FieldVal = X86::rmTowardZero; break;
2749927516
default:
2750027517
llvm_unreachable("rounding mode is not supported by X86 hardware");
27518+
// clang-format on
2750127519
}
2750227520
RMBits = DAG.getConstant(FieldVal, DL, MVT::i16);
2750327521
} else {
@@ -28713,11 +28731,13 @@ SDValue X86TargetLowering::LowerWin64_i128OP(SDValue Op, SelectionDAG &DAG) cons
2871328731
RTLIB::Libcall LC;
2871428732
bool isSigned;
2871528733
switch (Op->getOpcode()) {
28734+
// clang-format off
2871628735
default: llvm_unreachable("Unexpected request for libcall!");
2871728736
case ISD::SDIV: isSigned = true; LC = RTLIB::SDIV_I128; break;
2871828737
case ISD::UDIV: isSigned = false; LC = RTLIB::UDIV_I128; break;
2871928738
case ISD::SREM: isSigned = true; LC = RTLIB::SREM_I128; break;
2872028739
case ISD::UREM: isSigned = false; LC = RTLIB::UREM_I128; break;
28740+
// clang-format on
2872128741
}
2872228742

2872328743
SDLoc dl(Op);
@@ -31846,6 +31866,7 @@ bool X86TargetLowering::isInlineAsmTargetBranch(
3184631866
/// Provide custom lowering hooks for some operations.
3184731867
SDValue X86TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
3184831868
switch (Op.getOpcode()) {
31869+
// clang-format off
3184931870
default: llvm_unreachable("Should not custom lower this!");
3185031871
case ISD::ATOMIC_FENCE: return LowerATOMIC_FENCE(Op, Subtarget, DAG);
3185131872
case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS:
@@ -31997,6 +32018,7 @@ SDValue X86TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
3199732018
case ISD::ADDRSPACECAST: return LowerADDRSPACECAST(Op, DAG);
3199832019
case X86ISD::CVTPS2PH: return LowerCVTPS2PH(Op, DAG);
3199932020
case ISD::PREFETCH: return LowerPREFETCH(Op, Subtarget, DAG);
32021+
// clang-format on
3200032022
}
3200132023
}
3200232024

@@ -36128,6 +36150,7 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
3612836150
// Get the X86 opcode to use.
3612936151
unsigned Opc;
3613036152
switch (MI.getOpcode()) {
36153+
// clang-format off
3613136154
default: llvm_unreachable("illegal opcode!");
3613236155
case X86::FP32_TO_INT16_IN_MEM: Opc = X86::IST_Fp16m32; break;
3613336156
case X86::FP32_TO_INT32_IN_MEM: Opc = X86::IST_Fp32m32; break;
@@ -36138,6 +36161,7 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
3613836161
case X86::FP80_TO_INT16_IN_MEM: Opc = X86::IST_Fp16m80; break;
3613936162
case X86::FP80_TO_INT32_IN_MEM: Opc = X86::IST_Fp32m80; break;
3614036163
case X86::FP80_TO_INT64_IN_MEM: Opc = X86::IST_Fp64m80; break;
36164+
// clang-format on
3614136165
}
3614236166

3614336167
X86AddressMode AM = getAddressFromInstr(&MI, 0);
@@ -36346,13 +36370,15 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
3634636370
case X86::PTDPFP16PS: {
3634736371
unsigned Opc;
3634836372
switch (MI.getOpcode()) {
36373+
// clang-format off
3634936374
default: llvm_unreachable("illegal opcode!");
3635036375
case X86::PTDPBSSD: Opc = X86::TDPBSSD; break;
3635136376
case X86::PTDPBSUD: Opc = X86::TDPBSUD; break;
3635236377
case X86::PTDPBUSD: Opc = X86::TDPBUSD; break;
3635336378
case X86::PTDPBUUD: Opc = X86::TDPBUUD; break;
3635436379
case X86::PTDPBF16PS: Opc = X86::TDPBF16PS; break;
3635536380
case X86::PTDPFP16PS: Opc = X86::TDPFP16PS; break;
36381+
// clang-format on
3635636382
}
3635736383

3635836384
MachineInstrBuilder MIB = BuildMI(*BB, MI, MIMD, TII->get(Opc));
@@ -36413,9 +36439,11 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
3641336439
const MIMetadata MIMD(MI);
3641436440
unsigned Opc;
3641536441
switch (MI.getOpcode()) {
36442+
// clang-format off
3641636443
default: llvm_unreachable("Unexpected instruction!");
3641736444
case X86::PTCMMIMFP16PS: Opc = X86::TCMMIMFP16PS; break;
3641836445
case X86::PTCMMRLFP16PS: Opc = X86::TCMMRLFP16PS; break;
36446+
// clang-format on
3641936447
}
3642036448
MachineInstrBuilder MIB = BuildMI(*BB, MI, MIMD, TII->get(Opc));
3642136449
MIB.addReg(TMMImmToTMMReg(MI.getOperand(0).getImm()), RegState::Define);
@@ -42424,10 +42452,12 @@ static bool checkBitcastSrcVectorSize(SDValue Src, unsigned Size,
4242442452
// Helper to flip between AND/OR/XOR opcodes and their X86ISD FP equivalents.
4242542453
static unsigned getAltBitOpcode(unsigned Opcode) {
4242642454
switch(Opcode) {
42455+
// clang-format off
4242742456
case ISD::AND: return X86ISD::FAND;
4242842457
case ISD::OR: return X86ISD::FOR;
4242942458
case ISD::XOR: return X86ISD::FXOR;
4243042459
case X86ISD::ANDNP: return X86ISD::FANDN;
42460+
// clang-format on
4243142461
}
4243242462
llvm_unreachable("Unknown bitwise opcode");
4243342463
}
@@ -43115,10 +43145,12 @@ static SDValue combineBitcast(SDNode *N, SelectionDAG &DAG,
4311543145
// transferring the SSE operand to integer register and back.
4311643146
unsigned FPOpcode;
4311743147
switch (N0.getOpcode()) {
43118-
case ISD::AND: FPOpcode = X86ISD::FAND; break;
43119-
case ISD::OR: FPOpcode = X86ISD::FOR; break;
43120-
case ISD::XOR: FPOpcode = X86ISD::FXOR; break;
43121-
default: return SDValue();
43148+
// clang-format off
43149+
case ISD::AND: FPOpcode = X86ISD::FAND; break;
43150+
case ISD::OR: FPOpcode = X86ISD::FOR; break;
43151+
case ISD::XOR: FPOpcode = X86ISD::FXOR; break;
43152+
default: return SDValue();
43153+
// clang-format on
4312243154
}
4312343155

4312443156
// Check if we have a bitcast from another integer type as well.
@@ -45181,11 +45213,13 @@ static SDValue combineSelect(SDNode *N, SelectionDAG &DAG,
4518145213
Cond1 == InnerSetCC.getOperand(1)) {
4518245214
ISD::CondCode NewCC;
4518345215
switch (CC == ISD::SETEQ ? InnerCC : CC) {
45216+
// clang-format off
4518445217
case ISD::SETGT: NewCC = ISD::SETGE; break;
4518545218
case ISD::SETLT: NewCC = ISD::SETLE; break;
4518645219
case ISD::SETUGT: NewCC = ISD::SETUGE; break;
4518745220
case ISD::SETULT: NewCC = ISD::SETULE; break;
4518845221
default: NewCC = ISD::SETCC_INVALID; break;
45222+
// clang-format on
4518945223
}
4519045224
if (NewCC != ISD::SETCC_INVALID) {
4519145225
Cond = DAG.getSetCC(DL, CondVT, Cond0, Cond1, NewCC);
@@ -48018,10 +48052,12 @@ static SDValue PromoteMaskArithmetic(SDNode *N, SelectionDAG &DAG,
4801848052
static unsigned convertIntLogicToFPLogicOpcode(unsigned Opcode) {
4801948053
unsigned FPOpcode;
4802048054
switch (Opcode) {
48055+
// clang-format off
4802148056
default: llvm_unreachable("Unexpected input node for FP logic conversion");
4802248057
case ISD::AND: FPOpcode = X86ISD::FAND; break;
4802348058
case ISD::OR: FPOpcode = X86ISD::FOR; break;
4802448059
case ISD::XOR: FPOpcode = X86ISD::FXOR; break;
48060+
// clang-format on
4802548061
}
4802648062
return FPOpcode;
4802748063
}
@@ -49593,6 +49629,7 @@ static SDValue foldVectorXorShiftIntoCmp(SDNode *N, SelectionDAG &DAG,
4959349629
return SDValue();
4959449630

4959549631
switch (VT.getSimpleVT().SimpleTy) {
49632+
// clang-format off
4959649633
default: return SDValue();
4959749634
case MVT::v16i8:
4959849635
case MVT::v8i16:
@@ -49602,6 +49639,7 @@ static SDValue foldVectorXorShiftIntoCmp(SDNode *N, SelectionDAG &DAG,
4960249639
case MVT::v16i16:
4960349640
case MVT::v8i32:
4960449641
case MVT::v4i64: if (!Subtarget.hasAVX2()) return SDValue(); break;
49642+
// clang-format on
4960549643
}
4960649644

4960749645
// There must be a shift right algebraic before the xor, and the xor must be a
@@ -51546,6 +51584,7 @@ static unsigned negateFMAOpcode(unsigned Opcode, bool NegMul, bool NegAcc,
5154651584
bool NegRes) {
5154751585
if (NegMul) {
5154851586
switch (Opcode) {
51587+
// clang-format off
5154951588
default: llvm_unreachable("Unexpected opcode");
5155051589
case ISD::FMA: Opcode = X86ISD::FNMADD; break;
5155151590
case ISD::STRICT_FMA: Opcode = X86ISD::STRICT_FNMADD; break;
@@ -51559,11 +51598,13 @@ static unsigned negateFMAOpcode(unsigned Opcode, bool NegMul, bool NegAcc,
5155951598
case X86ISD::FNMSUB: Opcode = X86ISD::FMSUB; break;
5156051599
case X86ISD::STRICT_FNMSUB: Opcode = X86ISD::STRICT_FMSUB; break;
5156151600
case X86ISD::FNMSUB_RND: Opcode = X86ISD::FMSUB_RND; break;
51601+
// clang-format on
5156251602
}
5156351603
}
5156451604

5156551605
if (NegAcc) {
5156651606
switch (Opcode) {
51607+
// clang-format off
5156751608
default: llvm_unreachable("Unexpected opcode");
5156851609
case ISD::FMA: Opcode = X86ISD::FMSUB; break;
5156951610
case ISD::STRICT_FMA: Opcode = X86ISD::STRICT_FMSUB; break;
@@ -51581,12 +51622,14 @@ static unsigned negateFMAOpcode(unsigned Opcode, bool NegMul, bool NegAcc,
5158151622
case X86ISD::FMADDSUB_RND: Opcode = X86ISD::FMSUBADD_RND; break;
5158251623
case X86ISD::FMSUBADD: Opcode = X86ISD::FMADDSUB; break;
5158351624
case X86ISD::FMSUBADD_RND: Opcode = X86ISD::FMADDSUB_RND; break;
51625+
// clang-format on
5158451626
}
5158551627
}
5158651628

5158751629
if (NegRes) {
5158851630
switch (Opcode) {
5158951631
// For accuracy reason, we never combine fneg and fma under strict FP.
51632+
// clang-format off
5159051633
default: llvm_unreachable("Unexpected opcode");
5159151634
case ISD::FMA: Opcode = X86ISD::FNMSUB; break;
5159251635
case X86ISD::FMADD_RND: Opcode = X86ISD::FNMSUB_RND; break;
@@ -51596,6 +51639,7 @@ static unsigned negateFMAOpcode(unsigned Opcode, bool NegMul, bool NegAcc,
5159651639
case X86ISD::FNMADD_RND: Opcode = X86ISD::FMSUB_RND; break;
5159751640
case X86ISD::FNMSUB: Opcode = ISD::FMA; break;
5159851641
case X86ISD::FNMSUB_RND: Opcode = X86ISD::FMADD_RND; break;
51642+
// clang-format on
5159951643
}
5160051644
}
5160151645

@@ -51724,11 +51768,13 @@ static SDValue lowerX86FPLogicOp(SDNode *N, SelectionDAG &DAG,
5172451768
SDValue Op1 = DAG.getBitcast(IntVT, N->getOperand(1));
5172551769
unsigned IntOpcode;
5172651770
switch (N->getOpcode()) {
51771+
// clang-format off
5172751772
default: llvm_unreachable("Unexpected FP logic op");
5172851773
case X86ISD::FOR: IntOpcode = ISD::OR; break;
5172951774
case X86ISD::FXOR: IntOpcode = ISD::XOR; break;
5173051775
case X86ISD::FAND: IntOpcode = ISD::AND; break;
5173151776
case X86ISD::FANDN: IntOpcode = X86ISD::ANDNP; break;
51777+
// clang-format on
5173251778
}
5173351779
SDValue IntOp = DAG.getNode(IntOpcode, dl, IntVT, Op0, Op1);
5173451780
return DAG.getBitcast(VT, IntOp);
@@ -53788,13 +53834,15 @@ static bool needCarryOrOverflowFlag(SDValue Flags) {
5378853834
}
5378953835

5379053836
switch (CC) {
53837+
// clang-format off
5379153838
default: break;
5379253839
case X86::COND_A: case X86::COND_AE:
5379353840
case X86::COND_B: case X86::COND_BE:
5379453841
case X86::COND_O: case X86::COND_NO:
5379553842
case X86::COND_G: case X86::COND_GE:
5379653843
case X86::COND_L: case X86::COND_LE:
5379753844
return true;
53845+
// clang-format on
5379853846
}
5379953847
}
5380053848

@@ -56188,6 +56236,7 @@ SDValue X86TargetLowering::PerformDAGCombine(SDNode *N,
5618856236
DAGCombinerInfo &DCI) const {
5618956237
SelectionDAG &DAG = DCI.DAG;
5619056238
switch (N->getOpcode()) {
56239+
// clang-format off
5619156240
default: break;
5619256241
case ISD::SCALAR_TO_VECTOR:
5619356242
return combineScalarToVector(N, DAG);
@@ -56365,6 +56414,7 @@ SDValue X86TargetLowering::PerformDAGCombine(SDNode *N,
5636556414
case X86ISD::SUBV_BROADCAST_LOAD: return combineBROADCAST_LOAD(N, DAG, DCI);
5636656415
case X86ISD::MOVDQ2Q: return combineMOVDQ2Q(N, DAG);
5636756416
case X86ISD::PDEP: return combinePDEP(N, DAG, DCI);
56417+
// clang-format on
5636856418
}
5636956419

5637056420
return SDValue();

0 commit comments

Comments
 (0)