Skip to content

Commit b08b9d7

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:b8b4ee6b4507 into amd-gfx:d15fa08abe6d
Local branch amd-gfx d15fa08 Merged main:d230bf3fce6d into amd-gfx:da5edb4170fd Remote branch main b8b4ee6 [Support] Add [[nodiscard]] (NFC)
2 parents d15fa08 + b8b4ee6 commit b08b9d7

File tree

5 files changed

+37
-105
lines changed

5 files changed

+37
-105
lines changed

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 475719
19+
#define LLVM_MAIN_REVISION 475721
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/Support/Endian.h

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ constexpr endianness system_endianness() {
4646
}
4747

4848
template <typename value_type>
49-
inline value_type byte_swap(value_type value, endianness endian) {
49+
[[nodiscard]] inline value_type byte_swap(value_type value, endianness endian) {
5050
if ((endian != native) && (endian != system_endianness()))
5151
sys::swapByteOrder(value);
5252
return value;
5353
}
5454

5555
/// Swap the bytes of value to match the given endianness.
56-
template<typename value_type, endianness endian>
57-
inline value_type byte_swap(value_type value) {
56+
template <typename value_type, endianness endian>
57+
[[nodiscard]] inline value_type byte_swap(value_type value) {
5858
return byte_swap(value, endian);
5959
}
6060

6161
/// Read a value of a particular endianness from memory.
6262
template <typename value_type, std::size_t alignment = unaligned>
63-
inline value_type read(const void *memory, endianness endian) {
63+
[[nodiscard]] inline value_type read(const void *memory, endianness endian) {
6464
value_type ret;
6565

6666
memcpy(&ret,
@@ -70,25 +70,24 @@ inline value_type read(const void *memory, endianness endian) {
7070
return byte_swap<value_type>(ret, endian);
7171
}
7272

73-
template<typename value_type,
74-
endianness endian,
75-
std::size_t alignment>
76-
inline value_type read(const void *memory) {
73+
template <typename value_type, endianness endian, std::size_t alignment>
74+
[[nodiscard]] inline value_type read(const void *memory) {
7775
return read<value_type, alignment>(memory, endian);
7876
}
7977

8078
/// Read a value of a particular endianness from a buffer, and increment the
8179
/// buffer past that value.
8280
template <typename value_type, std::size_t alignment, typename CharT>
83-
inline value_type readNext(const CharT *&memory, endianness endian) {
81+
[[nodiscard]] inline value_type readNext(const CharT *&memory,
82+
endianness endian) {
8483
value_type ret = read<value_type, alignment>(memory, endian);
8584
memory += sizeof(value_type);
8685
return ret;
8786
}
8887

89-
template<typename value_type, endianness endian, std::size_t alignment,
90-
typename CharT>
91-
inline value_type readNext(const CharT *&memory) {
88+
template <typename value_type, endianness endian, std::size_t alignment,
89+
typename CharT>
90+
[[nodiscard]] inline value_type readNext(const CharT *&memory) {
9291
return readNext<value_type, alignment, CharT>(memory, endian);
9392
}
9493

@@ -114,7 +113,8 @@ using make_unsigned_t = std::make_unsigned_t<value_type>;
114113
/// Read a value of a particular endianness from memory, for a location
115114
/// that starts at the given bit offset within the first byte.
116115
template <typename value_type, endianness endian, std::size_t alignment>
117-
inline value_type readAtBitAlignment(const void *memory, uint64_t startBit) {
116+
[[nodiscard]] inline value_type readAtBitAlignment(const void *memory,
117+
uint64_t startBit) {
118118
assert(startBit < 8);
119119
if (startBit == 0)
120120
return read<value_type, endian, alignment>(memory);
@@ -349,36 +349,42 @@ using aligned_big_t = detail::packed_endian_specific_integral<T, big, aligned>;
349349

350350
namespace endian {
351351

352-
template <typename T, endianness E> inline T read(const void *P) {
352+
template <typename T, endianness E> [[nodiscard]] inline T read(const void *P) {
353353
return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
354354
}
355355

356-
inline uint16_t read16(const void *P, endianness E) {
356+
[[nodiscard]] inline uint16_t read16(const void *P, endianness E) {
357357
return read<uint16_t>(P, E);
358358
}
359-
inline uint32_t read32(const void *P, endianness E) {
359+
[[nodiscard]] inline uint32_t read32(const void *P, endianness E) {
360360
return read<uint32_t>(P, E);
361361
}
362-
inline uint64_t read64(const void *P, endianness E) {
362+
[[nodiscard]] inline uint64_t read64(const void *P, endianness E) {
363363
return read<uint64_t>(P, E);
364364
}
365365

366-
template <endianness E> inline uint16_t read16(const void *P) {
366+
template <endianness E> [[nodiscard]] inline uint16_t read16(const void *P) {
367367
return read<uint16_t, E>(P);
368368
}
369-
template <endianness E> inline uint32_t read32(const void *P) {
369+
template <endianness E> [[nodiscard]] inline uint32_t read32(const void *P) {
370370
return read<uint32_t, E>(P);
371371
}
372-
template <endianness E> inline uint64_t read64(const void *P) {
372+
template <endianness E> [[nodiscard]] inline uint64_t read64(const void *P) {
373373
return read<uint64_t, E>(P);
374374
}
375375

376-
inline uint16_t read16le(const void *P) { return read16<little>(P); }
377-
inline uint32_t read32le(const void *P) { return read32<little>(P); }
378-
inline uint64_t read64le(const void *P) { return read64<little>(P); }
379-
inline uint16_t read16be(const void *P) { return read16<big>(P); }
380-
inline uint32_t read32be(const void *P) { return read32<big>(P); }
381-
inline uint64_t read64be(const void *P) { return read64<big>(P); }
376+
[[nodiscard]] inline uint16_t read16le(const void *P) {
377+
return read16<little>(P);
378+
}
379+
[[nodiscard]] inline uint32_t read32le(const void *P) {
380+
return read32<little>(P);
381+
}
382+
[[nodiscard]] inline uint64_t read64le(const void *P) {
383+
return read64<little>(P);
384+
}
385+
[[nodiscard]] inline uint16_t read16be(const void *P) { return read16<big>(P); }
386+
[[nodiscard]] inline uint32_t read32be(const void *P) { return read32<big>(P); }
387+
[[nodiscard]] inline uint64_t read64be(const void *P) { return read64<big>(P); }
382388

383389
template <typename T, endianness E> inline void write(void *P, T V) {
384390
*(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,10 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
642642
setI16x2OperationAction(ISD::UREM, MVT::v2i16, Legal, Custom);
643643

644644
// Other arithmetic and logic ops are unsupported.
645-
setOperationAction({ISD::SDIV, ISD::UDIV, ISD::SRA, ISD::SRL, ISD::MULHS,
646-
ISD::MULHU, ISD::FP_TO_SINT, ISD::FP_TO_UINT,
647-
ISD::SINT_TO_FP, ISD::UINT_TO_FP},
645+
setOperationAction({ISD::AND, ISD::OR, ISD::XOR, ISD::SDIV, ISD::UDIV,
646+
ISD::SRA, ISD::SRL, ISD::MULHS, ISD::MULHU,
647+
ISD::FP_TO_SINT, ISD::FP_TO_UINT, ISD::SINT_TO_FP,
648+
ISD::UINT_TO_FP},
648649
MVT::v2i16, Expand);
649650

650651
setOperationAction(ISD::ADDC, MVT::i32, Legal);

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,17 +1486,6 @@ defm OR : BITWISE<"or", or>;
14861486
defm AND : BITWISE<"and", and>;
14871487
defm XOR : BITWISE<"xor", xor>;
14881488

1489-
// Lower logical ops as bitwise ops on b32.
1490-
// By this point the constants get legalized into a bitcast from i32, so that's
1491-
// what we need to match here.
1492-
def: Pat<(or Int32Regs:$a, (v2i16 (bitconvert (i32 imm:$b)))),
1493-
(ORb32ri Int32Regs:$a, imm:$b)>;
1494-
def: Pat<(xor Int32Regs:$a, (v2i16 (bitconvert (i32 imm:$b)))),
1495-
(XORb32ri Int32Regs:$a, imm:$b)>;
1496-
def: Pat<(and Int32Regs:$a, (v2i16 (bitconvert (i32 imm:$b)))),
1497-
(ANDb32ri Int32Regs:$a, imm:$b)>;
1498-
1499-
15001489
def NOT1 : NVPTXInst<(outs Int1Regs:$dst), (ins Int1Regs:$src),
15011490
"not.pred \t$dst, $src;",
15021491
[(set Int1Regs:$dst, (not Int1Regs:$src))]>;

llvm/test/CodeGen/NVPTX/i16x2-instructions.ll

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -235,70 +235,6 @@ define <2 x i16> @test_mul(<2 x i16> %a, <2 x i16> %b) #0 {
235235
ret <2 x i16> %r
236236
}
237237

238-
;; Logical ops are available on all GPUs as regular 32-bit logical ops
239-
; COMMON-LABEL: test_or(
240-
; COMMON-DAG: ld.param.u32 [[A:%r[0-9]+]], [test_or_param_0];
241-
; COMMON-DAG: ld.param.u32 [[B:%r[0-9]+]], [test_or_param_1];
242-
; COMMON-NEXT: or.b32 [[R:%r[0-9]+]], [[A]], [[B]];
243-
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
244-
; COMMON-NEXT: ret;
245-
define <2 x i16> @test_or(<2 x i16> %a, <2 x i16> %b) #0 {
246-
%r = or <2 x i16> %a, %b
247-
ret <2 x i16> %r
248-
}
249-
250-
; Check that we can lower or with immediate arguments.
251-
; COMMON-LABEL: test_or_imm_0(
252-
; COMMON-DAG: ld.param.u32 [[A:%r[0-9]+]], [test_or_imm_0_param_0];
253-
; COMMON-NEXT: or.b32 [[R:%r[0-9]+]], [[A]], 131073;
254-
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
255-
; COMMON-NEXT: ret;
256-
define <2 x i16> @test_or_imm_0(<2 x i16> %a) #0 {
257-
%r = or <2 x i16> <i16 1, i16 2>, %a
258-
ret <2 x i16> %r
259-
}
260-
261-
; COMMON-LABEL: test_or_imm_1(
262-
; COMMON-DAG: ld.param.u32 [[B:%r[0-9]+]], [test_or_imm_1_param_0];
263-
; COMMON-NEXT: or.b32 [[R:%r[0-9]+]], [[A]], 131073;
264-
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
265-
; COMMON-NEXT: ret;
266-
define <2 x i16> @test_or_imm_1(<2 x i16> %a) #0 {
267-
%r = or <2 x i16> %a, <i16 1, i16 2>
268-
ret <2 x i16> %r
269-
}
270-
271-
; COMMON-LABEL: test_xor(
272-
; COMMON-DAG: ld.param.u32 [[A:%r[0-9]+]], [test_xor_param_0];
273-
; COMMON-DAG: ld.param.u32 [[B:%r[0-9]+]], [test_xor_param_1];
274-
; COMMON-NEXT: xor.b32 [[R:%r[0-9]+]], [[A]], [[B]];
275-
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
276-
; COMMON-NEXT: ret;
277-
define <2 x i16> @test_xor(<2 x i16> %a, <2 x i16> %b) #0 {
278-
%r = xor <2 x i16> %a, %b
279-
ret <2 x i16> %r
280-
}
281-
282-
; Check that we can lower xor with immediate arguments.
283-
; COMMON-LABEL: test_xor_imm_0(
284-
; COMMON-DAG: ld.param.u32 [[A:%r[0-9]+]], [test_xor_imm_0_param_0];
285-
; COMMON-NEXT: xor.b32 [[R:%r[0-9]+]], [[A]], 131073;
286-
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
287-
; COMMON-NEXT: ret;
288-
define <2 x i16> @test_xor_imm_0(<2 x i16> %a) #0 {
289-
%r = xor <2 x i16> <i16 1, i16 2>, %a
290-
ret <2 x i16> %r
291-
}
292-
293-
; COMMON-LABEL: test_xor_imm_1(
294-
; COMMON-DAG: ld.param.u32 [[B:%r[0-9]+]], [test_xor_imm_1_param_0];
295-
; COMMON-NEXT: xor.b32 [[R:%r[0-9]+]], [[A]], 131073;
296-
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
297-
; COMMON-NEXT: ret;
298-
define <2 x i16> @test_xor_imm_1(<2 x i16> %a) #0 {
299-
%r = xor <2 x i16> %a, <i16 1, i16 2>
300-
ret <2 x i16> %r
301-
}
302238

303239
; COMMON-LABEL: .func test_ldst_v2i16(
304240
; COMMON-DAG: ld.param.u64 [[A:%rd[0-9]+]], [test_ldst_v2i16_param_0];

0 commit comments

Comments
 (0)