From cfdbcc469f9691bd9dce3b0b86982a63d86ca6b7 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 1 Aug 2026 14:50:04 +0800 Subject: [CodeGen] Add target state and compilation status --- backend/lib/CodeGen/MachineFunction.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'backend/lib/CodeGen/MachineFunction.cpp') diff --git a/backend/lib/CodeGen/MachineFunction.cpp b/backend/lib/CodeGen/MachineFunction.cpp index 64b6440..294158b 100644 --- a/backend/lib/CodeGen/MachineFunction.cpp +++ b/backend/lib/CodeGen/MachineFunction.cpp @@ -75,6 +75,17 @@ MachineFunction::~MachineFunction() { } } +Expected MachineFunction::setTargetState(TargetFunctionState State) { + if (TargetState.hasValue()) { + return makeUnexpected(ErrorCode::InvalidArgument, "machine function already has target state"); + } + auto Verification = State.verify(); + if (!Verification) + return std::unexpected(Verification.error()); + TargetState = std::move(State); + return {}; +} + Expected MachineFunction::createBasicBlock() { auto ID = BlockIDGenerator.allocate(); if (!ID) -- cgit v1.2.3