| 1 | //===-- RISCV.h - Top-level interface for RISC-V ----------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file contains the entry points for global functions defined in the LLVM |
| 10 | // RISC-V back-end. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_LIB_TARGET_RISCV_RISCV_H |
| 15 | #define LLVM_LIB_TARGET_RISCV_RISCV_H |
| 16 | |
| 17 | #include "MCTargetDesc/RISCVBaseInfo.h" |
| 18 | #include "llvm/CodeGen/MachineFunctionAnalysisManager.h" |
| 19 | #include "llvm/CodeGen/SelectionDAGISel.h" |
| 20 | #include "llvm/IR/Analysis.h" |
| 21 | #include "llvm/IR/PassManager.h" |
| 22 | #include "llvm/Target/TargetMachine.h" |
| 23 | |
| 24 | namespace llvm { |
| 25 | class FunctionPass; |
| 26 | class InstructionSelector; |
| 27 | class ModulePass; |
| 28 | class PassRegistry; |
| 29 | class RISCVRegisterBankInfo; |
| 30 | class RISCVSubtarget; |
| 31 | class RISCVTargetMachine; |
| 32 | |
| 33 | class RISCVCodeGenPreparePass |
| 34 | : public OptionalPassInfoMixin<RISCVCodeGenPreparePass> { |
| 35 | private: |
| 36 | const RISCVTargetMachine *TM; |
| 37 | |
| 38 | public: |
| 39 | RISCVCodeGenPreparePass(const RISCVTargetMachine *TM) : TM(TM) {} |
| 40 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); |
| 41 | }; |
| 42 | FunctionPass *createRISCVCodeGenPrepareLegacyPass(); |
| 43 | void initializeRISCVCodeGenPrepareLegacyPass(PassRegistry &); |
| 44 | |
| 45 | class RISCVDeadRegisterDefinitionsPass |
| 46 | : public OptionalPassInfoMixin<RISCVDeadRegisterDefinitionsPass> { |
| 47 | public: |
| 48 | PreservedAnalyses run(MachineFunction &MF, |
| 49 | MachineFunctionAnalysisManager &MFAM); |
| 50 | }; |
| 51 | FunctionPass *createRISCVDeadRegisterDefinitionsLegacyPass(); |
| 52 | void initializeRISCVDeadRegisterDefinitionsLegacyPass(PassRegistry &); |
| 53 | |
| 54 | class RISCVIndirectBranchTrackingPass |
| 55 | : public RequiredPassInfoMixin<RISCVIndirectBranchTrackingPass> { |
| 56 | public: |
| 57 | PreservedAnalyses run(MachineFunction &MF, |
| 58 | MachineFunctionAnalysisManager &MFAM); |
| 59 | }; |
| 60 | FunctionPass *createRISCVIndirectBranchTrackingLegacyPass(); |
| 61 | void initializeRISCVIndirectBranchTrackingLegacyPass(PassRegistry &); |
| 62 | |
| 63 | class RISCVLandingPadSetupPass |
| 64 | : public RequiredPassInfoMixin<RISCVLandingPadSetupPass> { |
| 65 | public: |
| 66 | PreservedAnalyses run(MachineFunction &MF, |
| 67 | MachineFunctionAnalysisManager &MFAM); |
| 68 | }; |
| 69 | FunctionPass *createRISCVLandingPadSetupLegacyPass(); |
| 70 | void initializeRISCVLandingPadSetupLegacyPass(PassRegistry &); |
| 71 | |
| 72 | FunctionPass *createRISCVISelDagLegacyPass(RISCVTargetMachine &TM, |
| 73 | CodeGenOptLevel OptLevel); |
| 74 | |
| 75 | class RISCVISelDAGToDAGPass : public SelectionDAGISelPass { |
| 76 | public: |
| 77 | RISCVISelDAGToDAGPass(RISCVTargetMachine &TM, CodeGenOptLevel OptLevel); |
| 78 | }; |
| 79 | |
| 80 | class RISCVLateBranchOptPass |
| 81 | : public OptionalPassInfoMixin<RISCVLateBranchOptPass> { |
| 82 | public: |
| 83 | PreservedAnalyses run(MachineFunction &MF, |
| 84 | MachineFunctionAnalysisManager &MFAM); |
| 85 | }; |
| 86 | FunctionPass *createRISCVLateBranchOptLegacyPass(); |
| 87 | void initializeRISCVLateBranchOptLegacyPass(PassRegistry &); |
| 88 | |
| 89 | class RISCVMakeCompressiblePass |
| 90 | : public OptionalPassInfoMixin<RISCVMakeCompressiblePass> { |
| 91 | public: |
| 92 | PreservedAnalyses run(MachineFunction &MF, |
| 93 | MachineFunctionAnalysisManager &MFAM); |
| 94 | }; |
| 95 | FunctionPass *createRISCVMakeCompressibleLegacyPass(); |
| 96 | void initializeRISCVMakeCompressibleLegacyPass(PassRegistry &); |
| 97 | |
| 98 | class RISCVGatherScatterLoweringPass |
| 99 | : public OptionalPassInfoMixin<RISCVGatherScatterLoweringPass> { |
| 100 | private: |
| 101 | const RISCVTargetMachine *TM; |
| 102 | |
| 103 | public: |
| 104 | RISCVGatherScatterLoweringPass(const RISCVTargetMachine *TM) : TM(TM) {} |
| 105 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); |
| 106 | }; |
| 107 | |
| 108 | FunctionPass *createRISCVGatherScatterLoweringLegacyPass(); |
| 109 | void initializeRISCVGatherScatterLoweringLegacyPass(PassRegistry &); |
| 110 | |
| 111 | class RISCVVectorPeepholePass |
| 112 | : public OptionalPassInfoMixin<RISCVVectorPeepholePass> { |
| 113 | public: |
| 114 | PreservedAnalyses run(MachineFunction &MF, |
| 115 | MachineFunctionAnalysisManager &MFAM); |
| 116 | MachineFunctionProperties getRequiredProperties() const { |
| 117 | return MachineFunctionProperties().setIsSSA(); |
| 118 | } |
| 119 | }; |
| 120 | |
| 121 | FunctionPass *createRISCVVectorPeepholeLegacyPass(); |
| 122 | void initializeRISCVVectorPeepholeLegacyPass(PassRegistry &); |
| 123 | |
| 124 | class RISCVOptWInstrsPass : public OptionalPassInfoMixin<RISCVOptWInstrsPass> { |
| 125 | public: |
| 126 | PreservedAnalyses run(MachineFunction &MF, |
| 127 | MachineFunctionAnalysisManager &MFAM); |
| 128 | }; |
| 129 | |
| 130 | FunctionPass *createRISCVOptWInstrsLegacyPass(); |
| 131 | void initializeRISCVOptWInstrsLegacyPass(PassRegistry &); |
| 132 | |
| 133 | class RISCVFoldMemOffsetPass |
| 134 | : public OptionalPassInfoMixin<RISCVFoldMemOffsetPass> { |
| 135 | public: |
| 136 | PreservedAnalyses run(MachineFunction &MF, |
| 137 | MachineFunctionAnalysisManager &MFAM); |
| 138 | }; |
| 139 | |
| 140 | FunctionPass *createRISCVFoldMemOffsetLegacyPass(); |
| 141 | void initializeRISCVFoldMemOffsetLegacyPass(PassRegistry &); |
| 142 | |
| 143 | class RISCVMergeBaseOffsetPass |
| 144 | : public OptionalPassInfoMixin<RISCVMergeBaseOffsetPass> { |
| 145 | public: |
| 146 | PreservedAnalyses run(MachineFunction &MF, |
| 147 | MachineFunctionAnalysisManager &MFAM); |
| 148 | }; |
| 149 | |
| 150 | FunctionPass *createRISCVMergeBaseOffsetLegacyPass(); |
| 151 | void initializeRISCVMergeBaseOffsetLegacyPass(PassRegistry &); |
| 152 | |
| 153 | class RISCVExpandPseudoPreRAPass |
| 154 | : public RequiredPassInfoMixin<RISCVExpandPseudoPreRAPass> { |
| 155 | public: |
| 156 | PreservedAnalyses run(MachineFunction &MF, |
| 157 | MachineFunctionAnalysisManager &MFAM); |
| 158 | MachineFunctionProperties getRequiredProperties() const { |
| 159 | return MachineFunctionProperties().setIsSSA(); |
| 160 | } |
| 161 | }; |
| 162 | |
| 163 | FunctionPass *createRISCVExpandPseudoPreRALegacyPass(); |
| 164 | void initializeRISCVExpandPseudoPreRALegacyPass(PassRegistry &); |
| 165 | |
| 166 | class RISCVExpandPseudoPostRAPass |
| 167 | : public RequiredPassInfoMixin<RISCVExpandPseudoPostRAPass> { |
| 168 | public: |
| 169 | PreservedAnalyses run(MachineFunction &MF, |
| 170 | MachineFunctionAnalysisManager &MFAM); |
| 171 | }; |
| 172 | |
| 173 | FunctionPass *createRISCVExpandPseudoPostRALegacyPass(); |
| 174 | void initializeRISCVExpandPseudoPostRALegacyPass(PassRegistry &); |
| 175 | |
| 176 | class RISCVExpandPseudoPreEmitPass |
| 177 | : public RequiredPassInfoMixin<RISCVExpandPseudoPreEmitPass> { |
| 178 | public: |
| 179 | PreservedAnalyses run(MachineFunction &MF, |
| 180 | MachineFunctionAnalysisManager &MFAM); |
| 181 | }; |
| 182 | |
| 183 | FunctionPass *createRISCVExpandPseudoPreEmitLegacyPass(); |
| 184 | void initializeRISCVExpandPseudoPreEmitLegacyPass(PassRegistry &); |
| 185 | |
| 186 | class RISCVExpandPseudoAtomicsPass |
| 187 | : public RequiredPassInfoMixin<RISCVExpandPseudoAtomicsPass> { |
| 188 | public: |
| 189 | PreservedAnalyses run(MachineFunction &MF, |
| 190 | MachineFunctionAnalysisManager &MFAM); |
| 191 | }; |
| 192 | |
| 193 | FunctionPass *createRISCVExpandPseudoAtomicsLegacyPass(); |
| 194 | void initializeRISCVExpandPseudoAtomicsLegacyPass(PassRegistry &); |
| 195 | |
| 196 | class RISCVInsertVSETVLIPass |
| 197 | : public RequiredPassInfoMixin<RISCVInsertVSETVLIPass> { |
| 198 | public: |
| 199 | PreservedAnalyses run(MachineFunction &MF, |
| 200 | MachineFunctionAnalysisManager &MFAM); |
| 201 | }; |
| 202 | |
| 203 | FunctionPass *createRISCVInsertVSETVLILegacyPass(); |
| 204 | void initializeRISCVInsertVSETVLILegacyPass(PassRegistry &); |
| 205 | extern char &RISCVInsertVSETVLILegacyID; |
| 206 | |
| 207 | class RISCVInsertReadWriteCSRPass |
| 208 | : public RequiredPassInfoMixin<RISCVInsertReadWriteCSRPass> { |
| 209 | public: |
| 210 | PreservedAnalyses run(MachineFunction &MF, |
| 211 | MachineFunctionAnalysisManager &MFAM); |
| 212 | }; |
| 213 | |
| 214 | FunctionPass *createRISCVInsertReadWriteCSRLegacyPass(); |
| 215 | void initializeRISCVInsertReadWriteCSRLegacyPass(PassRegistry &); |
| 216 | |
| 217 | class RISCVInsertWriteVXRMPass |
| 218 | : public RequiredPassInfoMixin<RISCVInsertWriteVXRMPass> { |
| 219 | public: |
| 220 | PreservedAnalyses run(MachineFunction &MF, |
| 221 | MachineFunctionAnalysisManager &MFAM); |
| 222 | }; |
| 223 | |
| 224 | FunctionPass *createRISCVInsertWriteVXRMLegacyPass(); |
| 225 | void initializeRISCVInsertWriteVXRMLegacyPass(PassRegistry &); |
| 226 | |
| 227 | class RISCVRedundantCopyEliminationPass |
| 228 | : public OptionalPassInfoMixin<RISCVRedundantCopyEliminationPass> { |
| 229 | public: |
| 230 | PreservedAnalyses run(MachineFunction &MF, |
| 231 | MachineFunctionAnalysisManager &MFAM); |
| 232 | |
| 233 | MachineFunctionProperties getRequiredProperties() const { |
| 234 | return MachineFunctionProperties().setNoVRegs(); |
| 235 | } |
| 236 | }; |
| 237 | |
| 238 | FunctionPass *createRISCVRedundantCopyEliminationLegacyPass(); |
| 239 | void initializeRISCVRedundantCopyEliminationLegacyPass(PassRegistry &); |
| 240 | |
| 241 | class RISCVMoveMergePass : public OptionalPassInfoMixin<RISCVMoveMergePass> { |
| 242 | public: |
| 243 | PreservedAnalyses run(MachineFunction &MF, |
| 244 | MachineFunctionAnalysisManager &MFAM); |
| 245 | }; |
| 246 | |
| 247 | FunctionPass *createRISCVMoveMergeLegacyPass(); |
| 248 | void initializeRISCVMoveMergeLegacyPass(PassRegistry &); |
| 249 | |
| 250 | class RISCVPushPopOptPass : public OptionalPassInfoMixin<RISCVPushPopOptPass> { |
| 251 | public: |
| 252 | PreservedAnalyses run(MachineFunction &MF, |
| 253 | MachineFunctionAnalysisManager &MFAM); |
| 254 | }; |
| 255 | |
| 256 | FunctionPass *createRISCVPushPopOptLegacyPass(); |
| 257 | void initializeRISCVPushPopOptLegacyPass(PassRegistry &); |
| 258 | |
| 259 | class RISCVLoadStoreOptPass |
| 260 | : public OptionalPassInfoMixin<RISCVLoadStoreOptPass> { |
| 261 | public: |
| 262 | PreservedAnalyses run(MachineFunction &MF, |
| 263 | MachineFunctionAnalysisManager &MFAM); |
| 264 | }; |
| 265 | |
| 266 | FunctionPass *createRISCVLoadStoreOptLegacyPass(); |
| 267 | void initializeRISCVLoadStoreOptLegacyPass(PassRegistry &); |
| 268 | |
| 269 | class RISCVPreAllocZilsdOptPass |
| 270 | : public OptionalPassInfoMixin<RISCVPreAllocZilsdOptPass> { |
| 271 | public: |
| 272 | PreservedAnalyses run(MachineFunction &MF, |
| 273 | MachineFunctionAnalysisManager &MFAM); |
| 274 | }; |
| 275 | |
| 276 | FunctionPass *createRISCVPreAllocZilsdOptLegacyPass(); |
| 277 | void initializeRISCVPreAllocZilsdOptLegacyPass(PassRegistry &); |
| 278 | |
| 279 | class RISCVZacasABIFixPass |
| 280 | : public RequiredPassInfoMixin<RISCVZacasABIFixPass> { |
| 281 | private: |
| 282 | const RISCVTargetMachine *TM; |
| 283 | |
| 284 | public: |
| 285 | RISCVZacasABIFixPass(const RISCVTargetMachine *TM) : TM(TM) {} |
| 286 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); |
| 287 | }; |
| 288 | FunctionPass *createRISCVZacasABIFixLegacyPass(); |
| 289 | void initializeRISCVZacasABIFixLegacyPass(PassRegistry &); |
| 290 | |
| 291 | InstructionSelector * |
| 292 | createRISCVInstructionSelector(const RISCVTargetMachine &, |
| 293 | const RISCVSubtarget &, |
| 294 | const RISCVRegisterBankInfo &); |
| 295 | void initializeRISCVDAGToDAGISelLegacyPass(PassRegistry &); |
| 296 | |
| 297 | class RISCVPostLegalizerCombinerPass |
| 298 | : public RequiredPassInfoMixin<RISCVPostLegalizerCombinerPass> { |
| 299 | public: |
| 300 | PreservedAnalyses run(MachineFunction &MF, |
| 301 | MachineFunctionAnalysisManager &MFAM); |
| 302 | }; |
| 303 | |
| 304 | FunctionPass *createRISCVPostLegalizerCombinerLegacyPass(); |
| 305 | void initializeRISCVPostLegalizerCombinerLegacyPass(PassRegistry &); |
| 306 | |
| 307 | class RISCVO0PreLegalizerCombinerPass |
| 308 | : public RequiredPassInfoMixin<RISCVO0PreLegalizerCombinerPass> { |
| 309 | public: |
| 310 | PreservedAnalyses run(MachineFunction &MF, |
| 311 | MachineFunctionAnalysisManager &MFAM); |
| 312 | }; |
| 313 | |
| 314 | FunctionPass *createRISCVO0PreLegalizerCombinerLegacyPass(); |
| 315 | void initializeRISCVO0PreLegalizerCombinerLegacyPass(PassRegistry &); |
| 316 | |
| 317 | class RISCVPreLegalizerCombinerPass |
| 318 | : public RequiredPassInfoMixin<RISCVPreLegalizerCombinerPass> { |
| 319 | public: |
| 320 | PreservedAnalyses run(MachineFunction &MF, |
| 321 | MachineFunctionAnalysisManager &MFAM); |
| 322 | }; |
| 323 | |
| 324 | FunctionPass *createRISCVPreLegalizerCombinerLegacyPass(); |
| 325 | void initializeRISCVPreLegalizerCombinerLegacyPass(PassRegistry &); |
| 326 | |
| 327 | class RISCVPromoteConstantPass |
| 328 | : public OptionalPassInfoMixin<RISCVPromoteConstantPass> { |
| 329 | private: |
| 330 | const RISCVTargetMachine *TM; |
| 331 | |
| 332 | public: |
| 333 | RISCVPromoteConstantPass(const RISCVTargetMachine *TM) : TM(TM) {} |
| 334 | PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM); |
| 335 | }; |
| 336 | |
| 337 | ModulePass *createRISCVPromoteConstantLegacyPass(); |
| 338 | void initializeRISCVPromoteConstantLegacyPass(PassRegistry &); |
| 339 | |
| 340 | class RISCVVLOptimizerPass |
| 341 | : public OptionalPassInfoMixin<RISCVVLOptimizerPass> { |
| 342 | public: |
| 343 | PreservedAnalyses run(MachineFunction &MF, |
| 344 | MachineFunctionAnalysisManager &MFAM); |
| 345 | }; |
| 346 | |
| 347 | FunctionPass *createRISCVVLOptimizerLegacyPass(); |
| 348 | void initializeRISCVVLOptimizerLegacyPass(PassRegistry &); |
| 349 | |
| 350 | class RISCVVMV0EliminationPass |
| 351 | : public RequiredPassInfoMixin<RISCVVMV0EliminationPass> { |
| 352 | public: |
| 353 | PreservedAnalyses run(MachineFunction &MF, |
| 354 | MachineFunctionAnalysisManager &MFAM); |
| 355 | |
| 356 | MachineFunctionProperties getRequiredProperties() const { |
| 357 | return MachineFunctionProperties().setIsSSA(); |
| 358 | } |
| 359 | }; |
| 360 | |
| 361 | FunctionPass *createRISCVVMV0EliminationLegacyPass(); |
| 362 | void initializeRISCVVMV0EliminationLegacyPass(PassRegistry &); |
| 363 | |
| 364 | class RISCVQCRelaxMarkingPass |
| 365 | : public OptionalPassInfoMixin<RISCVQCRelaxMarkingPass> { |
| 366 | public: |
| 367 | PreservedAnalyses run(MachineFunction &MF, |
| 368 | MachineFunctionAnalysisManager &MFAM); |
| 369 | }; |
| 370 | |
| 371 | FunctionPass *createRISCVQCRelaxMarkingLegacyPass(); |
| 372 | void initializeRISCVQCRelaxMarkingLegacyPass(PassRegistry &); |
| 373 | |
| 374 | void initializeRISCVAsmPrinterPass(PassRegistry &); |
| 375 | } // namespace llvm |
| 376 | |
| 377 | #endif |
| 378 | |