Skip to content
Open
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
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@ RUN apt-get update && apt-get -y install cmake ninja-build lzip
#USER ez80
WORKDIR /root
COPY clang/0001-Emit-GAS-sytax.patch 0001-Emit-GAS-sytax.patch
RUN curl -LO https://github.com/jacobly0/llvm-project/archive/1b767f5cc455.zip
RUN unzip 1b767f5cc455.zip
RUN cd llvm-project-1b767f5cc45505fb2d6285e717d439c6b1ea2e7f && patch -p1 < ../0001-Emit-GAS-sytax.patch
RUN cd llvm-project-1b767f5cc45505fb2d6285e717d439c6b1ea2e7f \
RUN curl -LO https://github.com/jacobly0/llvm-project/archive/005a99ce256937.zip
RUN unzip 005a99ce256937.zip
RUN cd llvm-project-005a99ce2569373524bd881207aa4a1e98a2b238 && patch -p1 < ../0001-Emit-GAS-sytax.patch
RUN cd llvm-project-005a99ce2569373524bd881207aa4a1e98a2b238 \
&& mkdir build \
&& cmake -G Ninja -DLLVM_ENABLE_PROJECTS="clang" \
-DCMAKE_INSTALL_PREFIX=/opt/local/ez80-none-elf \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=Z80 \
-DLLVM_TARGETS_TO_BUILD= \
-DLLVM_DEFAULT_TARGET_TRIPLE=ez80-none-elf \
../llvm-project-1b767f5cc45505fb2d6285e717d439c6b1ea2e7f/llvm \
../llvm-project-005a99ce2569373524bd881207aa4a1e98a2b238/llvm \
&& ninja install
RUN curl -LO https://mirror.freedif.org/GNU/binutils/binutils-2.36.1.tar.lz
RUN tar xf binutils-2.36.1.tar.lz
RUN cd binutils-2.36.1 \
&& ./configure --target=z80-none-elf --program-prefix=ez80-none-elf- --prefix=/opt/local/ez80-none-elf \
&& make -j4 \
&& make install

FROM buildpack-deps:stable
COPY --from=0 /opt/local/ez80-none-elf /opt/local/ez80-none-elf
ENV PATH=/opt/local/ez80-none-elf/bin:$PATH
87 changes: 38 additions & 49 deletions clang/0001-Emit-GAS-sytax.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
From 8974d48fac9e60a84315bffd3992904b24397575 Mon Sep 17 00:00:00 2001
From: Byron Ellacott <code@bje.id.au>
Date: Mon, 1 Feb 2021 08:00:41 +1000
Subject: [PATCH] Emit GAS sytax

---
.../Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp | 64 ++++++++++---------
.../Z80/MCTargetDesc/Z80TargetStreamer.cpp | 10 +--
llvm/lib/Target/Z80/Z80InstrInfo.td | 4 +-
3 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp b/llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp
index 9a8109b7b714..458fa87d5617 100644
--- a/llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp
+++ b/llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp
@@ -25,41 +25,45 @@ Z80MCAsmInfoELF::Z80MCAsmInfoELF(const Triple &T) {
diff -urb A/llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp B/llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp
--- A/llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp 2023-12-13 09:14:57
+++ B/llvm/lib/Target/Z80/MCTargetDesc/Z80MCAsmInfo.cpp 2023-12-15 21:17:43
@@ -33,44 +33,49 @@
DollarIsPC = true;
SeparatorString = nullptr;
CommentString = ";";
Expand All @@ -30,15 +18,19 @@ index 9a8109b7b714..458fa87d5617 100644
- BlockSeparator = " dup ";
- AsciiDirective = ByteListDirective = Data8bitsDirective = "\tdb\t";
+ ZeroDirective = "\tds\t";
+ //ZeroDirective =
+ AscizDirective = nullptr;
+ //ZeroDirective = AscizDirective = nullptr;
+ //BlockSeparator = " dup ";
+ //AsciiDirective = ByteListDirective = Data8bitsDirective = "\tdb\t";
+ AscizDirective = nullptr;
+ AsciiDirective = nullptr;
+ ByteListDirective = "\tdb\t";
OctalLiteralSyntax = AOLS_TrailingO;
NumberLiteralSyntax = ANLS_PlainDecimal;
- CharacterLiteralSyntax = ACLS_SingleQuotes;
+ CharacterLiteralSyntax = ACLS_Unknown; //ACLS_SingleQuotePrefix; //ACLS_SingleQuotes;
StringLiteralEscapeSyntax = ASLES_RepeatDelimiter;
+ CharacterLiteralSyntax = ACLS_Unknown; // ACLS_SingleQuotes;
HasPairedDoubleQuoteStringConstants = true;
HasBackslashEscapesInStringConstants = false;
StringConstantsEscapeNonPrint = EscapeNonPrint;
StringConstantsRequiredEscapes = {"\n\r\32", 4}; // include null
+ Data8bitsDirective = "\tdb\t";
Data16bitsDirective = "\tdw\t";
- Data24bitsDirective = "\tdl\t";
Expand All @@ -47,9 +39,9 @@ index 9a8109b7b714..458fa87d5617 100644
- DataULEB128Directive = "\tuleb128\t";
- DataSLEB128Directive = "\tsleb128\t";
- SectionDirective = "\tsection\t";
+ Data24bitsDirective = "\td24\t";
+ Data32bitsDirective = "\td32\t";
+ Data64bitsDirective = nullptr;//"\tdq\t";
+ Data24bitsDirective = "\td24\t"; //"\tdl\t";
+ Data32bitsDirective = "\td32\t"; //"\tdd\t";
+ Data64bitsDirective = nullptr; //"\tdq\t";
+ DataULEB128Directive = "\t.uleb128\t";
+ DataSLEB128Directive = "\t.sleb128\t";
+ SectionDirective = "\t.section\t";
Expand Down Expand Up @@ -84,7 +76,7 @@ index 9a8109b7b714..458fa87d5617 100644
DwarfCFIDirectivePrefix = "\tcfi_";
}

@@ -68,7 +72,7 @@ MCSection *Z80MCAsmInfoELF::getNonexecutableStackSection(MCContext &Ctx) const {
@@ -79,7 +84,7 @@
}

bool Z80MCAsmInfoELF::isAcceptableChar(char C) const {
Expand All @@ -93,7 +85,7 @@ index 9a8109b7b714..458fa87d5617 100644
}

bool Z80MCAsmInfoELF::shouldOmitSectionDirective(StringRef SectionName) const {
@@ -78,9 +82,9 @@ bool Z80MCAsmInfoELF::shouldOmitSectionDirective(StringRef SectionName) const {
@@ -89,10 +94,10 @@
const char *Z80MCAsmInfoELF::getBlockDirective(int64_t Size) const {
switch (Size) {
default: return nullptr;
Expand All @@ -107,17 +99,16 @@ index 9a8109b7b714..458fa87d5617 100644
+ case 4: return Data32bitsDirective;
}
}
diff --git a/llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp b/llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp
index 4ca0d9c5fa0f..350e1a18dc56 100644
--- a/llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp
+++ b/llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp
@@ -31,29 +31,29 @@ void Z80TargetAsmStreamer::emitLabel(MCSymbol *Symbol) {
diff -urb A/llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp B/llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp
--- A/llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp 2023-12-13 09:14:57
+++ B/llvm/lib/Target/Z80/MCTargetDesc/Z80TargetStreamer.cpp 2023-12-15 20:51:47
@@ -32,16 +32,16 @@

void Z80TargetAsmStreamer::emitAlign(Align Alignment) {
if (auto Mask = Alignment.value() - 1)
- OS << "\trb\t" << Mask << " - ($ - $$ + " << Mask << ") and not " << Mask
+ OS << "\tds\t" << Mask << " - ($ - $$ + " << Mask << ") and not " << Mask
<< "\n";
- OS << "\trb\t($$ - $) and " << Mask << '\n';
+ OS << "\tds\t($$ - $) and " << Mask << '\n';
}

void Z80TargetAsmStreamer::emitBlock(uint64_t NumBytes) {
Expand All @@ -132,6 +123,8 @@ index 4ca0d9c5fa0f..350e1a18dc56 100644
Symbol->print(OS, MAI);
OS << '\n';
}
@@ -53,13 +53,13 @@
}

void Z80TargetAsmStreamer::emitGlobal(MCSymbol *Symbol) {
- OS << "\tpublic\t";
Expand All @@ -146,28 +139,24 @@ index 4ca0d9c5fa0f..350e1a18dc56 100644
Symbol->print(OS, MAI);
OS << '\n';
}
diff --git a/llvm/lib/Target/Z80/Z80InstrInfo.td b/llvm/lib/Target/Z80/Z80InstrInfo.td
index ad26337c2fe4..02d111d2123a 100644
--- a/llvm/lib/Target/Z80/Z80InstrInfo.td
+++ b/llvm/lib/Target/Z80/Z80InstrInfo.td
@@ -348,7 +348,7 @@ let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
diff -urb A/llvm/lib/Target/Z80/Z80InstrInfo.td B/llvm/lib/Target/Z80/Z80InstrInfo.td
--- A/llvm/lib/Target/Z80/Z80InstrInfo.td 2023-12-13 09:14:57
+++ B/llvm/lib/Target/Z80/Z80InstrInfo.td 2023-12-15 20:47:42
@@ -378,7 +378,7 @@

let isBranch = 1, isTerminator = 1 in {
let isBarrier = 1 in {
let isBranch = true, isTerminator = true in {
let isBarrier = true in {
- def JQ : Pseudo<"jq", "\t$tgt", "", (outs), (ins jmptarget:$tgt),
+ def JQ : Pseudo<"jp", "\t$tgt", "", (outs), (ins jmptarget:$tgt),
[(br bb:$tgt)]>;
def JR : Io <NoPre, 0x18, "jr", "\t$tgt", "",
def JR : Io < NoPre, 0x18, "jr", "\t$tgt", "",
(outs), (ins jmptargetoff:$tgt)>;
@@ -364,7 +364,7 @@ let isBranch = 1, isTerminator = 1 in {
}
}
@@ -397,7 +397,7 @@
def DJNZ : Io < NoPre, 0x10, "djnz", "\t$tgt", "",
(outs), (ins jmptargetoff:$tgt)>;
let Uses = [F] in {
- def JQCC : Pseudo<"jq", "\t$cc, $tgt", "",
+ def JQCC : Pseudo<"jp", "\t$cc, $tgt", "",
(outs), (ins jmptarget:$tgt, cc:$cc),
[(Z80brcond bb:$tgt, imm:$cc, F)]>;
def JRCC : Io <NoPre, 0x18, "jr", "\t$cc, $tgt", "",
--
2.28.0

def JRCC : Io < NoPre, 0x18, "jr", "\t$cc, $tgt", "",