aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/CodeGen/MachineOperand.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-08 04:14:34 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-08 04:14:34 +0800
commit77884c967d1cbc48afcbaef7e5a35adcb3c5da1b (patch)
tree8cc31c1c5115ed909ec9f8751964bfdc96fbd4ad /backend/lib/CodeGen/MachineOperand.cpp
parent10b7e69448f866bcd6893b21d7f78d766252eb11 (diff)
downloadrcc-project-77884c967d1cbc48afcbaef7e5a35adcb3c5da1b.tar.gz
rcc-project-77884c967d1cbc48afcbaef7e5a35adcb3c5da1b.tar.xz
[CodeGen] Implement machine SSA exit
Diffstat (limited to 'backend/lib/CodeGen/MachineOperand.cpp')
-rw-r--r--backend/lib/CodeGen/MachineOperand.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/backend/lib/CodeGen/MachineOperand.cpp b/backend/lib/CodeGen/MachineOperand.cpp
index ae46505..43a4f91 100644
--- a/backend/lib/CodeGen/MachineOperand.cpp
+++ b/backend/lib/CodeGen/MachineOperand.cpp
@@ -2,6 +2,7 @@
#include "rcc/CodeGen/MachineOperand.h"
+#include "rcc/CodeGen/MachineBasicBlock.h"
#include "rcc/CodeGen/MachineFunction.h"
#include "rcc/CodeGen/MachineInstr.h"
#include "rcc/CodeGen/MachineRegisterInfo.h"
@@ -172,8 +173,7 @@ std::string IntegerImmediate::toUnsignedDecimal() const {
return "0";
std::vector<std::uint64_t> Remaining = Words;
std::string Digits;
- while (!std::ranges::all_of(Remaining,
- [](std::uint64_t Word) { return Word == 0; })) {
+ while (!std::ranges::all_of(Remaining, [](std::uint64_t Word) { return Word == 0; })) {
unsigned __int128 Remainder = 0;
for (auto Iterator = Remaining.rbegin(); Iterator != Remaining.rend(); ++Iterator) {
const unsigned __int128 Dividend = (Remainder << 64U) | *Iterator;
@@ -537,6 +537,17 @@ Expected<void> MachineOperand::setSubReg(SubRegIndex SubReg) {
return {};
}
+Expected<void> MachineOperand::setBasicBlock(MachineBasicBlock &Block) {
+ if (OperandKind != Kind::BasicBlock)
+ return makeUnexpected(ErrorCode::InvalidArgument,
+ "setBasicBlock requires a basic-block operand");
+ if (Parent != nullptr && &Block.function() != &Parent->function())
+ return makeUnexpected(ErrorCode::InvalidArgument,
+ "basic-block operand references another machine function");
+ std::get<BasicBlockOperand>(Storage).Block = &Block;
+ return {};
+}
+
MachineOperand MachineOperand::cloneDetached() const {
MachineOperand Result(OperandKind, Storage, TargetFlags);
Result.RegFlags = RegFlags;