Skip to content

Commit 5afdceb

Browse files
committed
[RISCV] Add RISCVISD opcode for PseudoLLA.
Rather than emitting a MachineSDNode from lowering. Let isel match it. This is consistent with the RISCVISD::HI and ADD_LO nodes that were also added. Having them both the same will make D127679 consistent. Reviewed By: reames Differential Revision: https://reviews.llvm.org/D127714
1 parent ee28837 commit 5afdceb

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3606,7 +3606,7 @@ SDValue RISCVTargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG,
36063606
// Use PC-relative addressing to access the symbol. This generates the
36073607
// pattern (PseudoLLA sym), which expands to (addi (auipc %pcrel_hi(sym))
36083608
// %pcrel_lo(auipc)).
3609-
return SDValue(DAG.getMachineNode(RISCV::PseudoLLA, DL, Ty, Addr), 0);
3609+
return DAG.getNode(RISCVISD::LLA, DL, Ty, Addr);
36103610

36113611
// Use PC-relative addressing to access the GOT for this symbol, then load
36123612
// the address from the GOT. This generates the pattern (PseudoLA sym),
@@ -3639,7 +3639,7 @@ SDValue RISCVTargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG,
36393639
// the address space. This generates the pattern (PseudoLLA sym), which
36403640
// expands to (addi (auipc %pcrel_hi(sym)) %pcrel_lo(auipc)).
36413641
SDValue Addr = getTargetNode(N, DL, Ty, DAG, 0);
3642-
return SDValue(DAG.getMachineNode(RISCV::PseudoLLA, DL, Ty, Addr), 0);
3642+
return DAG.getNode(RISCVISD::LLA, DL, Ty, Addr);
36433643
}
36443644
}
36453645
}
@@ -11115,6 +11115,7 @@ const char *RISCVTargetLowering::getTargetNodeName(unsigned Opcode) const {
1111511115
NODE_NAME_CASE(TAIL)
1111611116
NODE_NAME_CASE(ADD_LO)
1111711117
NODE_NAME_CASE(HI)
11118+
NODE_NAME_CASE(LLA)
1111811119
NODE_NAME_CASE(MULHSU)
1111911120
NODE_NAME_CASE(SLLW)
1112011121
NODE_NAME_CASE(SRAW)

llvm/lib/Target/RISCV/RISCVISelLowering.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ enum NodeType : unsigned {
4747
// Get the Hi 20 bits from an address. Selected to LUI.
4848
HI,
4949

50+
// Represents an AUIPC+ADDI pair. Selected to PseudoLLA.
51+
LLA,
52+
5053
// Multiply high for signedxunsigned.
5154
MULHSU,
5255
// RV64I shifts, directly matching the semantics of the named RISC-V

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def riscv_read_cycle_wide : SDNode<"RISCVISD::READ_CYCLE_WIDE",
8585

8686
def riscv_add_lo : SDNode<"RISCVISD::ADD_LO", SDTIntBinOp>;
8787
def riscv_hi : SDNode<"RISCVISD::HI", SDTIntUnaryOp>;
88+
def riscv_lla : SDNode<"RISCVISD::LLA", SDTIntUnaryOp>;
8889

8990
//===----------------------------------------------------------------------===//
9091
// Operand and SDNode transformation definitions.
@@ -1376,6 +1377,11 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0, Size = 8, isCodeGenOnly = 0,
13761377
def PseudoLLA : Pseudo<(outs GPR:$dst), (ins bare_symbol:$src), [],
13771378
"lla", "$dst, $src">;
13781379

1380+
def : Pat<(riscv_lla tglobaladdr:$in), (PseudoLLA tglobaladdr:$in)>;
1381+
def : Pat<(riscv_lla tblockaddress:$in), (PseudoLLA tblockaddress:$in)>;
1382+
def : Pat<(riscv_lla tjumptable:$in), (PseudoLLA tjumptable:$in)>;
1383+
def : Pat<(riscv_lla tconstpool:$in), (PseudoLLA tconstpool:$in)>;
1384+
13791385
let hasSideEffects = 0, mayLoad = 1, mayStore = 0, Size = 8, isCodeGenOnly = 0,
13801386
isAsmParserOnly = 1 in
13811387
def PseudoLA : Pseudo<(outs GPR:$dst), (ins bare_symbol:$src), [],

0 commit comments

Comments
 (0)