Skip to content

Commit b70119d

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:888e2849036c7a216dd6208a2fe5a59393d4767a into amd-gfx:72c6d960b5b2
Local branch amd-gfx 72c6d96 Merged main:2377b9773d40d2daa249ac20fe452f041bb6a88c into amd-gfx:89b53e67852d Remote branch main 888e284 [NVPTX] Use PTX prmt for llvm.bswap (llvm#85545)
2 parents 72c6d96 + 888e284 commit b70119d

File tree

48 files changed

+1722
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1722
-146
lines changed

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "
1111

1212
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
1313
set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
14-
set(LLVM_ENABLE_FATLTO OFF CACHE BOOL "")
14+
set(LLVM_ENABLE_FATLTO ON CACHE BOOL "")
1515
set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "")
1616
set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
1717
set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8481,6 +8481,14 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
84818481
case llvm::Triple::riscv64:
84828482
AddRISCVTargetArgs(Args, CmdArgs);
84838483
break;
8484+
8485+
case llvm::Triple::hexagon:
8486+
if (Args.hasFlag(options::OPT_mdefault_build_attributes,
8487+
options::OPT_mno_default_build_attributes, true)) {
8488+
CmdArgs.push_back("-mllvm");
8489+
CmdArgs.push_back("-hexagon-add-build-attributes");
8490+
}
8491+
break;
84848492
}
84858493

84868494
// Consume all the warning flags. Usually this would be handled more
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// Enabled by default for assembly
2+
// RUN: %clang --target=hexagon-unknown-elf -### %s 2>&1 \
3+
// RUN: | FileCheck %s -check-prefix CHECK-ENABLED
4+
5+
/// Can be forced on or off for assembly.
6+
// RUN: %clang --target=hexagon-unknown-elf -### %s 2>&1 -mno-default-build-attributes \
7+
// RUN: | FileCheck %s -check-prefix CHECK-DISABLED
8+
// RUN: %clang --target=hexagon-unknown-elf -### %s 2>&1 -mdefault-build-attributes \
9+
// RUN: | FileCheck %s -check-prefix CHECK-ENABLED
10+
11+
/// Option ignored C/C++ (since we always emit hardware and ABI build attributes
12+
/// during codegen).
13+
// RUN: %clang --target=hexagon-unknown-elf -### -x c %s -mdefault-build-attributes 2>&1 \
14+
// RUN: | FileCheck %s -check-prefix CHECK-DISABLED-C
15+
// RUN: %clang --target=hexagon-unknown-elf -### -x c++ %s -mdefault-build-attributes 2>&1 \
16+
// RUN: | FileCheck %s -check-prefix CHECK-DISABLED-C
17+
18+
// CHECK-DISABLED-NOT: "-hexagon-add-build-attributes"
19+
// CHECK-DISABLED-C-NOT: "-hexagon-add-build-attributes"
20+
// CHECK-ENABLED: "-hexagon-add-build-attributes"
21+
// CHECK-DISABLED-C: argument unused during compilation: '-mdefault-build-attributes'

llvm/include/llvm/BinaryFormat/ELF.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,8 @@ enum : unsigned {
11411141

11421142
SHT_CSKY_ATTRIBUTES = 0x70000001U,
11431143

1144+
SHT_HEXAGON_ATTRIBUTES = 0x70000003U,
1145+
11441146
SHT_HIPROC = 0x7fffffff, // Highest processor arch-specific type.
11451147
SHT_LOUSER = 0x80000000, // Lowest type reserved for applications.
11461148
SHT_HIUSER = 0xffffffff // Highest type reserved for applications.

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 493251
19+
#define LLVM_MAIN_REVISION 493262
2020

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

llvm/include/llvm/Object/ELFObjectFile.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class ELFObjectFileBase : public ObjectFile {
6060

6161
SubtargetFeatures getMIPSFeatures() const;
6262
SubtargetFeatures getARMFeatures() const;
63+
SubtargetFeatures getHexagonFeatures() const;
6364
Expected<SubtargetFeatures> getRISCVFeatures() const;
6465
SubtargetFeatures getLoongArchFeatures() const;
6566

@@ -397,6 +398,9 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
397398
case ELF::EM_RISCV:
398399
Type = ELF::SHT_RISCV_ATTRIBUTES;
399400
break;
401+
case ELF::EM_HEXAGON:
402+
Type = ELF::SHT_HEXAGON_ATTRIBUTES;
403+
break;
400404
default:
401405
return Error::success();
402406
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===-- HexagonAttributeParser.h - Hexagon Attribute Parser -----*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_SUPPORT_HEXAGONATTRIBUTEPARSER_H
10+
#define LLVM_SUPPORT_HEXAGONATTRIBUTEPARSER_H
11+
12+
#include "llvm/Support/ELFAttributeParser.h"
13+
#include "llvm/Support/HexagonAttributes.h"
14+
15+
namespace llvm {
16+
class HexagonAttributeParser : public ELFAttributeParser {
17+
struct DisplayHandler {
18+
HexagonAttrs::AttrType Attribute;
19+
Error (HexagonAttributeParser::*Routine)(unsigned);
20+
};
21+
22+
static const DisplayHandler DisplayRoutines[];
23+
24+
Error handler(uint64_t Tag, bool &Handled) override;
25+
26+
public:
27+
HexagonAttributeParser(ScopedPrinter *SP)
28+
: ELFAttributeParser(SP, HexagonAttrs::getHexagonAttributeTags(),
29+
"hexagon") {}
30+
HexagonAttributeParser()
31+
: ELFAttributeParser(HexagonAttrs::getHexagonAttributeTags(), "hexagon") {
32+
}
33+
};
34+
35+
} // namespace llvm
36+
37+
#endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//===-- HexagonAttributes.h - Qualcomm Hexagon Attributes -----------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_SUPPORT_HEXAGONATTRIBUTES_H
10+
#define LLVM_SUPPORT_HEXAGONATTRIBUTES_H
11+
12+
#include "llvm/Support/ELFAttributes.h"
13+
14+
namespace llvm {
15+
namespace HexagonAttrs {
16+
17+
const TagNameMap &getHexagonAttributeTags();
18+
19+
enum AttrType : unsigned {
20+
ARCH = 4,
21+
HVXARCH = 5,
22+
HVXIEEEFP = 6,
23+
HVXQFLOAT = 7,
24+
ZREG = 8,
25+
AUDIO = 9,
26+
CABAC = 10
27+
};
28+
29+
} // namespace HexagonAttrs
30+
} // namespace llvm
31+
32+
#endif

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,25 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned BitWidth,
611611
return false;
612612
}
613613

614+
static SDValue simplifyUseOfIntToFP(SDValue Op, const APInt &DemandedBits,
615+
SelectionDAG &DAG) {
616+
unsigned Opc = Op.getOpcode();
617+
assert((Opc == ISD::SINT_TO_FP || Opc == ISD::UINT_TO_FP) &&
618+
"Invalid Int -> FP Opcode");
619+
if (!DemandedBits.isSignMask())
620+
return SDValue();
621+
622+
EVT VT = Op.getValueType();
623+
if (Opc == ISD::UINT_TO_FP)
624+
return DAG.getConstant(0, SDLoc(Op), VT);
625+
626+
EVT InnerVT = Op.getOperand(0).getValueType();
627+
if (VT.getScalarSizeInBits() == InnerVT.getScalarSizeInBits())
628+
return DAG.getBitcast(VT, Op.getOperand(0));
629+
630+
return SDValue();
631+
}
632+
614633
bool TargetLowering::SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits,
615634
DAGCombinerInfo &DCI) const {
616635
SelectionDAG &DAG = DCI.DAG;
@@ -816,6 +835,11 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
816835
}
817836
break;
818837
}
838+
case ISD::UINT_TO_FP:
839+
case ISD::SINT_TO_FP:
840+
if (SDValue R = simplifyUseOfIntToFP(Op, DemandedBits, DAG))
841+
return R;
842+
break;
819843
case ISD::SIGN_EXTEND_INREG: {
820844
// If none of the extended bits are demanded, eliminate the sextinreg.
821845
SDValue Op0 = Op.getOperand(0);
@@ -2313,6 +2337,12 @@ bool TargetLowering::SimplifyDemandedBits(
23132337
Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
23142338
break;
23152339
}
2340+
case ISD::UINT_TO_FP:
2341+
case ISD::SINT_TO_FP:
2342+
if (SDValue R = simplifyUseOfIntToFP(Op, DemandedBits, TLO.DAG))
2343+
return TLO.CombineTo(Op, R);
2344+
Known = TLO.DAG.computeKnownBits(Op, DemandedElts, Depth);
2345+
break;
23162346
case ISD::SIGN_EXTEND_INREG: {
23172347
SDValue Op0 = Op.getOperand(0);
23182348
EVT ExVT = cast<VTSDNode>(Op.getOperand(1))->getVT();

llvm/lib/Object/ELF.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ StringRef llvm::object::getELFSectionTypeName(uint32_t Machine, unsigned Type) {
251251
}
252252
break;
253253
case ELF::EM_HEXAGON:
254-
switch (Type) { STRINGIFY_ENUM_CASE(ELF, SHT_HEX_ORDERED); }
254+
switch (Type) {
255+
STRINGIFY_ENUM_CASE(ELF, SHT_HEX_ORDERED);
256+
STRINGIFY_ENUM_CASE(ELF, SHT_HEXAGON_ATTRIBUTES);
257+
}
255258
break;
256259
case ELF::EM_X86_64:
257260
switch (Type) { STRINGIFY_ENUM_CASE(ELF, SHT_X86_64_UNWIND); }

0 commit comments

Comments
 (0)