Skip to content

Commit 77613aa

Browse files
committed
Hexagon
1 parent 4ec5e5f commit 77613aa

File tree

5 files changed

+122
-162
lines changed

5 files changed

+122
-162
lines changed

llvm/lib/Target/Hexagon/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tablegen(LLVM HexagonGenDisassemblerTables.inc -gen-disassembler)
1111
tablegen(LLVM HexagonGenInstrInfo.inc -gen-instr-info)
1212
tablegen(LLVM HexagonGenMCCodeEmitter.inc -gen-emitter)
1313
tablegen(LLVM HexagonGenRegisterInfo.inc -gen-register-info)
14+
tablegen(LLVM HexagonGenSDNodeInfo.inc -gen-sd-node-info)
1415
tablegen(LLVM HexagonGenSubtargetInfo.inc -gen-subtarget)
1516

1617
add_public_tablegen_target(HexagonCommonTableGen)

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,66 +1914,6 @@ HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
19141914
computeRegisterProperties(&HRI);
19151915
}
19161916

1917-
const char* HexagonTargetLowering::getTargetNodeName(unsigned Opcode) const {
1918-
switch ((HexagonISD::NodeType)Opcode) {
1919-
case HexagonISD::ADDC: return "HexagonISD::ADDC";
1920-
case HexagonISD::SUBC: return "HexagonISD::SUBC";
1921-
case HexagonISD::ALLOCA: return "HexagonISD::ALLOCA";
1922-
case HexagonISD::AT_GOT: return "HexagonISD::AT_GOT";
1923-
case HexagonISD::AT_PCREL: return "HexagonISD::AT_PCREL";
1924-
case HexagonISD::BARRIER: return "HexagonISD::BARRIER";
1925-
case HexagonISD::CALL: return "HexagonISD::CALL";
1926-
case HexagonISD::CALLnr: return "HexagonISD::CALLnr";
1927-
case HexagonISD::CALLR: return "HexagonISD::CALLR";
1928-
case HexagonISD::COMBINE: return "HexagonISD::COMBINE";
1929-
case HexagonISD::CONST32_GP: return "HexagonISD::CONST32_GP";
1930-
case HexagonISD::CONST32: return "HexagonISD::CONST32";
1931-
case HexagonISD::CP: return "HexagonISD::CP";
1932-
case HexagonISD::DCFETCH: return "HexagonISD::DCFETCH";
1933-
case HexagonISD::EH_RETURN: return "HexagonISD::EH_RETURN";
1934-
case HexagonISD::TSTBIT: return "HexagonISD::TSTBIT";
1935-
case HexagonISD::EXTRACTU: return "HexagonISD::EXTRACTU";
1936-
case HexagonISD::INSERT: return "HexagonISD::INSERT";
1937-
case HexagonISD::JT: return "HexagonISD::JT";
1938-
case HexagonISD::RET_GLUE: return "HexagonISD::RET_GLUE";
1939-
case HexagonISD::TC_RETURN: return "HexagonISD::TC_RETURN";
1940-
case HexagonISD::VASL: return "HexagonISD::VASL";
1941-
case HexagonISD::VASR: return "HexagonISD::VASR";
1942-
case HexagonISD::VLSR: return "HexagonISD::VLSR";
1943-
case HexagonISD::MFSHL: return "HexagonISD::MFSHL";
1944-
case HexagonISD::MFSHR: return "HexagonISD::MFSHR";
1945-
case HexagonISD::SSAT: return "HexagonISD::SSAT";
1946-
case HexagonISD::USAT: return "HexagonISD::USAT";
1947-
case HexagonISD::SMUL_LOHI: return "HexagonISD::SMUL_LOHI";
1948-
case HexagonISD::UMUL_LOHI: return "HexagonISD::UMUL_LOHI";
1949-
case HexagonISD::USMUL_LOHI: return "HexagonISD::USMUL_LOHI";
1950-
case HexagonISD::VEXTRACTW: return "HexagonISD::VEXTRACTW";
1951-
case HexagonISD::VINSERTW0: return "HexagonISD::VINSERTW0";
1952-
case HexagonISD::VROR: return "HexagonISD::VROR";
1953-
case HexagonISD::READCYCLE: return "HexagonISD::READCYCLE";
1954-
case HexagonISD::READTIMER: return "HexagonISD::READTIMER";
1955-
case HexagonISD::THREAD_POINTER:
1956-
return "HexagonISD::THREAD_POINTER";
1957-
case HexagonISD::PTRUE: return "HexagonISD::PTRUE";
1958-
case HexagonISD::PFALSE: return "HexagonISD::PFALSE";
1959-
case HexagonISD::D2P: return "HexagonISD::D2P";
1960-
case HexagonISD::P2D: return "HexagonISD::P2D";
1961-
case HexagonISD::V2Q: return "HexagonISD::V2Q";
1962-
case HexagonISD::Q2V: return "HexagonISD::Q2V";
1963-
case HexagonISD::QCAT: return "HexagonISD::QCAT";
1964-
case HexagonISD::QTRUE: return "HexagonISD::QTRUE";
1965-
case HexagonISD::QFALSE: return "HexagonISD::QFALSE";
1966-
case HexagonISD::TL_EXTEND: return "HexagonISD::TL_EXTEND";
1967-
case HexagonISD::TL_TRUNCATE: return "HexagonISD::TL_TRUNCATE";
1968-
case HexagonISD::TYPECAST: return "HexagonISD::TYPECAST";
1969-
case HexagonISD::VALIGN: return "HexagonISD::VALIGN";
1970-
case HexagonISD::VALIGNADDR: return "HexagonISD::VALIGNADDR";
1971-
case HexagonISD::ISEL: return "HexagonISD::ISEL";
1972-
case HexagonISD::OP_END: break;
1973-
}
1974-
return nullptr;
1975-
}
1976-
19771917
bool
19781918
HexagonTargetLowering::validateConstPtrAlignment(SDValue Ptr, Align NeedAlign,
19791919
const SDLoc &dl, SelectionDAG &DAG) const {
@@ -3368,8 +3308,6 @@ HexagonTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
33683308
default:
33693309
#ifndef NDEBUG
33703310
Op.getNode()->dumpr(&DAG);
3371-
if (Opc > HexagonISD::OP_BEGIN && Opc < HexagonISD::OP_END)
3372-
errs() << "Error: check for a non-legal type in this operation\n";
33733311
#endif
33743312
llvm_unreachable("Should not custom lower this!");
33753313

llvm/lib/Target/Hexagon/HexagonISelLowering.h

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -29,102 +29,6 @@
2929

3030
namespace llvm {
3131

32-
namespace HexagonISD {
33-
34-
// clang-format off
35-
enum NodeType : unsigned {
36-
OP_BEGIN = ISD::BUILTIN_OP_END,
37-
38-
CONST32 = OP_BEGIN,
39-
CONST32_GP, // For marking data present in GP.
40-
ADDC, // Add with carry: (X, Y, Cin) -> (X+Y, Cout).
41-
SUBC, // Sub with carry: (X, Y, Cin) -> (X+~Y+Cin, Cout).
42-
ALLOCA,
43-
44-
AT_GOT, // Index in GOT.
45-
AT_PCREL, // Offset relative to PC.
46-
47-
CALL, // Function call.
48-
CALLnr, // Function call that does not return.
49-
CALLR,
50-
51-
RET_GLUE, // Return with a glue operand.
52-
BARRIER, // Memory barrier.
53-
JT, // Jump table.
54-
CP, // Constant pool.
55-
56-
COMBINE,
57-
VASL, // Vector shifts by a scalar value
58-
VASR,
59-
VLSR,
60-
MFSHL, // Funnel shifts with the shift amount guaranteed to be
61-
MFSHR, // within the range of the bit width of the element.
62-
63-
SSAT, // Signed saturate.
64-
USAT, // Unsigned saturate.
65-
SMUL_LOHI, // Same as ISD::SMUL_LOHI, but opaque to the combiner.
66-
UMUL_LOHI, // Same as ISD::UMUL_LOHI, but opaque to the combiner.
67-
// We want to legalize MULH[SU] to [SU]MUL_LOHI, but the
68-
// combiner will keep rewriting it back to MULH[SU].
69-
USMUL_LOHI, // Like SMUL_LOHI, but unsigned*signed.
70-
71-
TSTBIT,
72-
INSERT,
73-
EXTRACTU,
74-
VEXTRACTW,
75-
VINSERTW0,
76-
VROR,
77-
TC_RETURN,
78-
EH_RETURN,
79-
DCFETCH,
80-
READCYCLE,
81-
READTIMER,
82-
THREAD_POINTER,
83-
PTRUE,
84-
PFALSE,
85-
D2P, // Convert 8-byte value to 8-bit predicate register. [*]
86-
P2D, // Convert 8-bit predicate register to 8-byte value. [*]
87-
V2Q, // Convert HVX vector to a vector predicate reg. [*]
88-
Q2V, // Convert vector predicate to an HVX vector. [*]
89-
// [*] The equivalence is defined as "Q <=> (V != 0)",
90-
// where the != operation compares bytes.
91-
// Note: V != 0 is implemented as V >u 0.
92-
QCAT,
93-
QTRUE,
94-
QFALSE,
95-
96-
TL_EXTEND, // Wrappers for ISD::*_EXTEND and ISD::TRUNCATE to prevent DAG
97-
TL_TRUNCATE, // from auto-folding operations, e.g.
98-
// (i32 ext (i16 ext i8)) would be folded to (i32 ext i8).
99-
// To simplify the type legalization, we want to keep these
100-
// single steps separate during type legalization.
101-
// TL_[EXTEND|TRUNCATE] Inp, i128 _, i32 Opc
102-
// * Inp is the original input to extend/truncate,
103-
// * _ is a dummy operand with an illegal type (can be undef),
104-
// * Opc is the original opcode.
105-
// The legalization process (in Hexagon lowering code) will
106-
// first deal with the "real" types (i.e. Inp and the result),
107-
// and once all of them are processed, the wrapper node will
108-
// be replaced with the original ISD node. The dummy illegal
109-
// operand is there to make sure that the legalization hooks
110-
// are called again after everything else is legal, giving
111-
// us the opportunity to undo the wrapping.
112-
113-
TYPECAST, // No-op that's used to convert between different legal
114-
// types in a register.
115-
VALIGN, // Align two vectors (in Op0, Op1) to one that would have
116-
// been loaded from address in Op2.
117-
VALIGNADDR, // Align vector address: Op0 & -Op1, except when it is
118-
// an address in a vector load, then it's a no-op.
119-
ISEL, // Marker for nodes that were created during ISel, and
120-
// which need explicit selection (would have been left
121-
// unselected otherwise).
122-
OP_END
123-
};
124-
125-
} // end namespace HexagonISD
126-
// clang-format on
127-
12832
class HexagonSubtarget;
12933

13034
class HexagonTargetLowering : public TargetLowering {
@@ -189,7 +93,6 @@ class HexagonTargetLowering : public TargetLowering {
18993
void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
19094
SelectionDAG &DAG) const override;
19195

192-
const char *getTargetNodeName(unsigned Opcode) const override;
19396
std::pair<MVT, unsigned>
19497
handleMaskRegisterForCallingConv(const HexagonSubtarget &Subtarget,
19598
EVT VT) const;

llvm/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,73 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "HexagonSelectionDAGInfo.h"
1314
#include "HexagonTargetMachine.h"
1415
#include "llvm/CodeGen/SelectionDAG.h"
16+
17+
#define GET_SDNODE_DESC
18+
#include "HexagonGenSDNodeInfo.inc"
19+
1520
using namespace llvm;
1621

1722
#define DEBUG_TYPE "hexagon-selectiondag-info"
1823

24+
HexagonSelectionDAGInfo::HexagonSelectionDAGInfo()
25+
: SelectionDAGGenTargetInfo(HexagonGenSDNodeInfo) {}
26+
27+
const char *HexagonSelectionDAGInfo::getTargetNodeName(unsigned Opcode) const {
28+
// These nodes don't have corresponding entries in *.td files yet.
29+
switch (static_cast<HexagonISD::NodeType>(Opcode)) {
30+
case HexagonISD::ADDC:
31+
return "HexagonISD::ADDC";
32+
case HexagonISD::SUBC:
33+
return "HexagonISD::SUBC";
34+
case HexagonISD::CALLR:
35+
return "HexagonISD::CALLR";
36+
case HexagonISD::SMUL_LOHI:
37+
return "HexagonISD::SMUL_LOHI";
38+
case HexagonISD::UMUL_LOHI:
39+
return "HexagonISD::UMUL_LOHI";
40+
case HexagonISD::USMUL_LOHI:
41+
return "HexagonISD::USMUL_LOHI";
42+
case HexagonISD::VROR:
43+
return "HexagonISD::VROR";
44+
case HexagonISD::D2P:
45+
return "HexagonISD::D2P";
46+
case HexagonISD::P2D:
47+
return "HexagonISD::P2D";
48+
case HexagonISD::V2Q:
49+
return "HexagonISD::V2Q";
50+
case HexagonISD::Q2V:
51+
return "HexagonISD::Q2V";
52+
case HexagonISD::TL_EXTEND:
53+
return "HexagonISD::TL_EXTEND";
54+
case HexagonISD::TL_TRUNCATE:
55+
return "HexagonISD::TL_TRUNCATE";
56+
case HexagonISD::TYPECAST:
57+
return "HexagonISD::TYPECAST";
58+
case HexagonISD::ISEL:
59+
return "HexagonISD::ISEL";
60+
}
61+
62+
return SelectionDAGGenTargetInfo::getTargetNodeName(Opcode);
63+
}
64+
65+
void HexagonSelectionDAGInfo::verifyTargetNode(const SelectionDAG &DAG,
66+
const SDNode *N) const {
67+
switch (N->getOpcode()) {
68+
default:
69+
break;
70+
case HexagonISD::VALIGNADDR:
71+
// invalid number of operands; expected 1, got 2
72+
case HexagonISD::VINSERTW0:
73+
// operand #1 must have type i32, but has type v4i8/v2i16
74+
return;
75+
}
76+
77+
SelectionDAGGenTargetInfo::verifyTargetNode(DAG, N);
78+
}
79+
1980
SDValue HexagonSelectionDAGInfo::EmitTargetCodeForMemcpy(
2081
SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
2182
SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,

llvm/lib/Target/Hexagon/HexagonSelectionDAGInfo.h

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,68 @@
1515

1616
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
1717

18+
#define GET_SDNODE_ENUM
19+
#include "HexagonGenSDNodeInfo.inc"
20+
1821
namespace llvm {
22+
namespace HexagonISD {
23+
24+
enum NodeType : unsigned {
25+
ADDC = GENERATED_OPCODE_END, // Add with carry: (X, Y, Cin) -> (X+Y, Cout).
26+
SUBC, // Sub with carry: (X, Y, Cin) -> (X+~Y+Cin, Cout).
27+
28+
CALLR,
29+
30+
SMUL_LOHI, // Same as ISD::SMUL_LOHI, but opaque to the combiner.
31+
UMUL_LOHI, // Same as ISD::UMUL_LOHI, but opaque to the combiner.
32+
// We want to legalize MULH[SU] to [SU]MUL_LOHI, but the
33+
// combiner will keep rewriting it back to MULH[SU].
34+
USMUL_LOHI, // Like SMUL_LOHI, but unsigned*signed.
35+
36+
VROR,
37+
D2P, // Convert 8-byte value to 8-bit predicate register. [*]
38+
P2D, // Convert 8-bit predicate register to 8-byte value. [*]
39+
V2Q, // Convert HVX vector to a vector predicate reg. [*]
40+
Q2V, // Convert vector predicate to an HVX vector. [*]
41+
// [*] The equivalence is defined as "Q <=> (V != 0)",
42+
// where the != operation compares bytes.
43+
// Note: V != 0 is implemented as V >u 0.
44+
45+
TL_EXTEND, // Wrappers for ISD::*_EXTEND and ISD::TRUNCATE to prevent DAG
46+
TL_TRUNCATE, // from auto-folding operations, e.g.
47+
// (i32 ext (i16 ext i8)) would be folded to (i32 ext i8).
48+
// To simplify the type legalization, we want to keep these
49+
// single steps separate during type legalization.
50+
// TL_[EXTEND|TRUNCATE] Inp, i128 _, i32 Opc
51+
// * Inp is the original input to extend/truncate,
52+
// * _ is a dummy operand with an illegal type (can be undef),
53+
// * Opc is the original opcode.
54+
// The legalization process (in Hexagon lowering code) will
55+
// first deal with the "real" types (i.e. Inp and the result),
56+
// and once all of them are processed, the wrapper node will
57+
// be replaced with the original ISD node. The dummy illegal
58+
// operand is there to make sure that the legalization hooks
59+
// are called again after everything else is legal, giving
60+
// us the opportunity to undo the wrapping.
1961

20-
class HexagonSelectionDAGInfo : public SelectionDAGTargetInfo {
62+
TYPECAST, // No-op that's used to convert between different legal
63+
// types in a register.
64+
ISEL, // Marker for nodes that were created during ISel, and
65+
// which need explicit selection (would have been left
66+
// unselected otherwise).
67+
// clang-format on
68+
};
69+
70+
} // namespace HexagonISD
71+
72+
class HexagonSelectionDAGInfo : public SelectionDAGGenTargetInfo {
2173
public:
22-
explicit HexagonSelectionDAGInfo() = default;
74+
HexagonSelectionDAGInfo();
75+
76+
const char *getTargetNodeName(unsigned Opcode) const override;
77+
78+
void verifyTargetNode(const SelectionDAG &DAG,
79+
const SDNode *N) const override;
2380

2481
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl,
2582
SDValue Chain, SDValue Dst, SDValue Src,
@@ -29,6 +86,6 @@ class HexagonSelectionDAGInfo : public SelectionDAGTargetInfo {
2986
MachinePointerInfo SrcPtrInfo) const override;
3087
};
3188

32-
}
89+
} // namespace llvm
3390

3491
#endif

0 commit comments

Comments
 (0)