Skip to content

Commit 4d80e93

Browse files
authored
[RISCV] Remove RISCVISD opcodes for LGA, LA_TLS_IE, and LA_TLS_GD. (llvm#70137)
This effectively reverts f912d21 This was originally done for consistency with RISCVISD::ADD_LO so that all nodes were emitted as RISCVISD nodes. I've received feedback a couple times that its not worth it. So I'm putting it back.
1 parent 7fde4ff commit 4d80e93

File tree

3 files changed

+12
-36
lines changed

3 files changed

+12
-36
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6452,15 +6452,15 @@ SDValue RISCVTargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG,
64526452
// Use PC-relative addressing to access the GOT for this symbol, then load
64536453
// the address from the GOT. This generates the pattern (PseudoLGA sym),
64546454
// which expands to (ld (addi (auipc %got_pcrel_hi(sym)) %pcrel_lo(auipc))).
6455+
SDValue Load =
6456+
SDValue(DAG.getMachineNode(RISCV::PseudoLGA, DL, Ty, Addr), 0);
64556457
MachineFunction &MF = DAG.getMachineFunction();
64566458
MachineMemOperand *MemOp = MF.getMachineMemOperand(
64576459
MachinePointerInfo::getGOT(MF),
64586460
MachineMemOperand::MOLoad | MachineMemOperand::MODereferenceable |
64596461
MachineMemOperand::MOInvariant,
64606462
LLT(Ty.getSimpleVT()), Align(Ty.getFixedSizeInBits() / 8));
6461-
SDValue Load =
6462-
DAG.getMemIntrinsicNode(RISCVISD::LGA, DL, DAG.getVTList(Ty, MVT::Other),
6463-
{DAG.getEntryNode(), Addr}, Ty, MemOp);
6463+
DAG.setNodeMemRefs(cast<MachineSDNode>(Load.getNode()), {MemOp});
64646464
return Load;
64656465
}
64666466

@@ -6482,16 +6482,15 @@ SDValue RISCVTargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG,
64826482
// not be within 2GiB of PC, so use GOT-indirect addressing to access the
64836483
// symbol. This generates the pattern (PseudoLGA sym), which expands to
64846484
// (ld (addi (auipc %got_pcrel_hi(sym)) %pcrel_lo(auipc))).
6485+
SDValue Load =
6486+
SDValue(DAG.getMachineNode(RISCV::PseudoLGA, DL, Ty, Addr), 0);
64856487
MachineFunction &MF = DAG.getMachineFunction();
64866488
MachineMemOperand *MemOp = MF.getMachineMemOperand(
64876489
MachinePointerInfo::getGOT(MF),
64886490
MachineMemOperand::MOLoad | MachineMemOperand::MODereferenceable |
64896491
MachineMemOperand::MOInvariant,
64906492
LLT(Ty.getSimpleVT()), Align(Ty.getFixedSizeInBits() / 8));
6491-
SDValue Load =
6492-
DAG.getMemIntrinsicNode(RISCVISD::LGA, DL,
6493-
DAG.getVTList(Ty, MVT::Other),
6494-
{DAG.getEntryNode(), Addr}, Ty, MemOp);
6493+
DAG.setNodeMemRefs(cast<MachineSDNode>(Load.getNode()), {MemOp});
64956494
return Load;
64966495
}
64976496

@@ -6546,15 +6545,15 @@ SDValue RISCVTargetLowering::getStaticTLSAddr(GlobalAddressSDNode *N,
65466545
// the pattern (PseudoLA_TLS_IE sym), which expands to
65476546
// (ld (auipc %tls_ie_pcrel_hi(sym)) %pcrel_lo(auipc)).
65486547
SDValue Addr = DAG.getTargetGlobalAddress(GV, DL, Ty, 0, 0);
6548+
SDValue Load =
6549+
SDValue(DAG.getMachineNode(RISCV::PseudoLA_TLS_IE, DL, Ty, Addr), 0);
65496550
MachineFunction &MF = DAG.getMachineFunction();
65506551
MachineMemOperand *MemOp = MF.getMachineMemOperand(
65516552
MachinePointerInfo::getGOT(MF),
65526553
MachineMemOperand::MOLoad | MachineMemOperand::MODereferenceable |
65536554
MachineMemOperand::MOInvariant,
65546555
LLT(Ty.getSimpleVT()), Align(Ty.getFixedSizeInBits() / 8));
6555-
SDValue Load = DAG.getMemIntrinsicNode(
6556-
RISCVISD::LA_TLS_IE, DL, DAG.getVTList(Ty, MVT::Other),
6557-
{DAG.getEntryNode(), Addr}, Ty, MemOp);
6556+
DAG.setNodeMemRefs(cast<MachineSDNode>(Load.getNode()), {MemOp});
65586557

65596558
// Add the thread pointer.
65606559
SDValue TPReg = DAG.getRegister(RISCV::X4, XLenVT);
@@ -6590,7 +6589,8 @@ SDValue RISCVTargetLowering::getDynamicTLSAddr(GlobalAddressSDNode *N,
65906589
// This generates the pattern (PseudoLA_TLS_GD sym), which expands to
65916590
// (addi (auipc %tls_gd_pcrel_hi(sym)) %pcrel_lo(auipc)).
65926591
SDValue Addr = DAG.getTargetGlobalAddress(GV, DL, Ty, 0, 0);
6593-
SDValue Load = DAG.getNode(RISCVISD::LA_TLS_GD, DL, Ty, Addr);
6592+
SDValue Load =
6593+
SDValue(DAG.getMachineNode(RISCV::PseudoLA_TLS_GD, DL, Ty, Addr), 0);
65946594

65956595
// Prepare argument list to generate call.
65966596
ArgListTy Args;
@@ -17787,10 +17787,7 @@ const char *RISCVTargetLowering::getTargetNodeName(unsigned Opcode) const {
1778717787
NODE_NAME_CASE(ADD_LO)
1778817788
NODE_NAME_CASE(HI)
1778917789
NODE_NAME_CASE(LLA)
17790-
NODE_NAME_CASE(LGA)
1779117790
NODE_NAME_CASE(ADD_TPREL)
17792-
NODE_NAME_CASE(LA_TLS_IE)
17793-
NODE_NAME_CASE(LA_TLS_GD)
1779417791
NODE_NAME_CASE(MULHSU)
1779517792
NODE_NAME_CASE(SLLW)
1779617793
NODE_NAME_CASE(SRAW)

llvm/lib/Target/RISCV/RISCVISelLowering.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ enum NodeType : unsigned {
5555
// Selected as PseudoAddTPRel. Used to emit a TP-relative relocation.
5656
ADD_TPREL,
5757

58-
// Load address.
59-
LA_TLS_GD,
60-
6158
// Multiply high for signedxunsigned.
6259
MULHSU,
6360
// RV64I shifts, directly matching the semantics of the named RISC-V
@@ -418,12 +415,7 @@ enum NodeType : unsigned {
418415
// have memop! In fact, starting from FIRST_TARGET_MEMORY_OPCODE all
419416
// opcodes will be thought as target memory ops!
420417

421-
// Represents an AUIPC+L[WD] pair. Selected to PseudoLGA.
422-
LGA = ISD::FIRST_TARGET_MEMORY_OPCODE,
423-
// Load initial exec thread-local address.
424-
LA_TLS_IE,
425-
426-
TH_LWD,
418+
TH_LWD = ISD::FIRST_TARGET_MEMORY_OPCODE,
427419
TH_LWUD,
428420
TH_LDD,
429421
TH_SWD,

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,12 @@ def riscv_read_cycle_wide : SDNode<"RISCVISD::READ_CYCLE_WIDE",
8484
def riscv_add_lo : SDNode<"RISCVISD::ADD_LO", SDTIntBinOp>;
8585
def riscv_hi : SDNode<"RISCVISD::HI", SDTIntUnaryOp>;
8686
def riscv_lla : SDNode<"RISCVISD::LLA", SDTIntUnaryOp>;
87-
def riscv_lga : SDNode<"RISCVISD::LGA", SDTLoad,
88-
[SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
8987
def riscv_add_tprel : SDNode<"RISCVISD::ADD_TPREL",
9088
SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
9189
SDTCisSameAs<0, 2>,
9290
SDTCisSameAs<0, 3>,
9391
SDTCisInt<0>]>>;
9492

95-
def riscv_la_tls_ie : SDNode<"RISCVISD::LA_TLS_IE", SDTLoad,
96-
[SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
97-
def riscv_la_tls_gd : SDNode<"RISCVISD::LA_TLS_GD", SDTIntUnaryOp>;
98-
9993
//===----------------------------------------------------------------------===//
10094
// Operand and SDNode transformation definitions.
10195
//===----------------------------------------------------------------------===//
@@ -1690,8 +1684,6 @@ let hasSideEffects = 0, mayLoad = 1, mayStore = 0, Size = 8, isCodeGenOnly = 0,
16901684
def PseudoLGA : Pseudo<(outs GPR:$dst), (ins bare_symbol:$src), [],
16911685
"lga", "$dst, $src">;
16921686

1693-
def : Pat<(iPTR (riscv_lga tglobaladdr:$in)), (PseudoLGA tglobaladdr:$in)>;
1694-
16951687
let hasSideEffects = 0, mayLoad = 1, mayStore = 0, Size = 8, isCodeGenOnly = 0,
16961688
isAsmParserOnly = 1 in
16971689
def PseudoLA : Pseudo<(outs GPR:$dst), (ins bare_symbol:$src), [],
@@ -1708,16 +1700,11 @@ let hasSideEffects = 0, mayLoad = 1, mayStore = 0, Size = 8, isCodeGenOnly = 0,
17081700
def PseudoLA_TLS_IE : Pseudo<(outs GPR:$dst), (ins bare_symbol:$src), [],
17091701
"la.tls.ie", "$dst, $src">;
17101702

1711-
def : Pat<(iPTR (riscv_la_tls_ie tglobaltlsaddr:$in)),
1712-
(PseudoLA_TLS_IE tglobaltlsaddr:$in)>;
1713-
17141703
let hasSideEffects = 0, mayLoad = 0, mayStore = 0, Size = 8, isCodeGenOnly = 0,
17151704
isAsmParserOnly = 1 in
17161705
def PseudoLA_TLS_GD : Pseudo<(outs GPR:$dst), (ins bare_symbol:$src), [],
17171706
"la.tls.gd", "$dst, $src">;
17181707

1719-
def : Pat<(riscv_la_tls_gd tglobaltlsaddr:$in),
1720-
(PseudoLA_TLS_GD tglobaltlsaddr:$in)>;
17211708

17221709
/// Sign/Zero Extends
17231710

0 commit comments

Comments
 (0)