Skip to content

Commit 66ca3f1

Browse files
authored
[SystemZ] Serialize ada entry flags (#169395)
Adding support for serializing the ada entry flags helps with mir based test cases. Without this change, the flags are simple displayed as being "unkmown".
1 parent ea1e62d commit 66ca3f1

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,3 +2360,19 @@ SystemZInstrInfo::isCopyInstrImpl(const MachineInstr &MI) const {
23602360

23612361
return std::nullopt;
23622362
}
2363+
2364+
std::pair<unsigned, unsigned>
2365+
SystemZInstrInfo::decomposeMachineOperandsTargetFlags(unsigned TF) const {
2366+
return std::make_pair(TF, 0u);
2367+
}
2368+
2369+
ArrayRef<std::pair<unsigned, const char *>>
2370+
SystemZInstrInfo::getSerializableDirectMachineOperandTargetFlags() const {
2371+
using namespace SystemZII;
2372+
2373+
static const std::pair<unsigned, const char *> TargetFlags[] = {
2374+
{MO_ADA_DATA_SYMBOL_ADDR, "systemz-ada-datasymboladdr"},
2375+
{MO_ADA_INDIRECT_FUNC_DESC, "systemz-ada-indirectfuncdesc"},
2376+
{MO_ADA_DIRECT_FUNC_DESC, "systemz-ada-directfuncdesc"}};
2377+
return ArrayRef(TargetFlags);
2378+
}

llvm/lib/Target/SystemZ/SystemZInstrInfo.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,13 @@ enum {
7171
MO_GOT = (1 << 0),
7272

7373
// @INDNTPOFF
74-
MO_INDNTPOFF = (2 << 0)
75-
};
74+
MO_INDNTPOFF = (2 << 0),
7675

77-
// z/OS XPLink specific: classifies the types of
78-
// accesses to the ADA (Associated Data Area).
79-
// These enums contains values that overlap with the above MO_ enums,
80-
// but that's fine since the above enums are used with ELF,
81-
// while these values are used with z/OS.
82-
enum {
83-
MO_ADA_DATA_SYMBOL_ADDR = 1,
84-
MO_ADA_INDIRECT_FUNC_DESC,
85-
MO_ADA_DIRECT_FUNC_DESC,
76+
// z/OS XPLink specific: classifies the types of
77+
// accesses to the ADA (Associated Data Area).
78+
MO_ADA_DATA_SYMBOL_ADDR = (1 << 2),
79+
MO_ADA_INDIRECT_FUNC_DESC = (2 << 2),
80+
MO_ADA_DIRECT_FUNC_DESC = (3 << 2),
8681
};
8782

8883
// Classifies a branch.
@@ -391,6 +386,12 @@ class SystemZInstrInfo : public SystemZGenInstrInfo {
391386

392387
std::optional<DestSourcePair>
393388
isCopyInstrImpl(const MachineInstr &MI) const override;
389+
390+
std::pair<unsigned, unsigned>
391+
decomposeMachineOperandsTargetFlags(unsigned TF) const override;
392+
393+
ArrayRef<std::pair<unsigned, const char *>>
394+
getSerializableDirectMachineOperandTargetFlags() const override;
394395
};
395396

396397
} // end namespace llvm
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; RUN: llc -mtriple=s390x-ibm-zos -stop-after=systemz-isel --simplify-mir < %s | FileCheck %s
2+
3+
4+
declare i64 @calc(i64 noundef, ptr noundef)
5+
declare i64 @morework(i64 noundef)
6+
7+
@i = external local_unnamed_addr global i64, align 8
8+
9+
define i64 @work() {
10+
entry:
11+
; CHECK: %{{.*}}:addr64bit = ADA_ENTRY_VALUE target-flags(systemz-ada-datasymboladdr) @i,
12+
; CHECK: %{{.*}}:addr64bit = ADA_ENTRY_VALUE target-flags(systemz-ada-directfuncdesc) @calc,
13+
; CHECK: %{{.*}}:addr64bit = ADA_ENTRY_VALUE target-flags(systemz-ada-indirectfuncdesc) @morework,
14+
%0 = load i64, ptr @i, align 8
15+
%call = tail call i64 @calc(i64 noundef %0, ptr noundef nonnull @morework) #2
16+
ret i64 %call
17+
}

0 commit comments

Comments
 (0)