Skip to content

Commit

Permalink
[CIR][NFC] Refactor code for populating LLVM conversion patterns (#1152)
Browse files Browse the repository at this point in the history
The function `populateCIRToLLVMConversionPatterns` contains a spaghetti
of LLVM dialect conversion patterns, which results in merge conflicts
very easily. Besides, a few patterns are even registered for more than
once, possibly due to careless resolution of merge conflicts.

This PR attempts to mitigate this problem. Pattern names now are sorted
in alphabetical order, and each source code line now only lists exactly
one pattern name to reduce potential merge conflicts.
  • Loading branch information
Lancern authored Nov 22, 2024
1 parent bae7bd9 commit dbd3e03
Showing 1 changed file with 89 additions and 46 deletions.
135 changes: 89 additions & 46 deletions clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3859,55 +3859,98 @@ void populateCIRToLLVMConversionPatterns(
stringGlobalsMap, argStringGlobalsMap,
argsVarMap, patterns.getContext());
patterns.add<
CIRToLLVMCmpOpLowering, CIRToLLVMSelectOpLowering,
CIRToLLVMBitClrsbOpLowering, CIRToLLVMBitClzOpLowering,
CIRToLLVMBitCtzOpLowering, CIRToLLVMBitFfsOpLowering,
CIRToLLVMBitParityOpLowering, CIRToLLVMBitPopcountOpLowering,
CIRToLLVMAtomicCmpXchgLowering, CIRToLLVMAtomicXchgLowering,
CIRToLLVMAtomicFetchLowering, CIRToLLVMByteswapOpLowering,
CIRToLLVMRotateOpLowering, CIRToLLVMBrCondOpLowering,
CIRToLLVMPtrStrideOpLowering, CIRToLLVMCallOpLowering,
CIRToLLVMTryCallOpLowering, CIRToLLVMEhInflightOpLowering,
CIRToLLVMUnaryOpLowering, CIRToLLVMBinOpLowering,
CIRToLLVMBinOpOverflowOpLowering, CIRToLLVMShiftOpLowering,
CIRToLLVMLoadOpLowering, CIRToLLVMConstantOpLowering,
CIRToLLVMStoreOpLowering, CIRToLLVMFuncOpLowering,
CIRToLLVMCastOpLowering, CIRToLLVMGlobalOpLowering,
CIRToLLVMGetGlobalOpLowering, CIRToLLVMComplexCreateOpLowering,
CIRToLLVMComplexRealOpLowering, CIRToLLVMComplexImagOpLowering,
CIRToLLVMComplexRealPtrOpLowering, CIRToLLVMComplexImagPtrOpLowering,
CIRToLLVMVAStartOpLowering, CIRToLLVMVAEndOpLowering,
CIRToLLVMVACopyOpLowering, CIRToLLVMVAArgOpLowering,
CIRToLLVMBrOpLowering, CIRToLLVMGetMemberOpLowering,
CIRToLLVMGetRuntimeMemberOpLowering, CIRToLLVMSwitchFlatOpLowering,
CIRToLLVMPtrDiffOpLowering, CIRToLLVMCopyOpLowering,
CIRToLLVMMemCpyOpLowering, CIRToLLVMMemChrOpLowering,
CIRToLLVMAbsOpLowering, CIRToLLVMExpectOpLowering,
CIRToLLVMVTableAddrPointOpLowering, CIRToLLVMVecCreateOpLowering,
CIRToLLVMVecCmpOpLowering, CIRToLLVMVecSplatOpLowering,
CIRToLLVMVecTernaryOpLowering, CIRToLLVMVecShuffleDynamicOpLowering,
CIRToLLVMVecShuffleOpLowering, CIRToLLVMStackSaveOpLowering,
CIRToLLVMUnreachableOpLowering, CIRToLLVMTrapOpLowering,
CIRToLLVMInlineAsmOpLowering, CIRToLLVMSetBitfieldOpLowering,
CIRToLLVMGetBitfieldOpLowering, CIRToLLVMPrefetchOpLowering,
CIRToLLVMObjSizeOpLowering, CIRToLLVMIsConstantOpLowering,
CIRToLLVMCmpThreeWayOpLowering, CIRToLLVMMemCpyOpLowering,
CIRToLLVMIsConstantOpLowering, CIRToLLVMCmpThreeWayOpLowering,
CIRToLLVMReturnAddrOpLowering, CIRToLLVMClearCacheOpLowering,
CIRToLLVMEhTypeIdOpLowering, CIRToLLVMCatchParamOpLowering,
CIRToLLVMResumeOpLowering, CIRToLLVMAllocExceptionOpLowering,
CIRToLLVMFreeExceptionOpLowering, CIRToLLVMThrowOpLowering,
CIRToLLVMLLVMIntrinsicCallOpLowering, CIRToLLVMAssumeOpLowering,
CIRToLLVMAssumeAlignedOpLowering, CIRToLLVMAssumeSepStorageOpLowering,
CIRToLLVMBaseClassAddrOpLowering, CIRToLLVMDerivedClassAddrOpLowering,
CIRToLLVMVTTAddrPointOpLowering, CIRToLLVMIsFPClassOpLowering,
CIRToLLVMAbsOpLowering, CIRToLLVMMemMoveOpLowering,
CIRToLLVMMemSetOpLowering, CIRToLLVMMemSetInlineOpLowering,
CIRToLLVMMemCpyInlineOpLowering, CIRToLLVMSignBitOpLowering,
CIRToLLVMPtrMaskOpLowering
// clang-format off
CIRToLLVMAbsOpLowering,
CIRToLLVMAllocExceptionOpLowering,
CIRToLLVMAssumeAlignedOpLowering,
CIRToLLVMAssumeOpLowering,
CIRToLLVMAssumeSepStorageOpLowering,
CIRToLLVMAtomicCmpXchgLowering,
CIRToLLVMAtomicFetchLowering,
CIRToLLVMAtomicXchgLowering,
CIRToLLVMBaseClassAddrOpLowering,
CIRToLLVMBinOpLowering,
CIRToLLVMBinOpOverflowOpLowering,
CIRToLLVMBitClrsbOpLowering,
CIRToLLVMBitClzOpLowering,
CIRToLLVMBitCtzOpLowering,
CIRToLLVMBitFfsOpLowering,
CIRToLLVMBitParityOpLowering,
CIRToLLVMBitPopcountOpLowering,
CIRToLLVMBrCondOpLowering,
CIRToLLVMBrOpLowering,
CIRToLLVMByteswapOpLowering,
CIRToLLVMCallOpLowering,
CIRToLLVMCastOpLowering,
CIRToLLVMCatchParamOpLowering,
CIRToLLVMClearCacheOpLowering,
CIRToLLVMCmpOpLowering,
CIRToLLVMCmpThreeWayOpLowering,
CIRToLLVMComplexCreateOpLowering,
CIRToLLVMComplexImagOpLowering,
CIRToLLVMComplexImagPtrOpLowering,
CIRToLLVMComplexRealOpLowering,
CIRToLLVMComplexRealPtrOpLowering,
CIRToLLVMConstantOpLowering,
CIRToLLVMCopyOpLowering,
CIRToLLVMDerivedClassAddrOpLowering,
CIRToLLVMEhInflightOpLowering,
CIRToLLVMEhTypeIdOpLowering,
CIRToLLVMExpectOpLowering,
CIRToLLVMFreeExceptionOpLowering,
CIRToLLVMFuncOpLowering,
CIRToLLVMGetBitfieldOpLowering,
CIRToLLVMGetGlobalOpLowering,
CIRToLLVMGetMemberOpLowering,
CIRToLLVMGetRuntimeMemberOpLowering,
CIRToLLVMGlobalOpLowering,
CIRToLLVMInlineAsmOpLowering,
CIRToLLVMIsConstantOpLowering,
CIRToLLVMIsFPClassOpLowering,
CIRToLLVMLLVMIntrinsicCallOpLowering,
CIRToLLVMLoadOpLowering,
CIRToLLVMMemChrOpLowering,
CIRToLLVMMemCpyInlineOpLowering,
CIRToLLVMMemCpyOpLowering,
CIRToLLVMMemMoveOpLowering,
CIRToLLVMMemSetInlineOpLowering,
CIRToLLVMMemSetOpLowering,
CIRToLLVMObjSizeOpLowering,
CIRToLLVMPrefetchOpLowering,
CIRToLLVMPtrDiffOpLowering,
CIRToLLVMPtrMaskOpLowering,
CIRToLLVMPtrStrideOpLowering,
CIRToLLVMResumeOpLowering,
CIRToLLVMReturnAddrOpLowering,
CIRToLLVMRotateOpLowering,
CIRToLLVMSelectOpLowering,
CIRToLLVMSetBitfieldOpLowering,
CIRToLLVMShiftOpLowering,
CIRToLLVMSignBitOpLowering,
CIRToLLVMStackSaveOpLowering,
CIRToLLVMStoreOpLowering,
CIRToLLVMSwitchFlatOpLowering,
CIRToLLVMThrowOpLowering,
CIRToLLVMTrapOpLowering,
CIRToLLVMTryCallOpLowering,
CIRToLLVMUnaryOpLowering,
CIRToLLVMUnreachableOpLowering,
CIRToLLVMVAArgOpLowering,
CIRToLLVMVACopyOpLowering,
CIRToLLVMVAEndOpLowering,
CIRToLLVMVAStartOpLowering,
CIRToLLVMVecCmpOpLowering,
CIRToLLVMVecCreateOpLowering,
CIRToLLVMVecShuffleDynamicOpLowering,
CIRToLLVMVecShuffleOpLowering,
CIRToLLVMVecSplatOpLowering,
CIRToLLVMVecTernaryOpLowering,
CIRToLLVMVTableAddrPointOpLowering,
CIRToLLVMVTTAddrPointOpLowering
#define GET_BUILTIN_LOWERING_LIST
#include "clang/CIR/Dialect/IR/CIRBuiltinsLowering.inc"
#undef GET_BUILTIN_LOWERING_LIST
// clang-format on
>(converter, patterns.getContext());
}

Expand Down

0 comments on commit dbd3e03

Please sign in to comment.