LLVM 24.0.0git
IRTranslator.h
Go to the documentation of this file.
1//===- llvm/CodeGen/GlobalISel/IRTranslator.h - IRTranslator ----*- 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/// \file
9/// This file declares the IRTranslator pass.
10/// This pass is responsible for translating LLVM IR into MachineInstr.
11/// It uses target hooks to lower the ABI but aside from that, the pass
12/// generated code is generic. This is the default translator used for
13/// GlobalISel.
14///
15/// \todo Replace the comments with actual doxygen comments.
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_CODEGEN_GLOBALISEL_IRTRANSLATOR_H
19#define LLVM_CODEGEN_GLOBALISEL_IRTRANSLATOR_H
20
23#include "llvm/IR/Analysis.h"
24#include "llvm/IR/PassManager.h"
26#include <memory>
27
28namespace llvm {
29
31
32// Technically the pass should run on an hypothetical MachineModule,
33// since it should translate Global into some sort of MachineGlobal.
34// The MachineGlobal should ultimately just be a transfer of ownership of
35// the interesting bits that are relevant to represent a global value.
36// That being said, we could investigate what would it cost to just duplicate
37// the information from the LLVM IR.
38// The idea is that ultimately we would be able to free up the memory used
39// by the LLVM IR as soon as the translation is over.
41public:
42 static char ID;
45
46 StringRef getPassName() const override { return "IRTranslator"; }
47
48 void getAnalysisUsage(AnalysisUsage &AU) const override;
49
50 bool runOnMachineFunction(MachineFunction &MF) override;
51
52private:
53 CodeGenOptLevel OptLevel;
54 std::unique_ptr<IRTranslatorImpl> Impl;
55};
56
57class IRTranslatorPass : public RequiredPassInfoMixin<IRTranslatorPass> {
58 std::unique_ptr<IRTranslatorImpl> Impl;
59
60public:
64
67};
68
69} // end namespace llvm
70
71#endif // LLVM_CODEGEN_GLOBALISEL_IRTRANSLATOR_H
#define LLVM_ABI
Definition Compiler.h:215
This header defines various interfaces for pass management in LLVM.
Represent the analysis usage information of a pass.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
IRTranslatorLegacy(CodeGenOptLevel OptLevel=CodeGenOptLevel::None)
~IRTranslatorLegacy() override
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
IRTranslatorPass(IRTranslatorPass &&)
IRTranslatorPass(CodeGenOptLevel OptLevel)
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:149
A CRTP mix-in for passes that should not be skipped.