From 787f3a7a20958bfa6f231abccc617f4d8de25c4d Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 1 Aug 2026 17:36:40 +0800 Subject: [CodeGen] Add MIR function and block attributes --- backend/lib/CodeGen/MachineIRTypes.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'backend/lib/CodeGen/MachineIRTypes.cpp') diff --git a/backend/lib/CodeGen/MachineIRTypes.cpp b/backend/lib/CodeGen/MachineIRTypes.cpp index 7f97e98..b5348b3 100644 --- a/backend/lib/CodeGen/MachineIRTypes.cpp +++ b/backend/lib/CodeGen/MachineIRTypes.cpp @@ -2,8 +2,17 @@ #include "rcc/CodeGen/MachineIRTypes.h" +#include + namespace rcc { +Expected Alignment::create(std::uint64_t Bytes) { + if (!std::has_single_bit(Bytes)) { + return makeUnexpected(ErrorCode::InvalidArgument, "alignment must be a nonzero power of two"); + } + return Alignment(Bytes); +} + Expected BranchProbability::fromFraction(std::uint32_t Numerator, std::uint32_t Denominator) { if (Denominator == 0) { -- cgit v1.2.3