aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/Tooling
diff options
context:
space:
mode:
Diffstat (limited to 'backend/include/rcc/Tooling')
-rw-r--r--backend/include/rcc/Tooling/BackendDriver.h14
-rw-r--r--backend/include/rcc/Tooling/BackendInvocation.h18
-rw-r--r--backend/include/rcc/Tooling/PipelineDriver.h6
3 files changed, 15 insertions, 23 deletions
diff --git a/backend/include/rcc/Tooling/BackendDriver.h b/backend/include/rcc/Tooling/BackendDriver.h
index 8117a0c..2003983 100644
--- a/backend/include/rcc/Tooling/BackendDriver.h
+++ b/backend/include/rcc/Tooling/BackendDriver.h
@@ -13,11 +13,7 @@
#include <string_view>
#include <vector>
-namespace rcc {
-
-class TargetDescription;
-
-namespace tooling {
+namespace rcc::tooling {
struct BackendRunResult final {
ArtifactKind Kind = ArtifactKind::FinalMIR;
@@ -29,11 +25,9 @@ struct BackendRunResult final {
};
[[nodiscard]] Expected<BackendRunResult>
-runBackend(CanonicalMIR Input, const TargetDescription &Target, const BackendInvocation &Invocation,
- ArtifactKind Output, PipelineControls Controls = {},
- MachinePassInstrumentation *Instrumentation = nullptr);
+runBackend(CanonicalMIR Input, const BackendInvocation &Invocation, ArtifactKind Output,
+ PipelineControls Controls = {}, MachinePassInstrumentation *Instrumentation = nullptr);
-} // namespace tooling
-} // namespace rcc
+} // namespace rcc::tooling
#endif // RCC_TOOLING_BACKENDDRIVER_H
diff --git a/backend/include/rcc/Tooling/BackendInvocation.h b/backend/include/rcc/Tooling/BackendInvocation.h
index 504dc3a..c50148a 100644
--- a/backend/include/rcc/Tooling/BackendInvocation.h
+++ b/backend/include/rcc/Tooling/BackendInvocation.h
@@ -5,8 +5,10 @@
#include "rcc/CodeGen/CommandFlags.h"
#include "rcc/Support/Error.h"
+#include "rcc/Target/TargetOptions.h"
#include <cstdint>
+#include <memory>
#include <optional>
#include <span>
#include <string>
@@ -16,6 +18,8 @@
namespace rcc {
class TargetDescription;
+class Target;
+class TargetMachine;
namespace tooling {
@@ -23,7 +27,6 @@ inline constexpr std::uint32_t BackendInvocationSchemaVersion = 1;
inline constexpr std::string_view LLVMReferenceRevision =
"2b40c303e79f64c5c7642032554eda026594d604";
inline constexpr std::string_view GenericOpcodeReferenceVersion = "rcc-generic-opcode-v1";
-inline constexpr std::string_view RV64GCTargetABILoweringVersion = "rcc-rv64gc-lp64d-v1";
inline constexpr std::string_view CompilerBuildFingerprint = "rcc-backend-0.1.0-stage17";
enum class LayoutOwnership : std::uint8_t {
@@ -32,12 +35,7 @@ enum class LayoutOwnership : std::uint8_t {
ExternalRelaxation,
};
-struct BackendOption final {
- std::string Name;
- std::string Value;
-
- friend bool operator==(const BackendOption &, const BackendOption &) = default;
-};
+using BackendOption = TargetOption;
struct DeterminismOptions final {
std::uint64_t RandomSeed = 0;
@@ -69,7 +67,7 @@ struct BackendInvocation final {
std::vector<std::string> EnabledActions;
std::string MIRReferenceRevision{LLVMReferenceRevision};
std::string GenericOpcodeVersion{GenericOpcodeReferenceVersion};
- std::string TargetABILoweringVersion{RV64GCTargetABILoweringVersion};
+ std::string TargetABILoweringVersion;
std::string BuildFingerprint{CompilerBuildFingerprint};
[[nodiscard]] Expected<void> canonicalizeAndVerify();
@@ -78,7 +76,9 @@ struct BackendInvocation final {
friend bool operator==(const BackendInvocation &, const BackendInvocation &) = default;
};
-[[nodiscard]] BackendInvocation defaultRV64GCInvocation();
+[[nodiscard]] Expected<BackendInvocation> defaultBackendInvocation(const Target &Target);
+[[nodiscard]] Expected<std::unique_ptr<TargetMachine>>
+createTargetMachine(const BackendInvocation &Invocation);
[[nodiscard]] Expected<std::string>
computeTargetDescriptionFingerprint(const TargetDescription &Target);
[[nodiscard]] Expected<std::string> computeCacheKey(std::string_view CanonicalMIR,
diff --git a/backend/include/rcc/Tooling/PipelineDriver.h b/backend/include/rcc/Tooling/PipelineDriver.h
index c01650c..ce88e64 100644
--- a/backend/include/rcc/Tooling/PipelineDriver.h
+++ b/backend/include/rcc/Tooling/PipelineDriver.h
@@ -5,6 +5,7 @@
#include "rcc/CodeGen/MIRParser/MIRParser.h"
#include "rcc/CodeGen/MachinePassManager.h"
+#include "rcc/Target/TargetMachine.h"
#include "rcc/Tooling/BackendInvocation.h"
#include <cstdint>
@@ -15,8 +16,6 @@
namespace rcc {
-class TargetDescription;
-
namespace tooling {
enum class BackendStage : std::uint8_t {
@@ -72,9 +71,8 @@ struct PipelineRunResult final {
std::vector<PipelineSnapshot> Snapshots;
};
-[[nodiscard]] Expected<void> verifyRV64GCInvocation(const BackendInvocation &Invocation);
[[nodiscard]] Expected<PipelineRunResult>
-runRV64GCPipeline(mir::MIRDocument &Document, const TargetDescription &Target,
+runTargetPipeline(mir::MIRDocument &Document, const TargetMachine &TargetMachine,
const BackendInvocation &Invocation, PipelineControls Controls = {},
MachinePassInstrumentation *Instrumentation = nullptr);
[[nodiscard]] BackendStage stageForFunction(const MachineFunction &Function) noexcept;