diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-15 03:36:58 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-15 03:36:58 +0800 |
| commit | 5e2a50330a643b4580a94b68b1d68107ec4e1e87 (patch) | |
| tree | f7116245d9c538588a875128522f43a59c78dba3 /backend/include/rcc/CodeGen | |
| parent | 2eb438cac7bdd3abb43ae1a784e8eb20d77cf7b7 (diff) | |
| download | rcc-project-5e2a50330a643b4580a94b68b1d68107ec4e1e87.tar.gz rcc-project-5e2a50330a643b4580a94b68b1d68107ec4e1e87.tar.xz | |
[GlobalISel] Lower integer operations to libcalls
Diffstat (limited to 'backend/include/rcc/CodeGen')
| -rw-r--r-- | backend/include/rcc/CodeGen/GlobalISel/Legalizer.h | 18 | ||||
| -rw-r--r-- | backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h | 6 | ||||
| -rw-r--r-- | backend/include/rcc/CodeGen/TargetCallLowering.h | 5 |
3 files changed, 22 insertions, 7 deletions
diff --git a/backend/include/rcc/CodeGen/GlobalISel/Legalizer.h b/backend/include/rcc/CodeGen/GlobalISel/Legalizer.h index 358ed1a..2ba0012 100644 --- a/backend/include/rcc/CodeGen/GlobalISel/Legalizer.h +++ b/backend/include/rcc/CodeGen/GlobalISel/Legalizer.h @@ -6,6 +6,7 @@ #include "rcc/CodeGen/CommandFlags.h" #include "rcc/CodeGen/GlobalISel/LegalizerInfo.h" #include "rcc/CodeGen/MachinePassManager.h" +#include "rcc/CodeGen/TargetCallLowering.h" #include <memory> @@ -13,12 +14,16 @@ namespace rcc { class Legalizer final : public MachineFunctionPass { public: - Legalizer(const LegalizerInfo *Info, OptimizationLevel Optimization) - : Info(Info), Optimization(Optimization) {} - Legalizer(const LegalizerInfo &Info, OptimizationLevel Optimization) - : Info(&Info), Optimization(Optimization) {} - Legalizer(std::unique_ptr<LegalizerInfo> Info, OptimizationLevel Optimization) - : OwnedInfo(std::move(Info)), Info(OwnedInfo.get()), Optimization(Optimization) {} + Legalizer(const LegalizerInfo *Info, OptimizationLevel Optimization, + LibcallLoweringInfo Libcalls = {}) + : Info(Info), Optimization(Optimization), Libcalls(Libcalls) {} + Legalizer(const LegalizerInfo &Info, OptimizationLevel Optimization, + LibcallLoweringInfo Libcalls = {}) + : Info(&Info), Optimization(Optimization), Libcalls(Libcalls) {} + Legalizer(std::unique_ptr<LegalizerInfo> Info, OptimizationLevel Optimization, + LibcallLoweringInfo Libcalls = {}) + : OwnedInfo(std::move(Info)), Info(OwnedInfo.get()), Optimization(Optimization), + Libcalls(Libcalls) {} [[nodiscard]] const MachinePassContract &contract() const noexcept override; [[nodiscard]] Expected<MachinePassResult> run(MachineFunction &Function, @@ -33,6 +38,7 @@ private: std::unique_ptr<LegalizerInfo> OwnedInfo; const LegalizerInfo *Info = nullptr; OptimizationLevel Optimization; + LibcallLoweringInfo Libcalls; }; } // namespace rcc diff --git a/backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h b/backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h index 9ad66a2..39304ba 100644 --- a/backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h +++ b/backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h @@ -15,6 +15,7 @@ namespace rcc { class MachineFunction; class MachineInstr; class GISelChangeObserver; +struct LibcallLoweringInfo; class LegalizerHelper final { public: @@ -22,7 +23,8 @@ public: GISelChangeObserver &Observer; LegalizerHelper(MachineFunction &Function, const LegalizerInfo &Info, - GISelChangeObserver &Observer, MachineIRBuilder &MIRBuilder); + GISelChangeObserver &Observer, MachineIRBuilder &MIRBuilder, + const LibcallLoweringInfo *Libcalls = nullptr); [[nodiscard]] Expected<void> legalize(MachineInstr &Instruction, const LegalizationDecision &Decision); @@ -35,6 +37,7 @@ public: [[nodiscard]] Expected<void> lowerThreewayCompare(MachineInstr &Instruction); [[nodiscard]] Expected<void> lowerRotate(MachineInstr &Instruction); [[nodiscard]] Expected<void> lowerVAArg(MachineInstr &Instruction); + [[nodiscard]] Expected<void> libcall(MachineInstr &Instruction); [[nodiscard]] Expected<void> widenScalar(MachineInstr &Instruction, std::size_t TypeIndex, LowLevelType WideType); [[nodiscard]] Expected<void> widenScalarSrc(MachineInstr &Instruction, LowLevelType WideType, @@ -118,6 +121,7 @@ private: MachineFunction &Function; MachineRegisterInfo &MRI; const LegalizerInfo &Info; + const LibcallLoweringInfo *Libcalls = nullptr; }; } // namespace rcc diff --git a/backend/include/rcc/CodeGen/TargetCallLowering.h b/backend/include/rcc/CodeGen/TargetCallLowering.h index 21b5407..576ec39 100644 --- a/backend/include/rcc/CodeGen/TargetCallLowering.h +++ b/backend/include/rcc/CodeGen/TargetCallLowering.h @@ -402,6 +402,11 @@ public: const CallLoweringPlan &Plan) const = 0; }; +struct LibcallLoweringInfo final { + const TargetCallLowering *CallLowering = nullptr; + CallingConventionID Convention; +}; + } // namespace rcc #endif // RCC_CODEGEN_TARGETCALLLOWERING_H |
