aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/include/rcc/CodeGen/TargetCallLowering.h6
-rw-r--r--backend/lib/CodeGen/TargetCallLowering.cpp19
-rw-r--r--backend/lib/Target/RISCV/RISCV.rccdesc4
-rw-r--r--backend/lib/Target/RISCV/RISCVCallLowering.cpp10
-rw-r--r--backend/lib/Target/RISCV/RISCVCodeGen.cpp1
-rw-r--r--backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp10
-rw-r--r--backend/unittests/CodeGen/TargetCallLoweringTest.cpp1
-rw-r--r--backend/unittests/Target/RISCVCallLoweringTest.cpp8
-rw-r--r--backend/unittests/Target/RISCVFrameLoweringTest.cpp2
-rw-r--r--backend/unittests/Target/RISCVLateCodeGenTest.cpp3
10 files changed, 18 insertions, 46 deletions
diff --git a/backend/include/rcc/CodeGen/TargetCallLowering.h b/backend/include/rcc/CodeGen/TargetCallLowering.h
index a6b3535..9d9b98b 100644
--- a/backend/include/rcc/CodeGen/TargetCallLowering.h
+++ b/backend/include/rcc/CodeGen/TargetCallLowering.h
@@ -159,7 +159,6 @@ struct CallLoweringRequest final {
std::vector<ABIValue> Arguments;
std::vector<ABIValue> Results;
std::size_t FixedArgumentCount = 0;
- std::uint64_t CallSiteID = 0;
bool IsVariadic = false;
TailCallKind TailKind = TailCallKind::NotTail;
std::optional<TailCallContext> TailContext;
@@ -306,7 +305,6 @@ struct CallLoweringPlanDesc final {
std::vector<ByValCopyAssignment> ByValCopies;
std::shared_ptr<const RegisterMask> PreservedMask;
std::optional<MachineCallTarget> Callee;
- std::uint64_t CallSiteID = 0;
TailCallKind TailDecision = TailCallKind::NotTail;
std::string TailRejectionReason;
};
@@ -359,10 +357,6 @@ public:
return Description.Callee ? &*Description.Callee : nullptr;
}
- [[nodiscard]] std::uint64_t callSiteID() const noexcept {
- return Description.CallSiteID;
- }
-
[[nodiscard]] TailCallKind tailDecision() const noexcept {
return Description.TailDecision;
}
diff --git a/backend/lib/CodeGen/TargetCallLowering.cpp b/backend/lib/CodeGen/TargetCallLowering.cpp
index d6a14b7..adbe406 100644
--- a/backend/lib/CodeGen/TargetCallLowering.cpp
+++ b/backend/lib/CodeGen/TargetCallLowering.cpp
@@ -246,28 +246,27 @@ Expected<CallLoweringPlan> CallLoweringPlan::create(CallLoweringPlanDesc Descrip
switch (Description.Kind) {
case CallLoweringPlanKind::FormalArguments:
if (!Description.ReturnAssignments.empty() || Description.Callee || Description.PreservedMask ||
- Description.CallSiteID != 0 || Description.TailDecision != TailCallKind::NotTail ||
- Description.CallFrame.EmitSetup || Description.CallFrame.ReusesIncomingArea ||
- !Description.ByValCopies.empty() || !Description.TailRejectionReason.empty()) {
+ Description.TailDecision != TailCallKind::NotTail || Description.CallFrame.EmitSetup ||
+ Description.CallFrame.ReusesIncomingArea || !Description.ByValCopies.empty() ||
+ !Description.TailRejectionReason.empty()) {
return makeUnexpected(ErrorCode::InvalidArgument,
"formal-argument plan contains call or return state");
}
break;
case CallLoweringPlanKind::Return:
if (!Description.ArgumentAssignments.empty() || Description.Callee ||
- Description.PreservedMask || Description.CallSiteID != 0 ||
- Description.TailDecision != TailCallKind::NotTail || Description.CallFrame.EmitSetup ||
- Description.CallFrame.ReusesIncomingArea || !Description.ByValCopies.empty() ||
- Description.VarArgs.IsVariadic || !Description.TailRejectionReason.empty()) {
+ Description.PreservedMask || Description.TailDecision != TailCallKind::NotTail ||
+ Description.CallFrame.EmitSetup || Description.CallFrame.ReusesIncomingArea ||
+ !Description.ByValCopies.empty() || Description.VarArgs.IsVariadic ||
+ !Description.TailRejectionReason.empty()) {
return makeUnexpected(ErrorCode::InvalidArgument,
"return plan contains formal-argument or call state");
}
break;
case CallLoweringPlanKind::Call:
- if (!Description.Callee || !Description.Callee->isValid() || !Description.PreservedMask ||
- Description.CallSiteID == 0) {
+ if (!Description.Callee || !Description.Callee->isValid() || !Description.PreservedMask) {
return makeUnexpected(ErrorCode::InvalidArgument,
- "call plan requires a callee, call-site ID, and preserved mask");
+ "call plan requires a callee and preserved mask");
}
if (Description.TailDecision == TailCallKind::NotTail) {
if (!Description.CallFrame.EmitSetup || Description.CallFrame.ReusesIncomingArea) {
diff --git a/backend/lib/Target/RISCV/RISCV.rccdesc b/backend/lib/Target/RISCV/RISCV.rccdesc
index ea3a775..ad79073 100644
--- a/backend/lib/Target/RISCV/RISCV.rccdesc
+++ b/backend/lib/Target/RISCV/RISCV.rccdesc
@@ -3375,7 +3375,6 @@ instructions:
name: PseudoCALL
operands:
- { kinds: [global_symbol, external_symbol, register], role: use, allowed_target_flags: 1 }
- - { kinds: [immediate, integer_immediate] }
- { kinds: [register_mask] }
num_explicit_defs: 0
implicit_defs: [{ register: X1 }]
@@ -3389,7 +3388,6 @@ instructions:
name: PseudoTAIL
operands:
- { kinds: [global_symbol, external_symbol, register], role: use, allowed_target_flags: 1 }
- - { kinds: [immediate, integer_immediate] }
- { kinds: [register_mask] }
num_explicit_defs: 0
allow_extra_implicit_operands: true
@@ -3416,7 +3414,6 @@ instructions:
- { kinds: [register], role: def, register_class: GPR, register_bank: GPR, name: RD }
- { kinds: [register], role: use, register_class: GPR, register_bank: GPR, name: RS1 }
- { kinds: [immediate, mc_symbol], immediate_predicate: SIMM12, allowed_target_flags: 4, name: IMM }
- - { kinds: [immediate, integer_immediate] }
- { kinds: [register_mask] }
num_explicit_defs: 1
allow_extra_implicit_operands: true
@@ -3434,7 +3431,6 @@ instructions:
- { kinds: [register], role: def, register_class: GPR, register_bank: GPR, name: RD }
- { kinds: [register], role: use, register_class: GPR, register_bank: GPR, name: RS1 }
- { kinds: [immediate, mc_symbol], immediate_predicate: SIMM12, allowed_target_flags: 4, name: IMM }
- - { kinds: [immediate, integer_immediate] }
- { kinds: [register_mask] }
num_explicit_defs: 1
allow_extra_implicit_operands: true
diff --git a/backend/lib/Target/RISCV/RISCVCallLowering.cpp b/backend/lib/Target/RISCV/RISCVCallLowering.cpp
index 3a5805a..308ba05 100644
--- a/backend/lib/Target/RISCV/RISCVCallLowering.cpp
+++ b/backend/lib/Target/RISCV/RISCVCallLowering.cpp
@@ -574,10 +574,8 @@ Expected<CallLoweringPlan> RISCVCallLowering::planCall(const CallLoweringRequest
return makeUnexpected(ErrorCode::InvalidArgument,
"call request has an invalid fixed/variadic argument boundary");
}
- if (Request.CallSiteID == 0 || !Request.Callee.isValid()) {
- return makeUnexpected(ErrorCode::InvalidArgument,
- "call request requires a valid callee and nonzero call-site ID");
- }
+ if (!Request.Callee.isValid())
+ return makeUnexpected(ErrorCode::InvalidArgument, "call request requires a valid callee");
if (hasStructReturn(Request.Arguments) &&
(Request.Arguments.empty() ||
!Request.Arguments.front().Flags.has(ABIValueFlag::StructReturn))) {
@@ -704,7 +702,6 @@ Expected<CallLoweringPlan> RISCVCallLowering::planCall(const CallLoweringRequest
Plan.ByValCopies = std::move(ByValCopies);
Plan.PreservedMask = createCallPreservedMask();
Plan.Callee = std::move(EffectiveCallee);
- Plan.CallSiteID = Request.CallSiteID;
Plan.TailDecision = Decision;
Plan.TailRejectionReason = std::move(RejectionReason);
return CallLoweringPlan::create(std::move(Plan));
@@ -1337,9 +1334,6 @@ emitOutgoingArguments(MachineIRBuilder &Builder, const CallLoweringPlan &Plan,
auto Callee = addCallTarget(*Instruction, *Plan.callee());
if (!Callee)
return std::unexpected(Callee.error());
- auto CallSite = addUnsignedImmediate(*Instruction, Plan.callSiteID());
- if (!CallSite)
- return std::unexpected(CallSite.error());
auto Mask = Instruction->addRegisterMask(Plan.preservedMask());
if (!Mask)
return std::unexpected(Mask.error());
diff --git a/backend/lib/Target/RISCV/RISCVCodeGen.cpp b/backend/lib/Target/RISCV/RISCVCodeGen.cpp
index c9d14af..bd4e20c 100644
--- a/backend/lib/Target/RISCV/RISCVCodeGen.cpp
+++ b/backend/lib/Target/RISCV/RISCVCodeGen.cpp
@@ -1511,7 +1511,6 @@ void eraseDeadArtifacts(std::span<MachineInstr *const> Candidates,
Request.Arguments = {Value(*Left, 0), Value(*Right, 1)};
Request.Results = {Value(*Destination, 0)};
Request.FixedArgumentCount = Request.Arguments.size();
- Request.CallSiteID = Instruction.stableID().value();
MachineIRBuilder Builder(Function, Target);
auto Point = Builder.setInsertPointBefore(Instruction);
diff --git a/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp b/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp
index 8a309e0..ae5e51d 100644
--- a/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp
+++ b/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp
@@ -338,9 +338,8 @@ copyRegisters(const MachineInstr &Instruction) {
const TargetDescription &Target, bool IsTail) {
MachineBasicBlock *Block = Instruction.parent();
const MachineOperand *Callee = Instruction.operandAt(0);
- const MachineOperand *CallSite = Instruction.operandAt(1);
- const MachineOperand *Mask = Instruction.operandAt(2);
- if (Block == nullptr || Callee == nullptr || CallSite == nullptr || Mask == nullptr ||
+ const MachineOperand *Mask = Instruction.operandAt(1);
+ if (Block == nullptr || Callee == nullptr || Mask == nullptr ||
Mask->kind() != MachineOperand::Kind::RegisterMask) {
return makeUnexpected(ErrorCode::VerificationError,
"RISC-V call pseudo has malformed explicit operands");
@@ -409,14 +408,11 @@ copyRegisters(const MachineInstr &Instruction) {
Anchor ? LowPending->addMCSymbol(*Anchor, 0, PCRelativeLowFlag) : LowPending->addImmediate(0);
if (!LowOffset)
return std::unexpected(LowOffset.error());
- auto LowCallSite = LowPending->addOperand(CallSite->cloneDetached());
- if (!LowCallSite)
- return std::unexpected(LowCallSite.error());
auto LowMask = LowPending->addOperand(Mask->cloneDetached());
if (!LowMask)
return std::unexpected(LowMask.error());
auto Implicit = copyExtraImplicitOperands(
- Instruction, 3, *LowPending, IsTail ? std::nullopt : std::optional<PhysicalRegister>{*Link},
+ Instruction, 2, *LowPending, IsTail ? std::nullopt : std::optional<PhysicalRegister>{*Link},
std::nullopt);
if (!Implicit)
return std::unexpected(Implicit.error());
diff --git a/backend/unittests/CodeGen/TargetCallLoweringTest.cpp b/backend/unittests/CodeGen/TargetCallLoweringTest.cpp
index f826285..c5170d0 100644
--- a/backend/unittests/CodeGen/TargetCallLoweringTest.cpp
+++ b/backend/unittests/CodeGen/TargetCallLoweringTest.cpp
@@ -81,7 +81,6 @@ private:
Description.CallFrame.EmitDestroy = true;
Description.PreservedMask = rcc::test::createTestCallPreservedMask();
Description.Callee = *rcc::MachineCallTarget::externalSymbol("callee");
- Description.CallSiteID = 1;
}
return Description;
}
diff --git a/backend/unittests/Target/RISCVCallLoweringTest.cpp b/backend/unittests/Target/RISCVCallLoweringTest.cpp
index 1eaf146..7284887 100644
--- a/backend/unittests/Target/RISCVCallLoweringTest.cpp
+++ b/backend/unittests/Target/RISCVCallLoweringTest.cpp
@@ -176,7 +176,6 @@ abiValue(rcc::LLT Type, std::uint32_t OriginalValue, rcc::Register Value = plann
Request.Callee = externalTarget();
Request.Arguments = std::move(Arguments);
Request.FixedArgumentCount = FixedArgumentCount;
- Request.CallSiteID = 17;
Request.IsVariadic = IsVariadic;
return Request;
}
@@ -491,14 +490,13 @@ void testOrdinaryAndIndirectEmission(TestContext &Context) {
opcode(rcc::riscv::InstructionOpcode::ADJCALLSTACKDOWN) &&
Instructions[1]->opcode() == rcc::opcode(rcc::GenericOpcode::COPY) &&
Instructions.back()->opcode() == rcc::opcode(rcc::GenericOpcode::COPY) &&
- Call != nullptr && Call->operandCount() >= 6 &&
+ Call != nullptr && Call->operandCount() >= 5 &&
Call->operandAt(0)->kind() == rcc::MachineOperand::Kind::ExternalSymbol &&
Call->operandAt(0)->targetFlags() ==
static_cast<std::uint32_t>(rcc::riscv::CallTargetFlag::DirectCall) &&
- Call->operandAt(1)->kind() == rcc::MachineOperand::Kind::IntegerImmediate &&
- Call->operandAt(2)->kind() == rcc::MachineOperand::Kind::RegisterMask,
+ Call->operandAt(1)->kind() == rcc::MachineOperand::Kind::RegisterMask,
"ordinary emission must materialize canonical full-value copies, call-frame, "
- "target, ID, and RegMask");
+ "target, and RegMask");
const rcc::Register StackPointer =
rcc::Register::fromPhysical(physical(rcc::riscv::PhysicalRegisterID::X2));
const auto HasStackPointerEffects = [StackPointer](const rcc::MachineInstr *Instruction) {
diff --git a/backend/unittests/Target/RISCVFrameLoweringTest.cpp b/backend/unittests/Target/RISCVFrameLoweringTest.cpp
index 95d6a18..0525a6d 100644
--- a/backend/unittests/Target/RISCVFrameLoweringTest.cpp
+++ b/backend/unittests/Target/RISCVFrameLoweringTest.cpp
@@ -391,8 +391,6 @@ buildIndirectTail(rcc::MachineFunction &Function, const rcc::TargetDescription &
return std::unexpected(Pending.error());
if (auto Result = Pending->addUse(Callee); !Result)
return std::unexpected(Result.error());
- if (auto Result = Pending->addImmediate(1); !Result)
- return std::unexpected(Result.error());
if (auto Result = Pending->addRegisterMask(std::move(Mask)); !Result)
return std::unexpected(Result.error());
return Pending->build();
diff --git a/backend/unittests/Target/RISCVLateCodeGenTest.cpp b/backend/unittests/Target/RISCVLateCodeGenTest.cpp
index b9479b2..84ed796 100644
--- a/backend/unittests/Target/RISCVLateCodeGenTest.cpp
+++ b/backend/unittests/Target/RISCVLateCodeGenTest.cpp
@@ -1130,8 +1130,7 @@ void testPostRAPseudoExpansionAndFinalization(TestContext &Context,
}
auto Call = Builder.buildInstr(opcode(rcc::riscv::InstructionOpcode::PseudoCALL));
auto Preserved = rcc::riscv::createCallPreservedMask();
- if (!Call || !Call->addExternalSymbol("callee", 0, 1) || !Call->addImmediate(11) ||
- !Call->addRegisterMask(Preserved) ||
+ if (!Call || !Call->addExternalSymbol("callee", 0, 1) || !Call->addRegisterMask(Preserved) ||
!Call->addImplicitUse(physical(rcc::riscv::PhysicalRegisterID::X10)) || !Call->build()) {
Context.expect(false, "post-RA call pseudo construction must succeed");
return;