Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1668,17 +1668,18 @@ void SystemZAsmPrinter::emitPPA2(Module &M) {
uint8_t Flgs = static_cast<uint8_t>(PPA2Flags::CompileForBinaryFloatingPoint);
Flgs |= static_cast<uint8_t>(PPA2Flags::CompiledWithXPLink);

bool IsASCII = true;
if (auto *MD = M.getModuleFlag("zos_le_char_mode")) {
const StringRef &CharMode = cast<MDString>(MD)->getString();
if (CharMode == "ascii") {
Flgs |= static_cast<uint8_t>(
PPA2Flags::CompiledUnitASCII); // Setting bit for ASCII char. mode.
} else if (CharMode != "ebcdic") {
report_fatal_error(
"Only ascii or ebcdic are valid values for zos_le_char_mode "
"metadata");
}
if (CharMode == "ebcdic")
IsASCII = false;
else if (CharMode != "ascii")
OutContext.reportError(
{}, "Only ascii or ebcdic are allowed for zos_le_char_mode");
}
if (IsASCII)
Flgs |= static_cast<uint8_t>(
PPA2Flags::CompiledUnitASCII); // Setting bit for ASCII char. mode.

OutStreamer->emitInt8(Flgs);
OutStreamer->emitInt8(0x00); // Reserved.
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/CodeGen/SystemZ/zos-hlasm-out.ll
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ entry:
}

declare void @outs(ptr noundef, ...)

!llvm.module.flags = !{!0}
!0 = !{i32 1, !"zos_le_char_mode", !"ebcdic"}
14 changes: 12 additions & 2 deletions llvm/test/CodeGen/SystemZ/zos-ppa2.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
; RUN: llc -mtriple s390x-ibm-zos -mcpu=z15 -asm-verbose=true < %s | FileCheck %s
; RUN: sed -e 's/!"MODE"/!"ascii"/' -e 's/BYTE/133/' %s > %t.ascii.ll
; RUN: llc -mtriple s390x-ibm-zos -mcpu=z15 -asm-verbose=true < %t.ascii.ll | \
; RUN: FileCheck %t.ascii.ll

; RUN: sed -e 's/!"MODE"/!"ebcdic"/' -e 's/BYTE/129/' %s > %t.ebcdic.ll
; RUN: llc -mtriple s390x-ibm-zos -mcpu=z15 -asm-verbose=true < %t.ebcdic.ll | \
; RUN: FileCheck %t.ebcdic.ll

; CHECK: C_CODE64 CATTR
; CHECK: L#PPA2:
Expand All @@ -10,7 +16,7 @@
; CHECK: .long 0
; CHECK: .long L#DVS-L#PPA2
; CHECK: .long 0
; CHECK: .byte 129
; CHECK: .byte BYTE
; CHECK: .byte 0
; CHECK: .short 0
; CHECK: L#DVS:
Expand All @@ -24,6 +30,10 @@
; CHECK: .byte 3
; CHECK: .short 30
; CHECK: .ascii "\323\323\345\324@@@@@@{{((\\3[0-7]{2}){4})}}\361\371\367\360\360\361\360\361\360\360\360\360\360\360\360\360"

!llvm.module.flags = !{!0}
!0 = !{i32 1, !"zos_le_char_mode", !"MODE"}

define void @void_test() {
entry:
ret void
Expand Down