aboutsummaryrefslogtreecommitdiff
path: root/backend/include
diff options
context:
space:
mode:
Diffstat (limited to 'backend/include')
-rw-r--r--backend/include/rcc/CodeGen/GlobalISel/GIMatchTableExecutor.h25
-rw-r--r--backend/include/rcc/CodeGen/GlobalISel/GISelValueTracking.h6
-rw-r--r--backend/include/rcc/TableGen/Record.h18
3 files changed, 46 insertions, 3 deletions
diff --git a/backend/include/rcc/CodeGen/GlobalISel/GIMatchTableExecutor.h b/backend/include/rcc/CodeGen/GlobalISel/GIMatchTableExecutor.h
index afd0d70..fbbf68f 100644
--- a/backend/include/rcc/CodeGen/GlobalISel/GIMatchTableExecutor.h
+++ b/backend/include/rcc/CodeGen/GlobalISel/GIMatchTableExecutor.h
@@ -4,11 +4,14 @@
#define RCC_CODEGEN_GLOBALISEL_GIMATCHTABLEEXECUTOR_H
#include "rcc/CodeGen/MachineIRTypes.h"
+#include "rcc/CodeGen/MachineOperand.h"
#include "rcc/Support/Error.h"
#include <cstdint>
+#include <optional>
#include <span>
#include <string_view>
+#include <vector>
namespace rcc {
@@ -35,10 +38,15 @@ enum class GIMatchTableOpcode : std::uint8_t {
CheckOperandClass,
CheckIntegerPredicate,
CheckOperandDefConstantRanges,
+ CheckOperandDefOpcode,
+ CheckOperandDefOperandConstantRanges,
+ CaptureDefOperand,
CreateTemporary,
MutateOpcode,
BuildInstruction,
RenderOperand,
+ RenderComplexOperand,
+ RenderCapturedOperand,
RenderPhysicalRegister,
RenderTemporary,
RenderCapturedImmediate,
@@ -53,6 +61,18 @@ struct GIMatchTableInstruction final {
std::uint32_t Value = 0;
std::uint32_t Auxiliary = 0;
std::int64_t Immediate = 0;
+ std::string_view Symbol;
+};
+
+struct GIMatchComplexInstruction final {
+ Opcode ResultOpcode;
+ LowLevelType ResultType;
+ std::vector<MachineOperand> Operands;
+};
+
+struct GIMatchComplexOperand final {
+ std::optional<MachineOperand> Operand;
+ std::optional<GIMatchComplexInstruction> Instruction;
};
struct GIMatchTableConstantRange final {
@@ -88,6 +108,11 @@ public:
const TargetDescription &Target) const;
protected:
+ [[nodiscard]] virtual Expected<std::optional<GIMatchComplexOperand>>
+ renderComplexOperand(std::string_view Name, const MachineInstr &Instruction,
+ const MachineFunction &Function, const TargetDescription &Target,
+ std::uint32_t OperandIndex) const;
+
[[nodiscard]] virtual Expected<void>
finalizeGeneratedInstruction(MachineInstr &Output, MachineFunction &Function,
const TargetDescription &Target, MachineInstrFlags InputFlags,
diff --git a/backend/include/rcc/CodeGen/GlobalISel/GISelValueTracking.h b/backend/include/rcc/CodeGen/GlobalISel/GISelValueTracking.h
index aa02fe3..e51f8c1 100644
--- a/backend/include/rcc/CodeGen/GlobalISel/GISelValueTracking.h
+++ b/backend/include/rcc/CodeGen/GlobalISel/GISelValueTracking.h
@@ -18,7 +18,7 @@ class TargetDescription;
class GISelValueTracking final : public GISelChangeObserver {
public:
- GISelValueTracking(MachineFunction &Function, const TargetDescription &Target,
+ GISelValueTracking(const MachineFunction &Function, const TargetDescription &Target,
unsigned MaxDepth = 6) noexcept;
[[nodiscard]] const MachineFunction &getMachineFunction() const noexcept {
@@ -42,8 +42,8 @@ private:
[[nodiscard]] Expected<KnownBits> makeUnknown(std::uint32_t BitWidth) const;
[[nodiscard]] Expected<KnownBits> getKnownBits(Register Reg, unsigned Depth = 0) const;
- MachineFunction &Function;
- MachineRegisterInfo &MRI;
+ const MachineFunction &Function;
+ const MachineRegisterInfo &MRI;
const TargetDescription &Target;
unsigned MaxDepth;
};
diff --git a/backend/include/rcc/TableGen/Record.h b/backend/include/rcc/TableGen/Record.h
index 57e5832..6575b82 100644
--- a/backend/include/rcc/TableGen/Record.h
+++ b/backend/include/rcc/TableGen/Record.h
@@ -247,6 +247,20 @@ struct SourceSelectionOperandDefConstantPredicate final {
TextRange Range;
};
+struct SourceSelectionDefUseCapture final {
+ std::string Symbol;
+ std::uint32_t OperandIndex = 0;
+ TextRange Range;
+};
+
+struct SourceSelectionDefUsePredicate final {
+ std::uint32_t RootOperandIndex = 0;
+ std::string OpcodeSymbol;
+ std::vector<SourceSelectionDefUseCapture> Captures;
+ std::vector<SourceSelectionOperandDefConstantPredicate> OperandDefConstants;
+ TextRange Range;
+};
+
struct SourceSelectionTemporary final {
std::string Symbol;
std::uint32_t TypeFromOperand = 0;
@@ -255,8 +269,11 @@ struct SourceSelectionTemporary final {
struct SourceSelectionOperandRenderer final {
std::optional<std::uint32_t> OperandIndex;
+ std::optional<std::uint32_t> ComplexOperandIndex;
std::string PhysicalRegisterSymbol;
+ std::string ComplexRendererSymbol;
std::string TemporarySymbol;
+ std::string CapturedOperandSymbol;
std::optional<std::uint32_t> CapturedImmediateOperand;
std::optional<std::int64_t> Immediate;
std::string ImmediateTransform;
@@ -281,6 +298,7 @@ struct SourceSelectionRule final {
std::vector<SourceSelectionOperandBankPredicate> OperandBanks;
std::vector<SourceSelectionOperandClassPredicate> OperandClasses;
std::vector<SourceSelectionOperandDefConstantPredicate> OperandDefConstants;
+ std::vector<SourceSelectionDefUsePredicate> DefUsePredicates;
std::vector<SourceSelectionTemporary> Temporaries;
std::vector<SourceSelectionAction> Actions;
std::vector<std::uint32_t> EraseOperandDefinitions;