diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-15 04:48:16 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-15 04:48:16 +0800 |
| commit | 32a365a2dc0096b4421fb3947b32d971b7f34c40 (patch) | |
| tree | 54f8d77af09aaf586b672f59a815646bf5e8f7bb /backend/include | |
| parent | bb7990a58f56f8fb9bae4d5eb01fbbe3c36fca77 (diff) | |
| download | rcc-project-32a365a2dc0096b4421fb3947b32d971b7f34c40.tar.gz rcc-project-32a365a2dc0096b4421fb3947b32d971b7f34c40.tar.xz | |
[GlobalISel] Lower stack operations
Diffstat (limited to 'backend/include')
| -rw-r--r-- | backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h | 3 | ||||
| -rw-r--r-- | backend/include/rcc/CodeGen/TargetDescription.h | 32 |
2 files changed, 30 insertions, 5 deletions
diff --git a/backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h b/backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h index 71ead8b..3e14311 100644 --- a/backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h +++ b/backend/include/rcc/CodeGen/GlobalISel/LegalizerHelper.h @@ -39,6 +39,9 @@ public: [[nodiscard]] Expected<void> lowerBitCount(MachineInstr &Instruction); [[nodiscard]] Expected<void> lowerBswap(MachineInstr &Instruction); [[nodiscard]] Expected<void> lowerRotate(MachineInstr &Instruction); + [[nodiscard]] Expected<void> lowerDynStackAlloc(MachineInstr &Instruction); + [[nodiscard]] Expected<void> lowerStackSave(MachineInstr &Instruction); + [[nodiscard]] Expected<void> lowerStackRestore(MachineInstr &Instruction); [[nodiscard]] Expected<void> lowerVAArg(MachineInstr &Instruction); [[nodiscard]] Expected<void> libcall(MachineInstr &Instruction); [[nodiscard]] Expected<void> widenScalar(MachineInstr &Instruction, std::size_t TypeIndex, diff --git a/backend/include/rcc/CodeGen/TargetDescription.h b/backend/include/rcc/CodeGen/TargetDescription.h index 56d328e..6504ba8 100644 --- a/backend/include/rcc/CodeGen/TargetDescription.h +++ b/backend/include/rcc/CodeGen/TargetDescription.h @@ -36,6 +36,16 @@ struct TargetBooleanContentInfo final { BooleanContent Vector = BooleanContent::Undefined; }; +enum class StackGrowthDirection : std::uint8_t { + Down, + Up, +}; + +struct TargetStackInfo final { + PhysicalRegister StackPointerRegisterToSaveRestore; + StackGrowthDirection GrowthDirection = StackGrowthDirection::Down; +}; + class TargetDescription final { public: TargetDescription(const TargetDescription &) = delete; @@ -44,9 +54,11 @@ public: TargetDescription &operator=(TargetDescription &&) noexcept = default; ~TargetDescription() = default; - [[nodiscard]] static Expected<TargetDescription> - create(InstructionSet Instructions, TargetRegisterInfo Registers, - TargetMIRTextInfoDesc MIRText = {}, TargetBooleanContentInfo BooleanInfo = {}); + [[nodiscard]] static Expected<TargetDescription> create(InstructionSet Instructions, + TargetRegisterInfo Registers, + TargetMIRTextInfoDesc MIRText = {}, + TargetBooleanContentInfo BooleanInfo = {}, + TargetStackInfo StackInfo = {}); [[nodiscard]] const InstructionSet &instructions() const noexcept { return Instructions; @@ -67,6 +79,14 @@ public: return IsFloatingPoint ? BooleanInfo.ScalarFloatingPoint : BooleanInfo.ScalarInteger; } + [[nodiscard]] PhysicalRegister stackPointerRegisterToSaveRestore() const noexcept { + return StackInfo.StackPointerRegisterToSaveRestore; + } + + [[nodiscard]] StackGrowthDirection stackGrowthDirection() const noexcept { + return StackInfo.GrowthDirection; + } + [[nodiscard]] const InstructionDescriptor * instructionDescriptor(Opcode InstructionOpcode) const noexcept { return Instructions.descriptor(InstructionOpcode); @@ -107,9 +127,10 @@ public: private: TargetDescription(InstructionSet Instructions, TargetRegisterInfo Registers, - TargetMIRTextInfo MIRText, TargetBooleanContentInfo BooleanInfo) + TargetMIRTextInfo MIRText, TargetBooleanContentInfo BooleanInfo, + TargetStackInfo StackInfo) : Instructions(std::move(Instructions)), Registers(std::move(Registers)), - MIRText(std::move(MIRText)), BooleanInfo(BooleanInfo) {} + MIRText(std::move(MIRText)), BooleanInfo(BooleanInfo), StackInfo(StackInfo) {} [[nodiscard]] Expected<void> validateTargetOperand(const OperandDescriptor *Descriptor, const MachineOperand &Operand, @@ -122,6 +143,7 @@ private: TargetRegisterInfo Registers; TargetMIRTextInfo MIRText; TargetBooleanContentInfo BooleanInfo; + TargetStackInfo StackInfo; }; } // namespace rcc |
