Skip to content

Commit e4d9380

Browse files
committed
Revert "[RISCV] Add GHC calling convention"
This reverts commit f8317bb due to lack of proper attribution.
1 parent 73c181c commit e4d9380

File tree

5 files changed

+3
-305
lines changed

5 files changed

+3
-305
lines changed

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,6 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF,
325325
// to determine the end of the prologue.
326326
DebugLoc DL;
327327

328-
// All calls are tail calls in GHC calling conv, and functions have no
329-
// prologue/epilogue.
330-
if (MF.getFunction().getCallingConv() == CallingConv::GHC)
331-
return;
332-
333328
// Emit prologue for shadow call stack.
334329
emitSCSPrologue(MF, MBB, MBBI, DL);
335330

@@ -505,11 +500,6 @@ void RISCVFrameLowering::emitEpilogue(MachineFunction &MF,
505500
Register FPReg = getFPReg(STI);
506501
Register SPReg = getSPReg(STI);
507502

508-
// All calls are tail calls in GHC calling conv, and functions have no
509-
// prologue/epilogue.
510-
if (MF.getFunction().getCallingConv() == CallingConv::GHC)
511-
return;
512-
513503
// Get the insert location for the epilogue. If there were no terminators in
514504
// the block, get the last instruction.
515505
MachineBasicBlock::iterator MBBI = MBB.end();

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,6 @@ SDValue RISCVTargetLowering::lowerGlobalTLSAddress(SDValue Op,
665665

666666
TLSModel::Model Model = getTargetMachine().getTLSModel(N->getGlobal());
667667

668-
if (DAG.getMachineFunction().getFunction().getCallingConv() ==
669-
CallingConv::GHC)
670-
report_fatal_error("In GHC calling convention TLS is not supported");
671-
672668
SDValue Addr;
673669
switch (Model) {
674670
case TLSModel::LocalExec:
@@ -2244,71 +2240,22 @@ static bool CC_RISCV_FastCC(unsigned ValNo, MVT ValVT, MVT LocVT,
22442240
return true; // CC didn't match.
22452241
}
22462242

2247-
static bool CC_RISCV_GHC(unsigned ValNo, MVT ValVT, MVT LocVT,
2248-
CCValAssign::LocInfo LocInfo,
2249-
ISD::ArgFlagsTy ArgFlags, CCState &State) {
2250-
2251-
if (LocVT == MVT::i32 || LocVT == MVT::i64) {
2252-
// Pass in STG registers: Base, Sp, Hp, R1, R2, R3, R4, R5, R6, R7, SpLim
2253-
// s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11
2254-
static const MCPhysReg GPRList[] = {
2255-
RISCV::X9, RISCV::X18, RISCV::X19, RISCV::X20, RISCV::X21, RISCV::X22,
2256-
RISCV::X23, RISCV::X24, RISCV::X25, RISCV::X26, RISCV::X27};
2257-
if (unsigned Reg = State.AllocateReg(GPRList)) {
2258-
State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
2259-
return false;
2260-
}
2261-
}
2262-
2263-
if (LocVT == MVT::f32) {
2264-
// Pass in STG registers: F1, ..., F6
2265-
// fs0 ... fs5
2266-
static const MCPhysReg FPR32List[] = {RISCV::F8_F, RISCV::F9_F,
2267-
RISCV::F18_F, RISCV::F19_F,
2268-
RISCV::F20_F, RISCV::F21_F};
2269-
if (unsigned Reg = State.AllocateReg(FPR32List)) {
2270-
State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
2271-
return false;
2272-
}
2273-
}
2274-
2275-
if (LocVT == MVT::f64) {
2276-
// Pass in STG registers: D1, ..., D6
2277-
// fs6 ... fs11
2278-
static const MCPhysReg FPR64List[] = {RISCV::F22_D, RISCV::F23_D,
2279-
RISCV::F24_D, RISCV::F25_D,
2280-
RISCV::F26_D, RISCV::F27_D};
2281-
if (unsigned Reg = State.AllocateReg(FPR64List)) {
2282-
State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
2283-
return false;
2284-
}
2285-
}
2286-
2287-
report_fatal_error("No registers left in GHC calling convention");
2288-
return true;
2289-
}
2290-
22912243
// Transform physical registers into virtual registers.
22922244
SDValue RISCVTargetLowering::LowerFormalArguments(
22932245
SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
22942246
const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &DL,
22952247
SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const {
22962248

2297-
MachineFunction &MF = DAG.getMachineFunction();
2298-
22992249
switch (CallConv) {
23002250
default:
23012251
report_fatal_error("Unsupported calling convention");
23022252
case CallingConv::C:
23032253
case CallingConv::Fast:
23042254
break;
2305-
case CallingConv::GHC:
2306-
if (!MF.getSubtarget().getFeatureBits()[RISCV::FeatureStdExtF] ||
2307-
!MF.getSubtarget().getFeatureBits()[RISCV::FeatureStdExtD])
2308-
report_fatal_error(
2309-
"GHC calling convention requires the F and D instruction set extensions");
23102255
}
23112256

2257+
MachineFunction &MF = DAG.getMachineFunction();
2258+
23122259
const Function &Func = MF.getFunction();
23132260
if (Func.hasFnAttribute("interrupt")) {
23142261
if (!Func.arg_empty())
@@ -2335,8 +2282,6 @@ SDValue RISCVTargetLowering::LowerFormalArguments(
23352282

23362283
if (CallConv == CallingConv::Fast)
23372284
CCInfo.AnalyzeFormalArguments(Ins, CC_RISCV_FastCC);
2338-
else if (CallConv == CallingConv::GHC)
2339-
CCInfo.AnalyzeFormalArguments(Ins, CC_RISCV_GHC);
23402285
else
23412286
analyzeInputArgs(MF, CCInfo, Ins, /*IsRet=*/false);
23422287

@@ -2537,8 +2482,6 @@ SDValue RISCVTargetLowering::LowerCall(CallLoweringInfo &CLI,
25372482

25382483
if (CallConv == CallingConv::Fast)
25392484
ArgCCInfo.AnalyzeCallOperands(Outs, CC_RISCV_FastCC);
2540-
else if (CallConv == CallingConv::GHC)
2541-
ArgCCInfo.AnalyzeCallOperands(Outs, CC_RISCV_GHC);
25422485
else
25432486
analyzeOutputArgs(MF, ArgCCInfo, Outs, /*IsRet=*/false, &CLI);
25442487

@@ -2826,9 +2769,6 @@ RISCVTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
28262769
analyzeOutputArgs(DAG.getMachineFunction(), CCInfo, Outs, /*IsRet=*/true,
28272770
nullptr);
28282771

2829-
if (CallConv == CallingConv::GHC && !RVLocs.empty())
2830-
report_fatal_error("GHC functions return void only");
2831-
28322772
SDValue Glue;
28332773
SmallVector<SDValue, 4> RetOps(1, Chain);
28342774

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ RISCVRegisterInfo::RISCVRegisterInfo(unsigned HwMode)
4545
const MCPhysReg *
4646
RISCVRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
4747
auto &Subtarget = MF->getSubtarget<RISCVSubtarget>();
48-
if (MF->getFunction().getCallingConv() == CallingConv::GHC)
49-
return CSR_NoRegs_SaveList;
5048
if (MF->getFunction().hasFnAttribute("interrupt")) {
5149
if (Subtarget.hasStdExtD())
5250
return CSR_XLEN_F64_Interrupt_SaveList;
@@ -193,11 +191,9 @@ Register RISCVRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
193191

194192
const uint32_t *
195193
RISCVRegisterInfo::getCallPreservedMask(const MachineFunction & MF,
196-
CallingConv::ID CC) const {
194+
CallingConv::ID /*CC*/) const {
197195
auto &Subtarget = MF.getSubtarget<RISCVSubtarget>();
198196

199-
if (CC == CallingConv::GHC)
200-
return CSR_NoRegs_RegMask;
201197
switch (Subtarget.getTargetABI()) {
202198
default:
203199
llvm_unreachable("Unrecognized ABI");

llvm/test/CodeGen/RISCV/ghccc-rv32.ll

Lines changed: 0 additions & 114 deletions
This file was deleted.

llvm/test/CodeGen/RISCV/ghccc-rv64.ll

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)