-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[SystemZ][z/OS] Introduce new AsmStreamer for z/OS specific HLASM format output #108433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //===- SystemZHLASMAsmStreamer.cpp - HLASM Assembly Text Output -----------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "SystemZHLASMAsmStreamer.h" | ||
|
|
||
| void SystemZHLASMAsmStreamer::changeSection(MCSection *Section, | ||
| uint32_t Subsection) { | ||
| MCStreamer::changeSection(Section, Subsection); | ||
| } | ||
|
|
||
| void SystemZHLASMAsmStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) { | ||
| MCStreamer::emitLabel(Symbol, Loc); | ||
|
|
||
| Symbol->print(OS, MAI); | ||
| // TODO: update LabelSuffix in SystemZMCAsmInfoGOFF once tests have been | ||
| // moved to HLASM syntax. | ||
| // OS << MAI->getLabelSuffix(); | ||
| OS << '\n'; | ||
| } |
93 changes: 93 additions & 0 deletions
93
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| //===- SystemZHLASMAsmStreamer.h - HLASM Assembly Text Output ---*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file declares the SystemZHLASMAsmStreamer class. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "llvm/ADT/SmallString.h" | ||
| #include "llvm/ADT/StringRef.h" | ||
| #include "llvm/MC/MCAsmBackend.h" | ||
| #include "llvm/MC/MCAsmInfo.h" | ||
| #include "llvm/MC/MCAssembler.h" | ||
| #include "llvm/MC/MCCodeEmitter.h" | ||
| #include "llvm/MC/MCContext.h" | ||
| #include "llvm/MC/MCInst.h" | ||
| #include "llvm/MC/MCInstPrinter.h" | ||
| #include "llvm/MC/MCObjectWriter.h" | ||
| #include "llvm/MC/MCStreamer.h" | ||
| #include "llvm/MC/MCTargetOptions.h" | ||
| #include "llvm/Support/FormattedStream.h" | ||
|
|
||
| using namespace llvm; | ||
|
|
||
| class SystemZHLASMAsmStreamer final : public MCStreamer { | ||
| std::unique_ptr<formatted_raw_ostream> OSOwner; | ||
| formatted_raw_ostream &OS; | ||
| const MCAsmInfo *MAI; | ||
| std::unique_ptr<MCInstPrinter> InstPrinter; | ||
| std::unique_ptr<MCAssembler> Assembler; | ||
| SmallString<128> CommentToEmit; | ||
| raw_svector_ostream CommentStream; | ||
| raw_null_ostream NullStream; | ||
|
|
||
| bool IsVerboseAsm = false; | ||
|
|
||
| public: | ||
| SystemZHLASMAsmStreamer(MCContext &Context, | ||
| std::unique_ptr<formatted_raw_ostream> os, | ||
| MCInstPrinter *printer, | ||
| std::unique_ptr<MCCodeEmitter> emitter, | ||
| std::unique_ptr<MCAsmBackend> asmbackend) | ||
| : MCStreamer(Context), OSOwner(std::move(os)), OS(*OSOwner), | ||
| MAI(Context.getAsmInfo()), InstPrinter(printer), | ||
| Assembler(std::make_unique<MCAssembler>( | ||
| Context, std::move(asmbackend), std::move(emitter), | ||
| (asmbackend) ? asmbackend->createObjectWriter(NullStream) | ||
| : nullptr)), | ||
| CommentStream(CommentToEmit) { | ||
| assert(InstPrinter); | ||
| if (Assembler->getBackendPtr()) | ||
| setAllowAutoPadding(Assembler->getBackend().allowAutoPadding()); | ||
|
|
||
| Context.setUseNamesOnTempLabels(true); | ||
| auto *TO = Context.getTargetOptions(); | ||
| if (!TO) | ||
| return; | ||
| IsVerboseAsm = TO->AsmVerbose; | ||
| if (IsVerboseAsm) | ||
| InstPrinter->setCommentStream(CommentStream); | ||
| } | ||
|
|
||
| MCAssembler &getAssembler() { return *Assembler; } | ||
|
|
||
| /// Return true if this streamer supports verbose assembly at all. | ||
| bool isVerboseAsm() const override { return IsVerboseAsm; } | ||
|
|
||
| /// Do we support EmitRawText? | ||
| bool hasRawTextSupport() const override { return true; } | ||
|
|
||
| /// @name MCStreamer Interface | ||
| /// @{ | ||
|
|
||
| void changeSection(MCSection *Section, uint32_t Subsection) override; | ||
|
|
||
| void emitLabel(MCSymbol *Symbol, SMLoc Loc) override; | ||
| bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override { | ||
| return false; | ||
| } | ||
|
|
||
| void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, | ||
| Align ByteAlignment) override {} | ||
|
|
||
| void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, | ||
| uint64_t Size = 0, Align ByteAlignment = Align(1), | ||
| SMLoc Loc = SMLoc()) override {} | ||
|
|
||
| /// @} | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ; RUN: llc < %s -emit-gnuas-syntax-on-zos=0 --mtriple=s390x-ibm-zos | FileCheck --match-full-lines %s | ||
|
|
||
| ; empty function | ||
| ; CHECK: foo | ||
| ; CHECK-NEXT: L#func_end0 | ||
| define void @foo() { | ||
| entry: | ||
| ret void | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move 'on' to the next line and add '.' at the end.