Skip to content

Commit e1e754d

Browse files
committed
The following changes made to addressed the comments like
a)Refactored the code for proper indent with clang format. b)Updated SelectAddrRegImm9 to fall back to already isel exist pattern for ADD. c)Used UTC (utils/update_llc_test_checks.py) to generate the FileCheck CHECKS d)Updated the llvm-mc testcase accordingly.
1 parent 7962538 commit e1e754d

File tree

6 files changed

+23
-31
lines changed

6 files changed

+23
-31
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
15271527
case Match_InvalidUImm9:
15281528
return generateImmOutOfRangeError(
15291529
Operands, ErrorInfo, 0, (1 << 9) - 1,
1530-
"immediate offset must be in the range[0-511]");
1530+
"immediate offset must be in the range");
15311531
case Match_InvalidBareSImm9Lsb0:
15321532
return generateImmOutOfRangeError(
15331533
Operands, ErrorInfo, -(1 << 8), (1 << 8) - 2,

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ static constexpr DecoderListEntry DecoderList32[]{
790790
{DecoderTableXmipscmov32,
791791
{RISCV::FeatureVendorXMIPSCMov},
792792
"MIPS mips.ccmov"},
793-
{DecoderTableXmipscbop32, {RISCV::FeatureVendorXMIPSCBOP},
793+
{DecoderTableXmipscbop32,
794+
{RISCV::FeatureVendorXMIPSCBOP},
794795
"MIPS mips.pref"},
795796
{DecoderTableXAndes32, XAndesGroup, "Andes extensions"},
796797
// Standard Extensions

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,22 +2945,6 @@ bool RISCVDAGToDAGISel::SelectAddrRegImm9(SDValue Addr, SDValue &Base,
29452945
Offset = CurDAG->getSignedTargetConstant(CVal, DL, VT);
29462946
return true;
29472947
}
2948-
2949-
// Handle with 12 bit offset with sign bit off with ADDI.
2950-
// For Immediate Range [0, 2047]
2951-
else if (Addr.getOpcode() == ISD::ADD &&
2952-
isa<ConstantSDNode>(Addr.getOperand(1))) {
2953-
assert(!isUInt<9>(CVal) && "uimm9 not already handled?");
2954-
2955-
if (isUInt<11>(CVal)) {
2956-
Base = SDValue(CurDAG->getMachineNode(
2957-
RISCV::ADDI, DL, VT, Addr.getOperand(0),
2958-
CurDAG->getSignedTargetConstant(CVal, DL, VT)),
2959-
0);
2960-
Offset = CurDAG->getTargetConstant(0, DL, VT);
2961-
return true;
2962-
}
2963-
}
29642948
}
29652949

29662950
Base = Addr;

llvm/test/CodeGen/RISCV/xmips-cbop.ll

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
12
; RUN: llc -mtriple=riscv32 -mattr=+xmipscbop -mattr=+m -verify-machineinstrs < %s \
23
; RUN: | FileCheck %s -check-prefix=RV32XMIPSPREFETCH
34
; RUN: llc -mtriple=riscv64 -mattr=+xmipscbop -mattr=+m -verify-machineinstrs < %s \
45
; RUN: | FileCheck %s -check-prefix=RV64XMIPSPREFETCH
56

67
define void @prefetch_read(ptr noundef %ptr) nounwind {
78
; RV32XMIPSPREFETCH-LABEL: prefetch_read:
8-
; RV32XMIPSPREFETCH: mips.pref 8, 1(a0)
9+
; RV32XMIPSPREFETCH: # %bb.0: # %entry
10+
; RV32XMIPSPREFETCH-NEXT: mips.pref 8, 1(a0)
11+
; RV32XMIPSPREFETCH-NEXT: ret
912
;
1013
; RV64XMIPSPREFETCH-LABEL: prefetch_read:
11-
; RV64XMIPSPREFETCH: mips.pref 8, 1(a0)
14+
; RV64XMIPSPREFETCH: # %bb.0: # %entry
15+
; RV64XMIPSPREFETCH-NEXT: mips.pref 8, 1(a0)
16+
; RV64XMIPSPREFETCH-NEXT: ret
1217
entry:
1318
%arrayidx = getelementptr inbounds nuw i8, ptr %ptr, i64 1
1419
tail call void @llvm.prefetch.p0(ptr nonnull %arrayidx, i32 0, i32 0, i32 1)
1520
ret void
16-
ret void
1721
}
18-
22+
1923
define void @prefetch_write(ptr noundef %ptr) nounwind {
2024
; RV32XMIPSPREFETCH-LABEL: prefetch_write:
21-
; RV32XMIPSPREFETCH: addi a0, a0, 512
22-
; RV32XMIPSPREFETCH-NEXT: mips.pref 9, 0(a0)
25+
; RV32XMIPSPREFETCH: # %bb.0:
26+
; RV32XMIPSPREFETCH-NEXT: addi a0, a0, 512
27+
; RV32XMIPSPREFETCH-NEXT: mips.pref 9, 0(a0)
28+
; RV32XMIPSPREFETCH-NEXT: ret
2329
;
2430
; RV64XMIPSPREFETCH-LABEL: prefetch_write:
25-
; RV64XMIPSPREFETCH: addi a0, a0, 512
26-
; RV64XMIPSPREFETCH-NEXT: mips.pref 9, 0(a0)
27-
entry:
31+
; RV64XMIPSPREFETCH: # %bb.0:
32+
; RV64XMIPSPREFETCH-NEXT: addi a0, a0, 512
33+
; RV64XMIPSPREFETCH-NEXT: mips.pref 9, 0(a0)
34+
; RV64XMIPSPREFETCH-NEXT: ret
2835
%arrayidx = getelementptr inbounds nuw i8, ptr %ptr, i64 512
2936
tail call void @llvm.prefetch.p0(ptr nonnull %arrayidx, i32 1, i32 0, i32 1)
3037
ret void

llvm/test/MC/RISCV/xmips-invalid.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# RUN: not llvm-mc -triple=riscv64 < %s 2>&1 | FileCheck %s -check-prefixes=CHECK-FEATURE
2-
# RUN: not llvm-mc -triple=riscv64 -mattr=+xmipslsp,+xmipscmov,+xmipsbcop < %s 2>&1 | FileCheck %s
2+
# RUN: not llvm-mc -triple=riscv64 -mattr=+xmipslsp,+xmipscmov,+Xmipscbop < %s 2>&1 | FileCheck %s
33

44
mips.pref 8, 512(a0)
5-
# CHECK: error: invalid operand for instruction
5+
# CHECK: error: immediate offset must be in the range [0, 511]
66

77
mips.pref 8
88
# CHECK: error: too few operands for instruction

llvm/test/MC/RISCV/xmips-valid.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
# CHECK-ENC: encoding: [0x0b,0x04,0xf5,0x1f]
99
mips.pref 8, 511(a0)
1010

11-
# CHECK-DIS: mips.perf 0x8, 0x1ff(a0)
11+
# CHECK-DIS: mips.pref 0x8, 0x1ff(a0)
1212

1313
# CHECK-INST: mips.pref 9, 0(a0)
1414
# CHECK-ENC: encoding: [0x8b,0x04,0x05,0x00]
1515
mips.pref 9, 0(a0)
1616

17-
# CHECK-DIS: mips.perf 0x9, 0x0(a0)
17+
# CHECK-DIS: mips.pref 0x9, 0x0(a0)
1818

1919
# CHECK-INST: mips.ccmov s0, s1, s2, s3
2020
# CHECK-ENC: encoding: [0x0b,0x34,0x99,0x9e]

0 commit comments

Comments
 (0)